Skip to content

Commit

Permalink
edit the text project
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbykumar706584 committed Sep 20, 2023
1 parent 57ba965 commit 184dbf8
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 41 deletions.
97 changes: 56 additions & 41 deletions 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 { DisplayLogin, checkLogInOrNot, commonFile, commonFolder, commonJson, createProjects, createUserValidation, projectValidation, searchProject, starProject, unstarProject } from './common';
import { DisplayLogin, checkLogInOrNot, commonFile, commonFolder, commonJson, createProjects, createUserValidation, goToEditProject, projectValidation, searchProject, starProject, unstarProject } from './common';

const fs = require('fs');
const { _electron: electron } = require('@playwright/test');
Expand Down Expand Up @@ -67,7 +67,7 @@ test('Create a new user and login', async ({ userName }) => {

/*CREATE PROJECTS FOR ALL FLAVOR TYPE */
// // /* Translation Project */
test('Click New and Fill project page details to create a new project for text translation', async ({ textProject }) => {
test('Click New and Fill project page details to create a new project for text translation with custom book', async ({ textProject }) => {
await projectValidation(window, expect)
await expect(window.locator('//input[@id="project_name"]')).toBeVisible()
await window.locator('//input[@id="project_name"]').fill(textProject)
Expand All @@ -77,9 +77,10 @@ test('Click New and Fill project page details to create a new project for text t
await window.locator('//input[@id="version_abbreviated"]').fill('ttp')
await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible()
await window.locator('//button[@id="open-advancesettings"]').click()
await expect(window.locator('//div[@aria-label="new-testament"]')).toBeVisible()
await window.locator('//div[@aria-label="new-testament"]').click()
await window.locator('//button[contains(text(),"Ok")]').click()
await expect(window.locator('//div[@aria-label="custom-book"]')).toBeVisible()
await window.locator('//div[@aria-label="custom-book"]').click()
await window.getByLabel('nt-Matthew').click()
await window.getByRole('button', { name: 'Save' }).click()
await window.locator('//button[@aria-label="create"]').click()
const notifyMe = await window.textContent('//*[@id="__next"]/div/div[2]/div[2]/div/div')
expect(await notifyMe).toBe('New project created')
Expand All @@ -100,8 +101,8 @@ 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
/* STAR & UNSTAR PROJECT */
////text translation
test("Star the text project", async ({ textProject }) => {
await starProject(window, expect, textProject)
})
Expand All @@ -111,51 +112,65 @@ test("Unstar the text project", async ({ textProject }) => {
})

// ///obs
// test("Star the obs project", async ({ obsProject }) => {
// await starProject(window, expect, obsProject)
// })
test("Star the obs project", async ({ obsProject }) => {
await starProject(window, expect, obsProject)
})

// test("Unstar the obs project", async ({ obsProject }) => {
// await unstarProject(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)
// })
// ///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("Unstar the audio project", async ({ audioProject }) => {
await unstarProject(window, expect, audioProject)
})

test('Search a text project in all projects list', async ({ textProject }) => {
await searchProject(window, expect, textProject, 'translation')
});

test("updating text transaltion project of description and abbriviation", async ({ textProject }) => {
await goToEditProject(window, expect, textProject)
const description = await window.textContent('//textarea[@id="project_description"]')
await expect(description).toBe('test description')
await window.locator('//textarea[@id="project_description"]').fill('edit test version')
const editDescription = await window.textContent('//textarea[@id="project_description"]')
await expect(editDescription).toBe('edit test version')
await window.locator('input[name="version_abbreviated"]').fill('tvs')
await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible()
await window.locator('//button[@aria-label="save-edit-project"]').click()
await window.waitForTimeout(2)
const title = await window.textContent('[aria-label=projects]');
expect(title).toBe('Projects')
})


// test('Search an obs project in all projects list', async ({ obsProject }) => {
// await searchProject(window, expect, obsProject, 'obs')
// });
test('Search an obs project in all projects list', async ({ obsProject }) => {
await searchProject(window, expect, obsProject, 'obs')
});

// test('Search an audio project in all projects list', async ({ audioProject }) => {
// await searchProject(window, expect, audioProject, 'audio')
// });
test('Search an audio project in all projects list', async ({ audioProject }) => {
await searchProject(window, expect, audioProject, 'audio')
});



// test("Logout and delete that playwright user from the backend", async ({ userName }) => {
// ///return json
// const json = await commonJson(window, userName, packageInfo, fs)
// /// return file
// const file = await commonFile(window, packageInfo)
// /// return folde name
// const folder = await commonFolder(window, userName, packageInfo)
// await window.getByRole('button', { name: "Open user menu" }).click()
// const currentUser = await window.textContent('[aria-label="userName"]')
// await window.getByRole('menuitem', { name: "Sign out" }).click()
// /// projects page then logout and delete playwright user
// if (currentUser.toLowerCase() === userName.toLowerCase() && await fs.existsSync(folder)) {
// await DisplayLogin(fs, folder, userName, json, file, window, expect)
// }
// })
test("Logout and delete that playwright user from the backend", async ({ userName }) => {
///return json
const json = await commonJson(window, userName, packageInfo, fs)
/// return file
const file = await commonFile(window, packageInfo)
/// return folde name
const folder = await commonFolder(window, userName, packageInfo)
await window.getByRole('button', { name: "Open user menu" }).click()
const currentUser = await window.textContent('[aria-label="userName"]')
await window.getByRole('menuitem', { name: "Sign out" }).click()
/// projects page then logout and delete playwright user
if (currentUser.toLowerCase() === userName.toLowerCase() && await fs.existsSync(folder)) {
await DisplayLogin(fs, folder, userName, json, file, window, expect)
}
})
18 changes: 18 additions & 0 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,22 @@ export const searchProject = async (window, expect, projectName, searchtext) =>
await window.locator('//input[@id="search_box"]').fill(searchtext)
const projectname = await window.innerText(`//*[@id="${projectName}"]`);
expect(projectname).toBe(projectName);
}

export const goToEditProject = 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 rows = await body.locator('tr')
for (let i = 0; i < await rows.count(); i++) {
const row = rows.nth(i);
const tds = row.locator('td');
if (await tds.nth(1).textContent() === projectName) {
await tds.last().locator('[aria-label=unstar-expand-project]').click()
await window.locator('[aria-label=unstar-menu-project]').click()
await window.getByRole('menuitem', { name: "edit-project" }).click()
const text = await window.innerText('//*[@id="__next"]/div/div[2]/header/div/div[1]/div/h1')
await expect(text).toBe('EDIT PROJECT')
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,13 +232,15 @@ export default function AdvancedSettingsDropdown({ call, project, projectType })
onClick={() => selectCanon(canonList[0])}
role="button"
tabIndex="0"
aria-label="all-books"
>
{t('label-all')}
</div>
<div
className={canonSpecification.title === 'Old Testament (OT)' ? 'bg-primary hover:bg-secondary text-white px-3 py-1 rounded-full cursor-pointer whitespace-nowrap' : 'bg-gray-200 hover:bg-primary hover:text-white px-3 py-1 rounded-full cursor-pointer whitespace-nowrap'}
onClick={() => selectCanon(canonList[1])}
role="button"
aria-label="old-testament"
tabIndex="0"
>
{`${t('label-old-testament')} (OT)`}
Expand All @@ -256,6 +258,7 @@ export default function AdvancedSettingsDropdown({ call, project, projectType })
className={canonSpecification.title === 'Other' ? 'bg-primary hover:bg-secondary text-white px-3 py-1 rounded-full cursor-pointer whitespace-nowrap' : 'bg-gray-200 hover:bg-primary hover:text-white px-3 py-1 rounded-full cursor-pointer whitespace-nowrap'}
onClick={() => selectCanon(canonList[3])}
role="button"
aria-label="custom-book"
tabIndex="0"
>
{t('label-custom')}
Expand Down

0 comments on commit 184dbf8

Please sign in to comment.