"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
    return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var react_2 = require("@testing-library/react");
var user_event_1 = __importDefault(require("@testing-library/user-event"));
var InlineSimpleAttribute_1 = require("./InlineSimpleAttribute");
var crosswalksDisplay = __importStar(require("../contexts/CrosswalksDisplayContext"));
var mdm_sdk_1 = require("@reltio/mdm-sdk");
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
var MaskedAttributesContext_1 = require("../contexts/MaskedAttributesContext");
jest.mock('@reltio/mdm-sdk', function () { return (__assign(__assign({}, jest.requireActual('@reltio/mdm-sdk')), { debounce: function (x) { return x; } })); });
var defaultProps = {
    attributeValue: {
        type: 'configuration/entityTypes/Franchise/attributes/String',
        ov: true,
        value: 'Test',
        uri: 'entities/123/attributes/String/123'
    },
    attributeType: {
        label: 'String',
        access: ['CREATE', 'UPDATE', 'DELETE', 'READ'],
        type: 'String',
        name: 'String',
        uri: 'configuration/entityTypes/Franchise/attributes/String'
    },
    crosswalk: {
        uri: 'entities/10wb4hEF/crosswalks/1PPwRPuk.3h28qA5Qw',
        type: 'configuration/sources/Reltio',
        value: '1PPwRPuk',
        attributes: ['123/attributes/String/123']
    },
    isEmpty: false,
    onIgnore: jest.fn(),
    onEdit: jest.fn(),
    onPin: jest.fn(),
    onDelete: jest.fn()
};
var metadata = {
    entityTypes: [],
    sources: []
};
var setUp = function (props, skipHover, providerValues) {
    if (props === void 0) { props = {}; }
    if (skipHover === void 0) { skipHover = false; }
    if (providerValues === void 0) { providerValues = {}; }
    var user = user_event_1.default.setup({ skipHover: skipHover });
    var Providers = function (_a) {
        var children = _a.children;
        return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: __assign({ metadata: metadata }, providerValues) },
            react_1.default.createElement(MaskedAttributesContext_1.MaskedAttributesProvider, null, children)));
    };
    return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(InlineSimpleAttribute_1.InlineSimpleAttribute, __assign({}, defaultProps, props)), { wrapper: Providers }));
};
describe('Inline simple attribute tests', function () {
    var color = '#ff00ff';
    var highlightCrosswalk = jest.fn();
    var removeHighlight = jest.fn();
    var toggleCrosswalkFocus = jest.fn();
    beforeEach(function () {
        jest.clearAllMocks();
        jest.spyOn(crosswalksDisplay, 'useCrosswalkColor').mockReturnValue(color);
        jest.spyOn(crosswalksDisplay, 'useCrosswalkFocus').mockReturnValue({
            isFocused: false,
            toggleCrosswalkFocus: toggleCrosswalkFocus
        });
        jest.spyOn(crosswalksDisplay, 'useCrosswalkHighlight').mockReturnValue({
            isHighlighted: true,
            isDimmed: true,
            highlightCrosswalk: highlightCrosswalk,
            removeHighlight: removeHighlight
        });
    });
    it('should render attribute and hide actions', function () {
        setUp();
        expect(react_2.screen.getByText('Test')).toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
        expect(react_2.screen.queryByLabelText('More actions')).not.toBeInTheDocument();
        expect(react_2.screen.queryByTestId('masking-switcher')).not.toBeInTheDocument();
        expect(crosswalksDisplay.useCrosswalkColor).toHaveBeenCalledWith(defaultProps.crosswalk);
        expect(react_2.screen.queryByTestId('inline-simple-attribute-editor')).not.toBeInTheDocument();
    });
    it('should render actions on hover', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp().user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    expect(react_2.screen.getByText('Test')).toBeInTheDocument();
                    expect(react_2.screen.getByLabelText('Pin')).toBeInTheDocument();
                    expect(react_2.screen.getByTestId('SvgPinOutlined')).toBeInTheDocument();
                    expect(react_2.screen.getByLabelText('Ignore')).toBeInTheDocument();
                    expect(react_2.screen.getByTestId('SvgIgnoredOutlined')).toBeInTheDocument();
                    expect(react_2.screen.getByLabelText('More actions')).toBeInTheDocument();
                    expect(highlightCrosswalk).toHaveBeenCalledTimes(1);
                    return [2 /*return*/];
            }
        });
    }); });
    it('should hide actions on mouse leave', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp().user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    expect(react_2.screen.getByLabelText('Pin')).toBeInTheDocument();
                    expect(highlightCrosswalk).toHaveBeenCalledTimes(1);
                    return [4 /*yield*/, user.unhover(react_2.screen.getByText('Test'))];
                case 2:
                    _a.sent();
                    expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
                    expect(removeHighlight).toHaveBeenCalledTimes(1);
                    return [2 /*return*/];
            }
        });
    }); });
    it('should show pin in pinned state even if no hover', function () {
        setUp({ attributeValue: __assign(__assign({}, defaultProps.attributeValue), { pin: true }) });
        expect(react_2.screen.getByLabelText('Pin')).not.toBeDisabled();
        expect(react_2.screen.getByTestId('SvgPin')).toBeInTheDocument();
    });
    it('should show ignore in ignored state even if no hover', function () {
        setUp({ attributeValue: __assign(__assign({}, defaultProps.attributeValue), { ignored: true }) });
        expect(react_2.screen.getByLabelText('Ignore')).not.toBeDisabled();
        expect(react_2.screen.getByTestId('SvgIgnored')).toBeInTheDocument();
    });
    it('should show actions with all actions if attribute type allows actions', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({}, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    expect(react_2.screen.getByLabelText('Focus')).toBeInTheDocument();
                    expect(react_2.screen.getByText('Edit')).not.toBeDisabled();
                    expect(react_2.screen.getByText('Delete')).not.toBeDisabled();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should disable actions based on attribute type permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
        var _a, user, rerender, editButton, deleteButton;
        return __generator(this, function (_b) {
            switch (_b.label) {
                case 0:
                    _a = setUp({ attributeType: __assign(__assign({}, defaultProps.attributeType), { access: ['READ'] }) }, true), user = _a.user, rerender = _a.rerender;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _b.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _b.sent();
                    editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
                    expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(editButton).toHaveTextContent('Edit');
                    deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
                    expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(deleteButton).toHaveTextContent('Delete');
                    rerender(react_1.default.createElement(InlineSimpleAttribute_1.InlineSimpleAttribute, __assign({}, defaultProps, { attributeValue: __assign(__assign({}, defaultProps.attributeValue), { pin: true, ignored: true }), attributeType: __assign(__assign({}, defaultProps.attributeType), { access: ['CREATE'] }) })));
                    expect(react_2.screen.getByLabelText("You don't have permissions to pin").children[0]).toBeDisabled();
                    expect(react_2.screen.getByLabelText("You don't have permissions to ignore").children[0]).toBeDisabled();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should disable delete action if props.disableDelete is true', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user, deleteButton;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({ disableDelete: true }, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
                    expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(deleteButton).toHaveTextContent('Delete');
                    expect(react_2.screen.getByText('Edit')).not.toBeDisabled();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should disable edit, pin and ignore actions if props.disableEdit is true', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user, editButton;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({ disableEdit: true }, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
                    expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
                    expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(editButton).toHaveTextContent('Edit');
                    expect(react_2.screen.getByText('Delete').parentElement).not.toHaveAttribute('aria-disabled', 'true');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should toggle crosswalk focus on click Focus', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({}, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Focus'))];
                case 3:
                    _a.sent();
                    expect(toggleCrosswalkFocus).toHaveBeenCalledWith();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should call props.onDelete on Delete button click correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({}, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByText('Delete'))];
                case 3:
                    _a.sent();
                    expect(defaultProps.onDelete).toHaveBeenCalledWith({
                        attributeType: defaultProps.attributeType,
                        attributeValue: defaultProps.attributeValue,
                        crosswalks: [defaultProps.crosswalk]
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    it('should call props.onPin on Pin button click correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({}, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Pin').childNodes[0])];
                case 2:
                    _a.sent();
                    expect(defaultProps.onPin).toHaveBeenCalledWith({
                        attributeValue: defaultProps.attributeValue
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    it('should call props.onIgnore on Ignore button click correctly', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({}, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('Ignore').childNodes[0])];
                case 2:
                    _a.sent();
                    expect(defaultProps.onIgnore).toHaveBeenCalledWith({
                        attributeValue: defaultProps.attributeValue
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    it('should render InlineSimpleAttributeEditor on Edit menu item click', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({}, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByText('Edit'))];
                case 3:
                    _a.sent();
                    expect(react_2.screen.getByTestId('inline-simple-attribute-editor')).toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should call props.onEdit when call onEdit prop of InlineSimpleAttributeEditor', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user, backdrop;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({}, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByText('Edit'))];
                case 3:
                    _a.sent();
                    expect(react_2.screen.getByTestId('inline-simple-attribute-editor')).toBeInTheDocument();
                    return [4 /*yield*/, user.type(react_2.screen.getByRole('textbox'), ' update')];
                case 4:
                    _a.sent();
                    backdrop = react_2.screen.getByRole('presentation').childNodes[0];
                    return [4 /*yield*/, user.click(backdrop)];
                case 5:
                    _a.sent();
                    expect(defaultProps.onEdit).toHaveBeenCalledWith({
                        attributeType: defaultProps.attributeType,
                        attributeValue: __assign(__assign({}, defaultProps.attributeValue), { uri: defaultProps.attributeValue.uri, value: 'Test update' }),
                        crosswalk: defaultProps.crosswalk
                    });
                    return [2 /*return*/];
            }
        });
    }); });
    it('should disable edit, pin, delete and ignore actions if it is system attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user, editButton, deleteButton;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({ attributeType: __assign(__assign({}, defaultProps.attributeType), { system: true }) }, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
                    expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
                    expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(editButton).toHaveTextContent('Edit');
                    deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
                    expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(deleteButton).toHaveTextContent('Delete');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should hide pin and ignore button for temporary attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({
                        attributeValue: __assign(__assign({}, (0, mdm_sdk_1.createNewAttribute)({ parentUri: 'entities/123', attributeType: defaultProps.attributeType })), { value: 'Test' })
                    }).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
                    expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
    it('should disable edit, pin, delete and ignore actions if crosswalk is disabled', function () { return __awaiter(void 0, void 0, void 0, function () {
        var user, editButton, deleteButton;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    user = setUp({ crosswalk: __assign(__assign({}, defaultProps.crosswalk), { deleteDate: Date.now() - 2000 }) }, true).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('Test'))];
                case 1:
                    _a.sent();
                    expect(react_2.screen.queryByLabelText('Ignore')).not.toBeInTheDocument();
                    expect(react_2.screen.queryByLabelText('Pin')).not.toBeInTheDocument();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
                    expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(editButton).toHaveTextContent('Edit');
                    deleteButton = react_2.screen.getByLabelText("You don't have permissions to delete");
                    expect(deleteButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(deleteButton).toHaveTextContent('Delete');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should disable edit action for masked attributes when user has no READ permissions', function () { return __awaiter(void 0, void 0, void 0, function () {
        var mockEntity, user, editButton;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    mockEntity = {
                        uri: 'entities/123',
                        type: 'configuration/entityTypes/Individual',
                        access: ['READ_MASKED'],
                        label: 'Test Entity'
                    };
                    user = setUp({
                        attributeType: __assign(__assign({}, defaultProps.attributeType), { access: ['READ_MASKED'], masking: true }),
                        attributeValue: __assign(__assign({}, defaultProps.attributeValue), { masked: true, value: '****' })
                    }, true, { entity: mockEntity, showMasking: true, mode: mdm_sdk_1.Mode.Viewing }).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('****'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    editButton = react_2.screen.getByLabelText("You don't have permissions to edit");
                    expect(editButton.children[0]).toHaveAttribute('aria-disabled', 'true');
                    expect(editButton).toHaveTextContent('Edit');
                    return [2 /*return*/];
            }
        });
    }); });
    it('should enable edit action for masked attributes when user has needed permissions including READ', function () { return __awaiter(void 0, void 0, void 0, function () {
        var mockEntity, user, editButton;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0:
                    mockEntity = {
                        uri: 'entities/123',
                        type: 'configuration/entityTypes/Individual',
                        access: ['READ_MASKED', 'READ'],
                        label: 'Test Entity'
                    };
                    user = setUp({
                        attributeType: __assign(__assign({}, defaultProps.attributeType), { access: ['UPDATE', 'READ_MASKED', 'READ'], masking: true }),
                        attributeValue: __assign(__assign({}, defaultProps.attributeValue), { masked: true, value: '****' })
                    }, true, { entity: mockEntity, showMasking: true, mode: mdm_sdk_1.Mode.Viewing }).user;
                    return [4 /*yield*/, user.hover(react_2.screen.getByText('****'))];
                case 1:
                    _a.sent();
                    return [4 /*yield*/, user.click(react_2.screen.getByLabelText('More actions'))];
                case 2:
                    _a.sent();
                    editButton = react_2.screen.getByText('Edit');
                    expect(editButton).not.toBeDisabled();
                    expect(react_2.screen.queryByLabelText("You don't have permissions to edit")).not.toBeInTheDocument();
                    return [2 /*return*/];
            }
        });
    }); });
});
