DocSpace-client/packages/login/tests/action_tests.js

125 lines
2.9 KiB
JavaScript
Raw Normal View History

2022-02-09 12:57:19 +00:00
const Endpoints = require("./mocking/endpoints.js");
2021-12-21 07:59:11 +00:00
2022-02-09 12:57:19 +00:00
const browser = process.env.profile || "chromium";
const deviceType = process.env.DEVICE_TYPE || "desktop";
2021-12-21 07:59:11 +00:00
const isModel = !!process.env.MODEL;
const featureName = isModel
? `Login actions on '${browser}' with '${deviceType}' dimension (model)`
: `Login actions on '${browser}' with '${deviceType}' dimension`;
Feature(featureName);
// doing it before others scenario
Before(async ({ I }) => {
2022-02-09 12:57:19 +00:00
I.mockEndpoint(Endpoints.settings, "settings");
I.mockEndpoint(Endpoints.build, "build");
I.mockEndpoint(Endpoints.providers, "providers");
I.mockEndpoint(Endpoints.capabilities, "capabilities");
I.mockEndpoint(Endpoints.people, "");
I.amOnPage("/login");
2021-12-21 07:59:11 +00:00
I.wait(2);
});
2022-02-09 12:57:19 +00:00
Scenario("Checkbox click test", async ({ I }) => {
2021-12-21 07:59:11 +00:00
I.seeElement({
2022-02-09 12:57:19 +00:00
react: "Checkbox",
2021-12-21 07:59:11 +00:00
props: {
2022-02-09 12:57:19 +00:00
className: "login-checkbox",
2021-12-21 07:59:11 +00:00
isChecked: false,
},
});
2022-02-09 12:57:19 +00:00
I.click({ react: "Checkbox" });
2021-12-21 07:59:11 +00:00
I.seeElement({
2022-02-09 12:57:19 +00:00
react: "Checkbox",
2021-12-21 07:59:11 +00:00
props: {
2022-02-09 12:57:19 +00:00
className: "login-checkbox",
2021-12-21 07:59:11 +00:00
isChecked: true,
},
});
2022-02-09 12:57:19 +00:00
I.saveScreenshot(`6.checked-checkbox.png`);
2021-12-21 07:59:11 +00:00
if (!isModel) {
2022-02-09 12:57:19 +00:00
I.seeVisualDiff(`6.checked-checkbox.png`, {
2021-12-21 07:59:11 +00:00
tolerance: 1,
prepareBaseImage: false,
});
}
});
2022-02-09 12:57:19 +00:00
Scenario("Test login error", async ({ I }) => {
I.mockEndpoint(Endpoints.auth, "authError");
2021-12-21 07:59:11 +00:00
I.click({
2022-02-09 12:57:19 +00:00
react: "Button",
2021-12-21 07:59:11 +00:00
props: {
2022-02-09 12:57:19 +00:00
className: "login-button",
type: "page",
2021-12-21 07:59:11 +00:00
},
});
2022-02-09 12:57:19 +00:00
I.see("Required field");
I.fillField("login", "test@mail.ru");
2021-12-21 07:59:11 +00:00
I.click({
2022-02-09 12:57:19 +00:00
react: "Button",
2021-12-21 07:59:11 +00:00
props: {
2022-02-09 12:57:19 +00:00
className: "login-button",
type: "page",
2021-12-21 07:59:11 +00:00
},
});
2022-02-09 12:57:19 +00:00
I.see("Required field");
I.fillField("password", secret("0000000"));
2021-12-21 07:59:11 +00:00
I.click({
2022-02-09 12:57:19 +00:00
react: "Button",
2021-12-21 07:59:11 +00:00
props: {
2022-02-09 12:57:19 +00:00
className: "login-button",
type: "page",
2021-12-21 07:59:11 +00:00
},
});
2022-02-09 12:57:19 +00:00
I.see("User authentication failed");
2021-12-21 07:59:11 +00:00
});
2022-02-09 12:57:19 +00:00
Scenario("Test login success", async ({ I }) => {
I.mockEndpoint(Endpoints.people, "self");
I.mockEndpoint(Endpoints.modules, "info");
I.mockEndpoint(Endpoints.auth, "authSuccess");
I.fillField("login", "test@mail.ru");
I.fillField("password", secret("12345678"));
2021-12-21 07:59:11 +00:00
I.click({
2022-02-09 12:57:19 +00:00
react: "Button",
2021-12-21 07:59:11 +00:00
props: {
2022-02-09 12:57:19 +00:00
className: "login-button",
type: "page",
2021-12-21 07:59:11 +00:00
},
});
2022-02-09 12:57:19 +00:00
I.see("Documents");
2021-12-21 07:59:11 +00:00
});
Scenario("Test fix wrong login", async ({ I }) => {
I.mockEndpoint(Endpoints.people, "self");
I.mockEndpoint(Endpoints.modules, "info");
I.mockEndpoint(Endpoints.auth, "authError");
I.fillField("login", "test@mail.ru");
I.fillField("password", secret("12345678!"));
I.click({
react: "Button",
props: {
className: "login-button",
type: "page",
},
});
I.see("User authentication failed");
I.mockEndpoint(Endpoints.auth, "authSuccess");
I.fillField("password", secret("12345678"));
I.click({
react: "Button",
props: {
className: "login-button",
type: "page",
},
});
I.see("Documents");
});