Avoid using unneeded test ids in dashboard POM

This commit is contained in:
Belén Albeza 2024-06-25 14:43:40 +02:00
parent 97a1b59861
commit 8f3452c0af
4 changed files with 35 additions and 31 deletions

View file

@ -1,3 +1,4 @@
import { expect } from "@playwright/test";
import { BaseWebSocketPage } from "./BaseWebSocketPage";
export class DashboardPage extends BaseWebSocketPage {
@ -49,31 +50,38 @@ export class DashboardPage extends BaseWebSocketPage {
}
static anyTeamId = "c7ce0794-0992-8105-8004-38e630f40f6d";
static secondTeamId = "dd33ff88-f4e5-8033-8003-8096cc07bdf3";
static draftProjectId = "c7ce0794-0992-8105-8004-38e630f7920b";
constructor(page) {
super(page);
this.titleLabel = page.getByRole("heading", { name: "Projects" });
this.addProjectBtn = page.getByRole("button", { name: "+ NEW PROJECT" });
this.sidebar = page.getByTestId("dashboard-sidebar");
this.sidebarMenu = this.sidebar.getByRole("menu");
this.projectsHeading = page.getByRole("heading", { name: "Projects" });
this.addProjectButton = page.getByRole("button", { name: "+ NEW PROJECT" });
this.projectName = page.getByText("Project 1");
this.draftTitle = page.getByRole("heading", { name: "Drafts" });
this.draftLink = page.getByTestId("drafts-link-sidebar");
this.draftsTitle = page.getByRole("heading", { name: "Drafts" });
this.draftsLink = this.sidebar.getByText("Drafts");
this.draftsFile = page.getByText(/New File 1/);
this.fontsLink = page.getByTestId("fonts-link-sidebar");
this.fontsLink = this.sidebar.getByText("Fonts");
this.fontsTitle = page.getByRole("heading", { name: "Fonts", level: 1 });
this.libsLink = page.getByTestId("libs-link-sidebar");
this.libsLink = this.sidebar.getByText("Libraries");
this.libsTitle = page.getByRole("heading", { name: "Libraries", level: 1 });
this.searchButton = page.getByRole("button", { name: "dashboard-search" });
this.searchTitle = page.getByRole("heading", { name: "Search results" });
this.searchInput = page.getByPlaceholder("Search…");
this.newFileName = page.getByText("New File 3");
this.teamDropdown = page.getByRole("button", { name: "Your Penpot" });
this.userAccount = page.getByRole("button", { name: "Princesa Leia Princesa Leia" });
this.userProfileOption = page.getByText("Your account");
this.userAccountTitle = page.getByRole("heading", { name: "Your account" });
this.teamDropdown = this.sidebar.getByRole("button", { name: "Your Penpot" });
this.userAccount = this.sidebar.getByRole("button", { name: /Princesa Leia/ });
this.userProfileOption = this.sidebarMenu.getByText("Your account");
this.userAccountHeading = page.getByRole("heading", { name: "Your account" });
}
async setupDraftsEmpty() {
@ -145,6 +153,7 @@ export class DashboardPage extends BaseWebSocketPage {
async goToDashboard() {
await this.page.goto(`#/dashboard/team/${DashboardPage.anyTeamId}/projects`);
await expect(this.projectsHeading).toBeVisible();
}
async goToSecondTeamDashboard() {