Login:Tests: add toHaveScreenshot and use fixtures

This commit is contained in:
Darya Umrikhina 2024-09-02 11:50:09 +04:00
parent 9ccdd6630c
commit 1470945088
4 changed files with 62 additions and 35 deletions

View File

@ -1,40 +1,34 @@
import { expect, test } from "@playwright/test";
// (c) Copyright Ascensio System SIA 2009-2024
//
// This program is a free software product.
// You can redistribute it and/or modify it under the terms
// of the GNU Affero General Public License (AGPL) version 3 as published by the Free Software
// Foundation. In accordance with Section 7(a) of the GNU AGPL its Section 15 shall be amended
// to the effect that Ascensio System SIA expressly excludes the warranty of non-infringement of
// any third-party rights.
//
// This program is distributed WITHOUT ANY WARRANTY, without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For details, see
// the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
//
// You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, EU, LV-1021.
//
// The interactive user interfaces in modified source and object code versions of the Program must
// display Appropriate Legal Notices, as required under Section 5 of the GNU AGPL version 3.
//
// Pursuant to Section 7(b) of the License you must retain the original Product logo when
// distributing the program. Pursuant to Section 7(e) we decline to grant you any rights under
// trademark law for use of our trademarks.
//
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
test.beforeEach(async ({ page }) => {
await page.route("*/**/logo.ashx**", async (route) => {
await route.fulfill({
contentType: "image/svg+xml",
path: `../../public/images/logo/loginpage.svg`,
});
});
await page.route(
"*/**/login/_next/public/images/**/*",
async (route, request) => {
const imagePath = request
.url()
.split("/login/_next/public/images/")
.at(-1)!
.split("?")[0];
await route.fulfill({
contentType: "image/*",
path: `../../public/images/${imagePath}`,
});
},
);
});
import { expect, test } from "./fixtures /base";
import { endpoints } from "./mocking/endpoints";
test("render wizard", async ({ page }) => {
await page.route("*/**/api/2.0/settings/wizard/complete", async (route) => {
const json = [
{
status: 0,
response: {
Completed: true,
},
},
];
await route.fulfill({ json });
});
test("wizard success", async ({ page, mockRequest }) => {
await mockRequest.router(endpoints.complete);
await page.goto("/login/wizard");
@ -45,6 +39,39 @@ test("render wizard", async ({ page }) => {
.fill("qwerty123");
await page.getByTestId("checkbox").click();
await expect(page).toHaveScreenshot([
"desktop",
"wizard",
"wizard-success.png",
]);
await page.getByTestId("button").click();
await expect(page).toHaveURL(/.*\//);
await expect(page).toHaveScreenshot([
"desktop",
"wizard",
"wizard-success-redirect.png",
]);
});
test("wizard error", async ({ page, mockRequest }) => {
await mockRequest.router(endpoints.complete);
await page.goto("/login/wizard");
await page.fill("[name='wizard-email']", "email@123");
await page
.getByTestId("password-input")
.getByTestId("text-input")
.fill("123");
await page.getByTestId("checkbox").click();
await page.getByTestId("button").click();
await expect(page).toHaveScreenshot([
"desktop",
"wizard",
"wizard-error.png",
]);
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB