0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-18 10:41:29 -05:00

Remove redundant locators for Dashboard POM

This commit is contained in:
Belén Albeza 2024-06-25 15:16:13 +02:00
parent 8f3452c0af
commit c14f783d94
3 changed files with 18 additions and 27 deletions

View file

@ -58,30 +58,25 @@ export class DashboardPage extends BaseWebSocketPage {
this.sidebar = page.getByTestId("dashboard-sidebar");
this.sidebarMenu = this.sidebar.getByRole("menu");
this.mainHeading = page.getByRole("heading", { level: 1 });
this.projectsHeading = page.getByRole("heading", { name: "Projects" });
this.addProjectButton = page.getByRole("button", { name: "+ NEW PROJECT" });
this.projectName = page.getByText("Project 1");
this.draftsTitle = page.getByRole("heading", { name: "Drafts" });
this.draftsLink = this.sidebar.getByText("Drafts");
this.draftsFile = page.getByText(/New File 1/);
this.fontsLink = this.sidebar.getByText("Fonts");
this.fontsTitle = page.getByRole("heading", { name: "Fonts", level: 1 });
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 = 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() {
@ -153,7 +148,7 @@ export class DashboardPage extends BaseWebSocketPage {
async goToDashboard() {
await this.page.goto(`#/dashboard/team/${DashboardPage.anyTeamId}/projects`);
await expect(this.projectsHeading).toBeVisible();
await expect(this.mainHeading).toBeVisible();
}
async goToSecondTeamDashboard() {

View file

@ -12,7 +12,7 @@ test("Dashboad page has title ", async ({ page }) => {
await dashboardPage.goToDashboard();
await expect(dashboardPage.page).toHaveURL(/dashboard/);
await expect(dashboardPage.projectsHeading).toBeVisible();
await expect(dashboardPage.mainHeading).toBeVisible();
});
test("User can create a new project", async ({ page }) => {
@ -32,7 +32,7 @@ test("User goes to draft page", async ({ page }) => {
await dashboardPage.goToDashboard();
await dashboardPage.draftsLink.click();
await expect(dashboardPage.draftsTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Drafts");
});
test("User loads the draft page", async ({ page }) => {

View file

@ -11,7 +11,7 @@ test("User goes to an empty dashboard", async ({ page }) => {
await dashboardPage.goToDashboard();
await expect(dashboardPage.projectsHeading).toBeVisible();
await expect(dashboardPage.mainHeading).toBeVisible();
await expect(dashboardPage.page).toHaveScreenshot();
});
@ -24,7 +24,7 @@ test("User goes to an empty draft page", async ({ page }) => {
await dashboardPage.goToDashboard();
await dashboardPage.draftsLink.click();
await expect(dashboardPage.draftsTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Drafts");
await expect(dashboardPage.page).toHaveScreenshot();
});
@ -34,7 +34,7 @@ test("User goes to an empty fonts page", async ({ page }) => {
await dashboardPage.goToDashboard();
await dashboardPage.fontsLink.click();
await expect(dashboardPage.fontsTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Fonts");
await expect(dashboardPage.page).toHaveScreenshot();
});
@ -45,7 +45,7 @@ test("User goes to an empty libraries page", async ({ page }) => {
await dashboardPage.goToDashboard();
await dashboardPage.libsLink.click();
await expect(dashboardPage.libsTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Libraries");
await expect(dashboardPage.page).toHaveScreenshot();
});
@ -55,7 +55,7 @@ test("User goes to an empty search page", async ({ page }) => {
await dashboardPage.goToSearch();
await expect(dashboardPage.searchTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Search results");
await expect(dashboardPage.page).toHaveScreenshot();
});
@ -81,40 +81,40 @@ test("User goes to a full dashboard", async ({ page }) => {
await expect(dashboardPage.page).toHaveScreenshot();
});
test("User goes to an full draft page", async ({ page }) => {
test("User goes to a full draft page", async ({ page }) => {
const dashboardPage = new DashboardPage(page);
await dashboardPage.setupDashboardFull();
await dashboardPage.goToDashboard();
await dashboardPage.draftsLink.click();
await expect(dashboardPage.draftsTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Drafts");
await expect(dashboardPage.page).toHaveScreenshot();
});
test("User goes to an full library page", async ({ page }) => {
test("User goes to a full library page", async ({ page }) => {
const dashboardPage = new DashboardPage(page);
await dashboardPage.setupDashboardFull();
await dashboardPage.goToDashboard();
await dashboardPage.libsLink.click();
await expect(dashboardPage.libsTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Libraries");
await expect(dashboardPage.page).toHaveScreenshot();
});
test("User goes to an full fonts page", async ({ page }) => {
test("User goes to a full fonts page", async ({ page }) => {
const dashboardPage = new DashboardPage(page);
await dashboardPage.setupDashboardFull();
await dashboardPage.goToDashboard();
await dashboardPage.fontsLink.click();
await expect(dashboardPage.fontsTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Fonts");
await expect(dashboardPage.page).toHaveScreenshot();
});
test("User goes to an full search page", async ({ page }) => {
test("User goes to a full search page", async ({ page }) => {
const dashboardPage = new DashboardPage(page);
await dashboardPage.setupDashboardFull();
@ -123,7 +123,7 @@ test("User goes to an full search page", async ({ page }) => {
await dashboardPage.searchInput.fill("New");
await expect(dashboardPage.searchTitle).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Search results");
await expect(dashboardPage.newFileName).toBeVisible();
await expect(dashboardPage.page).toHaveScreenshot();
});
@ -146,7 +146,7 @@ test("User goes to user profile", async ({ page }) => {
await dashboardPage.goToDashboard();
await dashboardPage.goToAccount();
await expect(dashboardPage.userAccountHeading).toBeVisible();
await expect(dashboardPage.mainHeading).toHaveText("Your account");
await expect(dashboardPage.page).toHaveScreenshot();
});
@ -180,8 +180,6 @@ test("User opens teams selector with only one team", async ({ page }) => {
const dashboardPage = new DashboardPage(page);
await dashboardPage.goToDashboard();
await expect(dashboardPage.projectsHeading).toBeVisible();
await dashboardPage.teamDropdown.click();
await expect(page.getByText("Create new team")).toBeVisible();
@ -193,8 +191,6 @@ test("User opens teams selector with more than one team", async ({ page }) => {
await dashboardPage.setupDashboardFull();
await dashboardPage.goToDashboard();
await expect(dashboardPage.projectsHeading).toBeVisible();
await dashboardPage.teamDropdown.click();
await expect(page.getByText("Second Team")).toBeVisible();