mirror of
https://github.com/plankanban/planka.git
synced 2025-08-02 20:15:27 +02:00
test: Add BDD UI tests using Playwright (#911)
This commit is contained in:
parent
4efc3be8d5
commit
096feb35bb
17 changed files with 1260 additions and 120 deletions
17
client/tests/acceptance/stepDefinitions/dashBoardContext.js
Normal file
17
client/tests/acceptance/stepDefinitions/dashBoardContext.js
Normal file
|
@ -0,0 +1,17 @@
|
|||
const { When, Then } = require('@cucumber/cucumber');
|
||||
const util = require('util');
|
||||
const { expect } = require('playwright/test');
|
||||
|
||||
const DashboardPage = require('../pageObjects/DashboardPage');
|
||||
|
||||
const dashboardPage = new DashboardPage();
|
||||
|
||||
When('the user creates a project with name {string} using the webUI', async function (project) {
|
||||
await dashboardPage.createProject(project);
|
||||
});
|
||||
|
||||
Then('the created project {string} should be opened', async function (project) {
|
||||
expect(
|
||||
await page.locator(util.format(dashboardPage.projectTitleSelector, project)),
|
||||
).toBeVisible();
|
||||
});
|
|
@ -1,26 +1,53 @@
|
|||
const { Given, When, Then } = require("@cucumber/cucumber");
|
||||
const { client } = require("nightwatch-api");
|
||||
const assert = require("assert");
|
||||
const { Given, When, Then } = require('@cucumber/cucumber');
|
||||
|
||||
const loginPage = client.page.loginPage();
|
||||
const dashboardPage = client.page.dashboardPage();
|
||||
// import expect for assertion
|
||||
const { expect } = require('@playwright/test');
|
||||
|
||||
Given("user has browsed to the login page", function () {
|
||||
return loginPage.navigate();
|
||||
// import assert
|
||||
const assert = require('assert');
|
||||
|
||||
const LoginPage = require('../pageObjects/LoginPage');
|
||||
|
||||
const loginPage = new LoginPage();
|
||||
|
||||
Given('user has browsed to the login page', async function () {
|
||||
await loginPage.goToLoginUrl();
|
||||
await expect(page).toHaveURL(loginPage.loginUrl);
|
||||
});
|
||||
|
||||
When(
|
||||
"user logs in with username/email {string} and password {string} using the webUI",
|
||||
function (username, password) {
|
||||
return loginPage.logIn(username, password);
|
||||
}
|
||||
Given(
|
||||
'user has logged in with email {string} and password {string}',
|
||||
async function (username, password) {
|
||||
await loginPage.goToLoginUrl();
|
||||
await loginPage.login(username, password);
|
||||
await expect(page).toHaveURL(loginPage.homeUrl);
|
||||
},
|
||||
);
|
||||
|
||||
Then("the user should be in the dashboard page", async function () {
|
||||
const isDashboard = await dashboardPage.isDashboardPage();
|
||||
assert.strictEqual(
|
||||
isDashboard,
|
||||
true,
|
||||
"Expected to see dashboard page but not visible"
|
||||
When(
|
||||
'user logs in with username {string} and password {string} using the webUI',
|
||||
async function (username, password) {
|
||||
await loginPage.login(username, password);
|
||||
},
|
||||
);
|
||||
|
||||
Then('the user should be in dashboard page', async function () {
|
||||
await expect(page).toHaveURL(loginPage.homeUrl);
|
||||
});
|
||||
|
||||
Then('user should see the error message {string}', async function (errorMessage) {
|
||||
const actualErrorMessage = await loginPage.getErrorMessage();
|
||||
assert.equal(
|
||||
actualErrorMessage,
|
||||
errorMessage,
|
||||
`Expected message to be "${errorMessage}" but receive "${actualErrorMessage}"`,
|
||||
);
|
||||
});
|
||||
|
||||
When('user logs out using the webUI', async function () {
|
||||
await loginPage.logOut();
|
||||
});
|
||||
|
||||
Then('the user should be in the login page', async function () {
|
||||
await expect(page).toHaveURL(loginPage.loginUrl);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue