1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-08-05 13:35:27 +02:00

refactor the code

Signed-off-by: nabim777 <nabinalemagar019@gmail.com>
This commit is contained in:
nabim777 2024-10-08 10:29:36 +05:45
parent 9670bd01f8
commit 8b1a599bee
No known key found for this signature in database
GPG key ID: 6EBA146273BEC371
2 changed files with 5 additions and 14 deletions

View file

@ -1,12 +1,9 @@
const util = require('util');
class dashboardPage {
constructor() {
this.createProjectIconSelector = `.Projects_addTitle__tXhB4`;
this.projectTitleInputSelector = `input[name="name"]`;
this.createProjectButtonSelector = `//button[text()="Create project"]`;
this.projectTitleSelector = `//div[@class="item Header_item__OOEY7 Header_title__l+wMf"][text()="%s"]`;
this.dashBoardHeaderSelector = `//div[@class="Projects_openTitle__PlaU6"][text()="%s"]`;
}
async createProject(project) {
@ -14,16 +11,6 @@ class dashboardPage {
await page.fill(this.projectTitleInputSelector, project);
await page.click(this.createProjectButtonSelector);
}
async getProjectTilte() {
return page.innerText(this.projectTitleSelector);
}
async checkForProjectOpenedOrNot() {
expect(
await page.locator(util.format(this.dashboardPage.projectTitleInputSelector, project)),
).toBeVisible();
}
}
module.exports = dashboardPage;

View file

@ -1,4 +1,6 @@
const { When, Then } = require('@cucumber/cucumber');
const util = require('util');
const { expect } = require('playwright/test');
const DashboardPage = require('../pageObjects/DashboardPage');
@ -9,5 +11,7 @@ When('the user creates a project with name {string} using the webUI', async func
});
Then('the created project {string} should be opened', async function (project) {
dashboardPage.checkForProjectOpenedOrNot(project);
expect(
await page.locator(util.format(dashboardPage.projectTitleSelector, project)),
).toBeVisible();
});