From 8b1a599bee3ec0a6f1e95b230015611d043806ae Mon Sep 17 00:00:00 2001 From: nabim777 Date: Tue, 8 Oct 2024 10:29:36 +0545 Subject: [PATCH] refactor the code Signed-off-by: nabim777 --- .../tests/acceptance/pageObjects/DashboardPage.js | 13 ------------- .../acceptance/stepDefinitions/dashBoardContext.js | 6 +++++- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/client/tests/acceptance/pageObjects/DashboardPage.js b/client/tests/acceptance/pageObjects/DashboardPage.js index 139741ac..53332dc2 100644 --- a/client/tests/acceptance/pageObjects/DashboardPage.js +++ b/client/tests/acceptance/pageObjects/DashboardPage.js @@ -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; diff --git a/client/tests/acceptance/stepDefinitions/dashBoardContext.js b/client/tests/acceptance/stepDefinitions/dashBoardContext.js index 61041a73..64bb7fbb 100644 --- a/client/tests/acceptance/stepDefinitions/dashBoardContext.js +++ b/client/tests/acceptance/stepDefinitions/dashBoardContext.js @@ -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(); });