Skip to content

Commit

Permalink
star and unstar
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbykumar706584 committed Sep 26, 2023
1 parent e57db55 commit 623d522
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
29 changes: 28 additions & 1 deletion e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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
Expand Down
42 changes: 42 additions & 0 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

0 comments on commit 623d522

Please sign in to comment.