UNPKG

passbolt-styleguide

Version:

Passbolt styleguide contains common styling assets used by the different sites, plugin, etc.

125 lines (113 loc) 5.24 kB
/** * Passbolt ~ Open source password manager for teams * Copyright (c) 2022 Passbolt SA (https://www.passbolt.com) * * Licensed under GNU Affero General Public License version 3 of the or any later version. * For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) 2022 Passbolt SA (https://www.passbolt.com) * @license https://opensource.org/licenses/AGPL-3.0 AGPL License * @link https://www.passbolt.com Passbolt(tm) * @since 3.6.0 */ /** * Unit tests on EnterNewPassphrase in regard of specifications */ import DisplayAccountRecoveryUserSettingsPage from "./DisplayAccountRecoveryUserSettings.test.page"; import { defaultProps, defaultAccountRecoveryPolicyDto } from "./DisplayAccountRecoveryUserSettings.test.data"; import { waitFor } from "@testing-library/react"; import ManageAccountRecoveryUserSettings from "../../AccountRecovery/ManageAccountRecoveryUserSettings/ManageAccountRecoveryUserSettings"; import { formatDateTimeAgo } from "../../../../../test/utils/dateUtils"; beforeEach(() => { jest.resetModules(); }); describe("DisplayAccountRecoveryUserSettings", () => { /** * Given that I am a logged in user * And the account recovery organization policy is enabled * When I navigate to the user account recovery settings in the user settings workspace * Then I see my current account recovery settings */ it("As a logged in user I can see my account recovery settings", async () => { const accountRecoveryPolicyDto = defaultAccountRecoveryPolicyDto(); const props = defaultProps(); const page = new DisplayAccountRecoveryUserSettingsPage(props); await waitFor(() => {}); expect(page.exists()).toBeTruthy(); expect(page.status.textContent).toBe("pending"); expect(page.requestorName.textContent).toBe("Ada Lovelace (ada@passbolt.com)"); expect(page.requestDate.textContent).toBe( formatDateTimeAgo(accountRecoveryPolicyDto.modified, props.context.locale), ); }); /** * Given that I am a logged in user * And the account recovery organization policy is disabled * When I navigate to the user settings workspace * Then I can’t see the account recovery section on the left sidebar */ it("As a logged in user I cannot see my account recovery settings if the account recovery organization policy is disabled", async () => { const props = defaultProps({ accountRecoveryContext: { status: "disabled", policy: { policy: "disabled", }, }, }); const page = new DisplayAccountRecoveryUserSettingsPage(props); await waitFor(() => {}); expect(page.exists()).toBeTruthy(); expect(page.description.textContent).toBe( "Please contact your administrator to enable the account recovery feature.", ); }); /** * Given that I am a logged in user * And the account recovery organization policy is enabled * And I rejected the account recovery program * When I navigate on the user account recovery settings in the user settings workspace * Then I see a “Review” button * When I click on the “Review” button * Then I see the account recovery dialog prompt */ it("As a logged in user who has rejected the account recovery program, I can change my choice from my settings workspace", async () => { const props = defaultProps({ accountRecoveryContext: { status: "disabled", }, }); const page = new DisplayAccountRecoveryUserSettingsPage(props); await waitFor(() => {}); expect(page.exists()).toBeTruthy(); expect(page.reviewButton).not.toBeNull(); await page.clickOnReview(); }); /** * Given that I am a logged in user * And my account was created before the account recovery policy was enabled * And I previously closed or cancel the “Recovery (Optional)” and “Recovery (Mandatory)” dialog or the account recovery policy is “Optional, Opt-in” * When I am on the Account recovery settings in the profile workspace * Then I see a breadcrumb saying “All users > Username > Account recovery” * And I see the Account recovery title with a description telling me the purpose of the feature * And I see a section with the account recovery status, a “Review” button * When I click on the “Review” button * Then I see the “Recovery (Optional)” or “Recovery (Mandatory)” dialog */ it("As a logged in user I can update my account recovery choice when my review is pending for the Opt-in, Mandatory and Opt-out policies", async () => { const accountRecoveryPoliciesDto = defaultAccountRecoveryPolicyDto(); const props = defaultProps({ accountRecoveryContext: { status: "disabled", }, }); const page = new DisplayAccountRecoveryUserSettingsPage(props); await waitFor(() => {}); expect(page.exists()).toBeTruthy(); await page.clickOnReview(); expect(props.dialogContext.open).toHaveBeenCalledWith(ManageAccountRecoveryUserSettings, { organizationPolicy: accountRecoveryPoliciesDto.policy, }); }); });