UNPKG

passbolt-styleguide

Version:

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

169 lines (150 loc) 4.35 kB
/** * Passbolt ~ Open source password manager for teams * Copyright (c) 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) Passbolt SA (https://www.passbolt.com) * @license https://opensource.org/licenses/AGPL-3.0 AGPL License * @link https://www.passbolt.com Passbolt(tm) * @since 5.8.0 */ import { fireEvent, render, waitFor } from "@testing-library/react"; import React from "react"; import ManageDialogs from "../../Common/Dialog/ManageDialogs/ManageDialogs"; import DialogContextProvider from "../../../contexts/DialogContext"; import AppContext from "../../../../shared/context/AppContext/AppContext"; import MockTranslationProvider from "../../../test/mock/components/Internationalisation/MockTranslationProvider"; import AddUserToGroupDialog from "./AddUserToGroupDialog"; /** * The AddUserToGroupDialog component represented as a page */ export default class AddUserToGroupDialogPage { /** * Default constructor * @param appContext An app context * @param props Props to attach */ constructor(appContext, props) { this._page = render( <MockTranslationProvider> <AppContext.Provider value={appContext}> <DialogContextProvider> <ManageDialogs /> <AddUserToGroupDialog {...props} /> </DialogContextProvider> </AppContext.Provider> </MockTranslationProvider>, ); this.setupPageObjects(); } /** * Set up the objects of the page */ setupPageObjects() { this._displayAddUserToGroupDialog = new AddUserToGroupDialogPageObject(this._page.container); } /** * Returns the page object of display comments */ get displayAddUserToGroupDialog() { return this._displayAddUserToGroupDialog; } } /** * Page object for the TitleHeader element */ class AddUserToGroupDialogPageObject { /** * Default constructor * @param container The container which includes the add user to group dialog Component */ constructor(container) { this._container = container; } /** * Returns the menu elements */ get dialogTitle() { return this._container.querySelector(".dialog-header h2 span"); } /** * Returns the close button elements */ get closeButton() { return this._container.querySelector(".dialog-close"); } /** * Returns the save button elements */ get saveButton() { return this._container.querySelector('.submit-wrapper [type=\"submit\"]'); } /** * Returns the save button processing elements */ get saveButtonProcessing() { return this._container.querySelector('.submit-wrapper [type=\"submit\"].processing'); } /** * Returns the cancel button elements */ get cancelButton() { return this._container.querySelector(".submit-wrapper .cancel"); } /** * Returns true if the cancel button is disabled elements */ hasCancelButtonDisabled() { return this.cancelButton.hasAttribute("disabled"); } /** * Returns the error dialog */ get errorDialog() { return this._container.querySelector(".error-dialog"); } /** * Returns the error dialog message */ get errorDialogMessage() { return this._container.querySelector(".error-dialog .dialog .dialog-content .form-content"); } /** * Returns the user first name, last name, (username) */ get getUser() { return this._container.querySelectorAll(".form-content p strong")[0]; } /** * Returns the group name */ get getGroup() { return this._container.querySelectorAll(".form-content p strong")[1]; } /** * Returns true if the page object exists in the container */ exists() { return this.dialogTitle !== null; } /** * Click on the element * @param element */ async click(element) { const leftClick = { button: 0 }; fireEvent.click(element, leftClick); await waitFor(() => {}); } /** * Click on the element without wait for * @param element */ clickWithoutWaitFor(element) { const leftClick = { button: 0 }; fireEvent.click(element, leftClick); } }