diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 6b0b1425b..8afbb2507 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, createProjectValidation, createProjects, unstarProject, starProject, userValidation, signOut, showActiveUsers } from './common'; +import { showLoginPage, checkLogInOrNot, userFile, userFolder, userJson, createProjectValidation, createProjects, unstarProject, starProject, userValidation, signOut, showActiveUsers, searchProject, checkProjectName, checkNotification, goToProjectPage } from './common'; const fs = require('fs'); const path = require('path'); @@ -57,13 +57,13 @@ test('If logged IN then logout and delete that user from the backend', async ({ }); - +// create new user test('Create a new user and login', async ({ userName }) => { await userValidation(window, expect) await window.locator('//input[@placeholder="Username"]').fill(userName) await expect(window.locator('//button[@type="submit"]')).toBeVisible() await window.click('[type=submit]'); - const title = await window.textContent('[aria-label=projects]'); + const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent(); expect(title).toBe('Projects'); }) @@ -88,11 +88,9 @@ test('Click New and Fill project page details to create a new project for text t await window.locator('//*[@id="save-canon"]').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') + await expect(notifyMe).toBe('New project created') const projectName = await window.innerText(`//div[@id="${textProject}"]`) - expect(projectName).toBe(textProject); - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('Projects'); + await expect(projectName).toBe(textProject); }) /* Obs translation project */ @@ -101,17 +99,17 @@ test('Click New and Fill project page details to create a new project for obs', }) /* Audio project */ -test('Click Click New and Fill project page details to create a new project for audio', async ({ audioProject }) => { +test('Click New and Fill project page details to create a new project for audio', async ({ audioProject }) => { await createProjects(window, expect, audioProject, "Audio", "test description", "atp") }) /* STAR & UNSTAR PROJECT */ // text translation -test("Star the text project", async ({ textProject }) => { +test("Star the text translation project", async ({ textProject }) => { await starProject(window, expect, textProject) }) -test("Unstar the text project", async ({ textProject }) => { +test("Unstar the text translation project", async ({ textProject }) => { await unstarProject(window, expect, textProject) }) @@ -133,10 +131,116 @@ test("Unstar the audio project", async ({ audioProject }) => { await unstarProject(window, expect, audioProject) }) +/* text transaltion project */ +test('Search a text translation project in all projects list', async ({ textProject }) => { + await searchProject(window, expect, textProject, 'translation') +}); + +test('Click on a text translation project and Check the text Translation project name in the editor', async ({ textProject }) => { + await checkProjectName(window, expect, textProject) +}); + +test('Check text Translation project Notifications', async () => { + await checkNotification(window, expect) +}); + +test('Return to the project page', async () => { + await goToProjectPage(window, expect) +}); + +/* obs project */ +test('Search an obs project in all projects list', async ({ obsProject }) => { + await searchProject(window, expect, obsProject, 'obs') +}); + +test('Click on a obs project and Check the obs project name in the editor', async ({ obsProject }) => { + await checkProjectName(window, expect, obsProject) +}); + +test('Check obs project Notifications', async () => { + await checkNotification(window, expect) +}); + +test('Add content in verses 1 and 2 in the obs story 1 editor', async () => { + await window.locator('div:nth-child(2) > .flex-grow').fill("god created heavens and earth"); + await window.locator('div:nth-child(3) > .flex-grow').fill("story content added in verse 3"); + const verse2 = await window.textContent('div:nth-child(2) > .flex-grow') + expect(verse2).toBe('god created heavens and earth'); + const verse3 = await window.textContent('div:nth-child(3) > .flex-grow') + expect(verse3).toBe('story content added in verse 3'); +}); + +test('Increase the font size in the obs editor', async () => { + await window.locator('//*[@aria-label="increase-font"]').click(); + await window.locator('//*[@aria-label="increase-font"]').click(); + const div = await window.locator('//*[@aria-label="editor"]') + const fontSize = await div.evaluate((ele) => { + return window.getComputedStyle(ele).getPropertyValue('font-size') + + }) + expect(await fontSize).toBe('22.4px'); +}); + +test('Decrease the font size in the obs editor', async () => { + await window.locator('//*[@aria-label="decrease-font"]').click(); + await window.locator('//*[@aria-label="decrease-font"]').click(); + const div = await window.locator('//*[@aria-label="editor"]') + const fontSize = await div.evaluate((ele) => { + return window.getComputedStyle(ele).getPropertyValue('font-size') + }) + expect(await fontSize).toBe('16px'); +}); + +test('Change the obs navigation story from 1 to 12 and edit the title', async () => { + await expect(window.locator('//*[@aria-label="obs-navigation"]')).toBeVisible() + await window.locator('//*[@aria-label="obs-navigation"]').click() + await window.locator('//*[@aria-label="12"]').click(); + await expect(window.locator('//*[@name="12. The Exodus"]')).toBeVisible() + await window.locator('//*[@name="12. The Exodus"]').fill('12. The Exodus Edit title') + const title = await window.textContent('//*[@name="12. The Exodus Edit title"]') + expect(title).toBe('12. The Exodus Edit title'); +}); + +test('Return to projects list page from obs editor', async () => { + await goToProjectPage(window, expect) +}); + + +/* audio project */ +test('Search an audio project in all projects list', async ({ audioProject }) => { + await searchProject(window, expect, audioProject, 'audio') +}); + +test('Click on a audio project and Check the audio project name in the editor', async ({ audioProject }) => { + await checkProjectName(window, expect, audioProject) +}); + +test('Check audio project Notifications', async () => { + await checkNotification(window, expect) +}); + +test('Return to the projects from audio editor page', async () => { + await goToProjectPage(window, expect) +}); + +/* about the scribe */ +test("About scribe Application and License", async () => { + await window.locator('//*[@aria-label="about-button"]').click() + const developedby = await window.innerText('[aria-label=developed-by]'); + expect(developedby).toBe('Developed by Bridge Connectivity Solutions'); + await window.click('[aria-label=license-button]'); + await window.locator('//*[@aria-label="about-description"]').click() + await window.click('[aria-label=close-about]'); + const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent(); + expect(title).toBe('Projects'); +}) + +/*signing out */ test("Sign out the Application", async () => { await signOut(window, expect) }) +/* view users */ test("Click the view users button, log in with playwright user, and sign out", async ({ userName }) => { await showActiveUsers(window, expect) const tabContent = await window.locator('//*[@id="active-tab-content"]') @@ -144,36 +248,44 @@ test("Click the view users button, log in with playwright user, and sign out", a for (let i = 0; i < await div.count(); i++) { if (await div.nth(i).textContent() === userName.toLowerCase()) { await div.nth(i).click() - await window.waitForTimeout(2000) - const title = await window.textContent('[aria-label=projects]') - await expect(title).toBe('Projects') + await window.waitForTimeout(1000) + const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent(); + expect(title).toBe('Projects') await signOut(window, expect) + break } } }) +/* user delete, check in archive and restore */ test("Delete the user from the active tab and check in the archived tab", async ({ userName }) => { await showActiveUsers(window, expect) - const tabContent = await window.locator('//*[@id="active-tab-content"]') + const tabContent = await window.locator('//*[@id="active-tab-content"]', { timeout: 5000 }) const items = await tabContent.locator('div > div') const div = await tabContent.locator("div > button") + const archiveTabContent = await window.locator('//*[@id="archive-tab-content"]') + const archiveItems = await archiveTabContent.locator('div > div') + const archiveDiv = await archiveTabContent.locator('div > button') for (let i = 0; i < await items.count(); i++) { if (await items.nth(i).textContent() === userName.toLowerCase()) { await div.nth(i).click() - expect(await window.locator('//*[@id="archived-tab"]')).toBeVisible() + await expect(window.locator('//*[@id="archived-tab"]')).toBeVisible() await window.locator('//*[@id="archived-tab"]').click() const text = await window.locator('//*[@id="archived-tab"]').textContent() - expect(await text).toBe('Archived') - await window.getByLabel('Archived').locator('button').click() - expect(await window.locator('//*[@id="active-tab"]')).toBeVisible() + await expect(text).toBe('Archived') + if (await archiveItems.nth(i).textContent() === userName.toLowerCase()) { + await archiveDiv.nth(i).click() + } await window.locator('//*[@id="active-tab"]').click() - await window.getByRole('button', { name: userName.toLowerCase() }).click() + await window.locator(`//*[@dataId="${userName.toLowerCase()}"]`).click() + break } } - const title = await window.textContent('[aria-label=projects]') - await expect(title).toBe('Projects') + const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent(); + expect(title).toBe('Projects') }) +/* logout and delete the playwright user */ test("Logout and delete that playwright user from the backend", async ({ userName }) => { // user json const json = await userJson(window, packageInfo, fs, path) diff --git a/e2e-tests/common.js b/e2e-tests/common.js index 3d8c36547..f225f96a7 100644 --- a/e2e-tests/common.js +++ b/e2e-tests/common.js @@ -1,25 +1,18 @@ export const checkLogInOrNot = async (window, expect) => { - await window.waitForSelector('//*[@id="__next"]/div', '//*[@id="__next"]/div[1]') - const textVisble = await window.locator('//h1["@aria-label=projects"]', { timeout: 3000 }).isVisible() + await window.waitForSelector('//*[@id="__next"]/div', '//*[@id="__next"]/div[1]', { timeout: 5000 }) + const textVisble = await window.locator('//h1[@aria-label="projects"]', { timeout: 5000 }).isVisible() if (textVisble) { - const title = await window.textContent('[aria-label=projects]') + const title = await window.locator('//h1[@aria-label="projects"]').textContent() await expect(title).toBe('Projects') } else { - const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + const welcome = await window.locator('//h2[@aria-label="welcome"]', {timeout:5000}).textContent() await expect(welcome).toBe("Welcome!") await window.reload() } return textVisble; } -export const filterUser = (json, name) => { - const filtered = json.filter((user) => - user.username.toLowerCase() !== name.toLowerCase() - ) - return filtered -} - export const userJson = async (window, packageInfo, fs, path) => { const newpath = await window.evaluate(() => Object.assign({}, window.localStorage)) const file = path.join(newpath.userPath, packageInfo.name, 'users', 'users.json'); @@ -45,13 +38,15 @@ export const removeFolderAndFile = async (fs, folder, userName, json, file) => { return await fs.writeFileSync(file, JSON.stringify(filtered)) } +// display welcome page export const showLoginPage = async (fs, folder, userName, json, file, window, expect) => { await removeFolderAndFile(fs, folder, userName, json, file) - const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + const welcome = await window.locator('//h2[@aria-label="welcome"]', {timeout:5000}).textContent() await expect(welcome).toBe("Welcome!") await window.reload() } +// user validation export const userValidation = async (window, expect) => { expect(await window.locator('//*[@aria-label="create-new-account"]')).toBeVisible() await window.locator('//*[@aria-label="create-new-account"]').click() @@ -64,12 +59,13 @@ export const userValidation = async (window, expect) => { expect(await lengthError.textContent()).toBe('The input has to be between 3 and 15 characters long') } +// project creation validation export const createProjectValidation = async (window, expect) => { await window.locator('//button[@aria-label="create"]').click() const snackbar = await window.textContent('//*[@id="__next"]/div/div[2]/div[2]/div/div') expect(await snackbar).toBe('Fill all the fields') - const title = await window.textContent('[aria-label=projects]'); - expect(title).toBe('New Project'); + const title = await window.locator('//h1[@aria-label="projects"]').textContent(); + await expect(title).toBe('New Project'); await window.waitForTimeout(3000) } @@ -92,11 +88,10 @@ export const createProjects = async (window, expect, projectname, type, descript await expect(window.locator('//button[@aria-label="create"]')).toBeVisible() await window.locator('//button[@aria-label="create"]').click() const projectName = await window.innerText(`//div[@id="${projectname}"]`) - expect(projectName).toBe(projectname); - const title = await window.textContent('[aria-label=projects]', { timeout: 10000 }); - expect(title).toBe('Projects'); + await expect(projectName).toBe(projectname); } +// star the project export const starProject = async (window, expect, projectname) => { await expect(window.locator('//*[@id="projects-list"]')).toBeVisible() const table = window.locator('//*[@id="projects-list"]') @@ -114,10 +109,12 @@ export const starProject = async (window, expect, projectname) => { const starProjectName = await starRows.locator("td").nth(1).innerText() expect(await starProjectName).toBe(projectname) expect(await starRows.count()).toBe(1) + break } } } +// unstar the project export const unstarProject = async (window, expect, projectname) => { await expect(window.locator('//*[@id="projects-list"]')).toBeVisible() const table = window.locator('//*[@id="projects-list"]') @@ -132,27 +129,73 @@ export const unstarProject = async (window, expect, projectname) => { 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) + expect(await unstarRows.count()).toBe(3) + break; + } + } +} + +// search projects +export const searchProject = async (window, expect, projectName, searchtext) => { + await window.waitForTimeout(500) + await expect(window.locator('//input[@id="search_box"]')).toBeVisible() + await window.locator('//input[@id="search_box"]').fill(searchtext) + const projectname = await window.innerText(`//*[@id="${projectName}"]`); + await expect(projectname).toBe(projectName); +} + +// check project name in editor +export const checkProjectName = async (window, expect, name) => { + 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 = await rows.nth(i); + const tds = await row.locator('td'); + if (await tds.nth(1).textContent() === name) { + await tds.nth(1).click({timeout:10000}) + break } } - const title = await window.textContent('[aria-label=projects]', { timeout: 10000 }); + await window.waitForTimeout(1000) + const projectname = await window.locator('[aria-label=editor-project-name]', { timeout: 10000 }).textContent() + expect(projectname).toBe(name); +} + +// check notification +export const checkNotification = async (window, expect) => { + await window.locator('//*[@aria-label="notification-button"]').click() + const title = await window.innerText('[aria-label=notification-title]'); + await expect(title).toBe('NOTIFICATIONS'); + await window.locator('//*[@aria-label="close-notification"]').click() +} + +// back button in editor page +export const goToProjectPage = async (window, expect) => { + await expect(window.locator('//*[@id="back-button"]')).toBeVisible() + await window.locator('//*[@id="back-button"]').click(); + const title = await window.locator('//h1[@aria-label="projects"]', { timeout: 10000 }).textContent(); expect(title).toBe('Projects'); + await window.waitForTimeout(1000) } +// sing out export const signOut = async (window, expect) => { - expect(await window.locator('//*[@id="user-profile"]')).toBeVisible() + await expect(window.locator('//*[@id="user-profile"]')).toBeVisible() await window.locator('//*[@id="user-profile"]').click() - expect(await window.locator('//*[@aria-label="signout"]')).toBeVisible() + await expect(window.locator('//*[@aria-label="signout"]')).toBeVisible() await window.locator('//*[@aria-label="signout"]').click() await window.waitForTimeout(1000) - const welcome = await window.textContent('//*[@id="__next"]/div/div[1]/div/h2') + const welcome = await window.locator('//h2[@aria-label="welcome"]', {timeout:5000}).textContent() await expect(welcome).toBe("Welcome!") - + await window.waitForTimeout(200) } +// show active user by clicking the view more but in login page export const showActiveUsers = async (window, expect) => { - expect(await window.locator('//*[@id="view-more"]')).toBeVisible() - await window.locator('//*[@id="view-more"]').click() + await expect(window.locator('//*[@id="view-more"]', {timeout:5000})).toBeVisible() + await window.locator('//*[@id="view-more"]', {timeout:5000}).click() const active = await window.locator('//*[@id="active-tab"]').textContent() - expect(await active).toBe("Active") + await expect(active).toBe("Active") } \ No newline at end of file diff --git a/renderer/src/components/EditorPage/ObsEditor/NavigationObs.js b/renderer/src/components/EditorPage/ObsEditor/NavigationObs.js index a64c5be77..9bf284e53 100644 --- a/renderer/src/components/EditorPage/ObsEditor/NavigationObs.js +++ b/renderer/src/components/EditorPage/ObsEditor/NavigationObs.js @@ -31,6 +31,7 @@ const SelectFile = ({ openChapter, onChapterSelect }) => ( onClick={(e) => { onChapterSelect(e, i + 1); }} className={styles.select} tabIndex={0} + aria-label={i + 1} > {i + 1} diff --git a/renderer/src/components/Login/LeftLogin.js b/renderer/src/components/Login/LeftLogin.js index 89b5215d6..497503270 100644 --- a/renderer/src/components/Login/LeftLogin.js +++ b/renderer/src/components/Login/LeftLogin.js @@ -181,7 +181,7 @@ const LeftLogin = () => { }; return (
Welcome back! Login to access Scribe Scripture
@@ -280,6 +280,7 @@ const LeftLogin = () => {