1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-24 15:49:46 +02:00
planka/client/tests/acceptance/steps/login.step.js
Maksim Eltyshev 2ee1166747 feat: Version 2
Closes #627, closes #1047
2025-05-10 02:09:06 +02:00

60 lines
1.6 KiB
JavaScript

import assert from 'assert';
import { Given, Then, When } from '@cucumber/cucumber';
import { expect } from '@playwright/test';
import LoginPage from '../pages/LoginPage.js';
import HomePage from '../pages/HomePage.js';
const loginPage = new LoginPage();
const homePage = new HomePage();
// ---------- GIVEN ----------
Given('the user navigates to the login page', async () => {
await loginPage.navigate();
await expect(page).toHaveURL(loginPage.url);
});
Given(
'the user is logged in with email or username {string} and password {string}',
async (emailOrUsername, password) => {
await loginPage.navigate();
await loginPage.login(emailOrUsername, password);
await expect(page).toHaveURL(homePage.url);
},
);
// ---------- WHEN ----------
When(
'the user logs in with email or username {string} and password {string} via the web UI',
async (emailOrUsername, password) => {
await loginPage.login(emailOrUsername, password);
},
);
When('the user logs out via the web UI', async () => {
await homePage.logout();
});
// ---------- THEN ----------
Then('the user should be redirected to the home page', async () => {
await expect(page).toHaveURL(homePage.url);
});
Then('the user should be redirected to the login page', async () => {
await expect(page).toHaveURL(loginPage.url);
});
Then('the user should see the message {string}', async (expectedMessage) => {
const message = await loginPage.getMessage();
assert.strictEqual(
message,
expectedMessage,
`Expected message to be "${expectedMessage}", but received "${message}"`,
);
});