diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index a89c9831e..70c12bc96 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -2,7 +2,7 @@ import { test, expect } from './myFixtures'; import packageInfo from '../package.json'; -import { showLoginPage, checkLogInOrNot, userFile, userFolder, userJson, createUserValidation, createProjectValidation, createProjects } from './common'; +import { showLoginPage, checkLogInOrNot, userFile, userFolder, userJson, createUserValidation, createProjectValidation, createProjects, unstarProject, starProject } from './common'; const fs = require('fs'); const path = require('path'); @@ -102,6 +102,33 @@ test('Click Click New and Fill project page details to create a new project for await createProjects(window, expect, audioProject, "Audio", "test description", "atp") }) +/* STAR & UNSTAR PROJECT */ +///text translation +test("Star the text project", async ({ textProject }) => { + await starProject(window, expect, textProject) +}) + +test("Unstar the text project", async ({ textProject }) => { + await unstarProject(window, expect, textProject) +}) + +///obs +test("Star the obs project", async ({ obsProject }) => { + await starProject(window, expect, obsProject) +}) + +test("Unstar the obs project", async ({ obsProject }) => { + await unstarProject(window, expect, obsProject) +}) + +// ///audio +test("Star the audio project", async ({ audioProject }) => { + await starProject(window, expect, audioProject) +}) + +test("Unstar the audio project", async ({ audioProject }) => { + await unstarProject(window, expect, audioProject) +}) test("Logout and delete that playwright user from the backend", async ({ userName }) => { ///user json diff --git a/e2e-tests/common.js b/e2e-tests/common.js index a736b4e86..6be9be405 100644 --- a/e2e-tests/common.js +++ b/e2e-tests/common.js @@ -93,4 +93,46 @@ export const createProjects = async (window, expect, projectname, type, descript expect(projectName).toBe(projectname); const title = await window.textContent('[aria-label=projects]', { timeout: 10000 }); expect(title).toBe('Projects'); +} + +export const starProject = async (window, expect, projectname) => { + await expect(window.locator('//*[@id="projects-list"]')).toBeVisible() + const table = window.locator('//*[@id="projects-list"]') + const body = table.locator('//*[@id="projects-list-unstar"]') + const starBody = table.locator('//*[@id="projects-list-star"]') + const rows = await body.locator('tr') + for (let i = 0; i < await rows.count(); i++) { + const row = await rows.nth(i); + const tds = await row.locator('td'); + if (await tds.nth(1).textContent() === projectname) { + expect(await tds.first().locator('[aria-label=unstar-project]')).toBeVisible() + await tds.first().locator('[aria-label=unstar-project]').click() + expect(await rows.count()).toBe(2) + const starRows = await starBody.locator('tr') + const starProjectName = await starRows.locator("td").nth(1).innerText() + expect(await starProjectName).toBe(projectname) + expect(await starRows.count()).toBe(1) + } + } +} + +export const unstarProject = async (window, expect, projectname) => { + await expect(window.locator('//*[@id="projects-list"]')).toBeVisible() + const table = window.locator('//*[@id="projects-list"]') + const body = table.locator('//*[@id="projects-list-star"]') + const rows = await body.locator('tr') + for (let i = 0; i < await rows.count(); i++) { + const row = await rows.nth(i); + const tds = await row.locator('td'); + if (await tds.nth(1).textContent() === projectname) { + expect(await tds.first().locator('[aria-label=star-project]')).toBeVisible() + await tds.first().locator('[aria-label=star-project]').click() + const unstarBody = table.locator('//*[@id="projects-list-unstar"]') + const unstarRows = await unstarBody.locator('tr') + expect(await rows.count()).toBe(0) + expect(await unstarRows.count()).toBe(3) + } + } + const title = await window.textContent('[aria-label=projects]', { timeout: 10000 }); + expect(title).toBe('Projects'); } \ No newline at end of file