diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index d291c8266..863887c3f 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -10,7 +10,8 @@ import { changeAppLanguage, projectTargetLanguage, userProfileValidaiton, exportAudioProject, updateDescriptionAbbriviation, changeLicense, customAddEditLanguage, customProjectTargetLanguage, starUnstar, - clickUserImageToLogout, confirmBookInEditor, checkingUpdatedLicense, createUser + clickUserImageToLogout, confirmBookInEditor, checkingUpdatedLicense, + createUser, projectPageExpect } from './common'; const fs = require('fs'); @@ -86,8 +87,7 @@ test('check user length should be between 3 and 15 characters long', async () => test('Create a new user and login', async ({ userName }) => { await createUser(window, expect, userName) // landing to the project page - const title = await window.locator('//*[@aria-label="projects"]').textContent(); - await expect(title).toBe('Projects'); + await projectPageExpect(window, expect) }) /* view users */ @@ -99,9 +99,7 @@ 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(1000) - const title = await window.locator('//*[@aria-label="projects"]').textContent(); - await expect(title).toBe('Projects') + await projectPageExpect(window, expect) break } } @@ -118,8 +116,7 @@ test("check the user is already created", async ({ userName }) => { await window.locator('//*[@aria-label="cancel"]').click() await window.locator(`//*[@id="${userName.toLowerCase()}"]`).click() // landing to the project page - const title = await window.locator('//*[@aria-label="projects"]').textContent(); - await expect(title).toBe('Projects'); + await projectPageExpect(window, expect) }) /* user delete, check in archive and restore */ @@ -147,8 +144,28 @@ test("Click the view users button and delete the playwright user from the active break } } - const title = await window.locator('//*[@aria-label="projects"]').textContent(); - await expect(title).toBe('Projects') + await projectPageExpect(window, expect) +}) + +/*changing app language english to hindi */ +test("App language change English to hindi", async ({ english, hindi }) => { + // Change the app language from English to hindi + await changeAppLanguage(window, expect, english, hindi); + + // Verify the language change and UI update + await window.waitForSelector('//*[@aria-label="snack-text"]') + const snackbar = await window.locator('//*[@aria-label="snack-text"]').isVisible(); + expect(await snackbar).toBe(true); + + await window.locator('//*[@aria-label="projectList"]').click(); + await projectPageExpect(window, expect) +}) + +test("Logout and check application language is changed", async ({ userName }) => { + await signOut(window, expect) + await window.locator(`//*[@id="${userName.toLowerCase()}"]`).click() + // landing to the project page + await projectPageExpect(window, expect) }) /* NEW PAGE*/ @@ -339,8 +356,7 @@ test("About scribe Application and License", async () => { 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('//*[@aria-label="projects"]').textContent(); - await expect(title).toBe('Projects'); + await projectPageExpect(window, expect) }) /* exports project */ @@ -420,11 +436,8 @@ test("Update/Edit text translation project scope added new book mark and luke fr await window.locator('//*[@id="save-canon"]').click(); await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible(); await window.locator('//*[@aria-label="save-edit-project"]').click(); - await window.waitForTimeout(2000); - // Verify that the title is "Projects" - const title = await window.textContent('//*[@aria-label="projects"]'); - expect(await title).toBe('Projects'); + await projectPageExpect(window, expect) await checkProjectName(window, expect, textProject) // checking mark and luke title in editor await confirmBookInEditor(window, expect, "nt-Mark", 1, 1, "MRK") @@ -447,14 +460,11 @@ test("Update/Edit text translation project scope custom book into 27 NT and chec await window.locator('//*[@aria-label="new-testament"]').click(); // Confirm the change and save - await window.locator('//button[contains(text(),"Ok")]').click(); + await window.locator('//*[@aria-label="close-bible-nav"]').click(); await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible(); await window.locator('//*[@aria-label="save-edit-project"]').click(); - await window.waitForTimeout(3000); - // Verify that the title is "Projects" - const title = await window.textContent('//*[@aria-label="projects"]'); - expect(await title).toBe('Projects'); + await projectPageExpect(window, expect) await checkProjectName(window, expect, textProject) // checking mark and luke title in editor await confirmBookInEditor(window, expect, "nt-John", 1, 1, "JHN") @@ -483,11 +493,8 @@ test("Update/Edit text transaltion project scope custom book genesis and exodus await window.locator('//*[@id="save-canon"]').click(); await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible(); await window.locator('//*[@aria-label="save-edit-project"]').click(); - await window.waitForTimeout(3000); - // Verify that the title is "Projects" - const title = await window.textContent('//*[@aria-label="projects"]'); - expect(await title).toBe('Projects'); + await projectPageExpect(window, expect) await checkProjectName(window, expect, textProject) await confirmBookInEditor(window, expect, "ot-Genesis", 1, 1, "GEN") await confirmBookInEditor(window, expect, "ot-Exodus", 1, 1, "EXO") @@ -537,6 +544,22 @@ test("Update/Edit audio project of description and abbreviation", async ({ audio await updateDescriptionAbbriviation(window, expect, description, AudioAbbreviation, audioProject) }) +/*changing app language hindi to english */ +test("App language change Hindi to English", async ({ hindi, english }) => { + // Verify the current page title + await projectPageExpect(window, expect) + // Change the app language from Hindi to English + await changeAppLanguage(window, expect, hindi, english); + + // Verify the language change and UI update + await window.waitForSelector('//*[@aria-label="snack-text"]') + const snackbar = await window.locator('//*[@aria-label="snack-text"]').isVisible(); + expect(await snackbar).toBe(true); + + await window.locator('//*[@aria-label="projectList"]').click(); + await projectPageExpect(window, expect) +}) + /* custom project with custom language for text translation */ test("Create new text translation project with new custom language and direction, custom book and without importing any book from the system", async ({ customTextProject, description, textAbbreviation, customTextLanguage }) => { // Navigate to the new project creation page @@ -632,40 +655,7 @@ test("Update user Profile details", async () => { await window.locator('//*[@id="save-profile"]').click(); // Verify the success message - const snackbar = await window.locator('//*[@aria-label="snack-text"]').textContent(); - expect(snackbar).toBe("Updated the Profile."); -}) - -/*changing app language english to hindi */ -test("App language change English to hindi", async ({ english, hindi }) => { - // Change the app language from English to Hindi - await changeAppLanguage(window, expect, english, hindi); - - // Verify the language change and UI update - const snackbar = await window.locator('//*[@aria-label="snack-text"]').textContent(); - expect(snackbar).toBe("Updated the Profile."); - - const textHindi = await window.locator('//*[@aria-label="projects"]').allTextContents(); - expect(await textHindi[0]).toBe("प्रोफ़ाइल"); -}) - -/*changing app language hindi to english */ -test("App language change Hindi to English", async ({ hindi, english }) => { - expect(await window.locator('//*[@aria-label="projectList"]')).toBeVisible(); - await window.locator('//*[@aria-label="projectList"]').click(); - await window.waitForTimeout(2000); - - // Verify the current page title - const title = await window.textContent('//*[@aria-label="projects"]', { timeout: 10000 }); - expect(await title).toBe('प्रोजेक्ट्स'); - - // Change the app language from Hindi to English - await changeAppLanguage(window, expect, hindi, english); - - // Verify the language change and UI update - const snackbar = await window.locator('//*[@aria-label="snack-text"]').textContent(); - expect(snackbar).toBe("Updated the Profile."); - const profile = await window.locator('//*[@aria-label="projects"]').allTextContents(); - expect(await profile[0]).toBe("Profile"); - await window.locator('//*[@aria-label="projectList"]').click(); + await window.waitForSelector('//*[@aria-label="snack-text"]') + const snackbar = await window.locator('//*[@aria-label="snack-text"]').isVisible(); + expect(await snackbar).toBe(true); }) \ No newline at end of file diff --git a/e2e-tests/common.js b/e2e-tests/common.js index 6e3de1bb9..7ff7e8db4 100644 --- a/e2e-tests/common.js +++ b/e2e-tests/common.js @@ -70,6 +70,12 @@ export const createUser = async (window, expect, username) => { await window.click('[type=submit]'); } +export const projectPageExpect = async (window, expect) => { + await window.waitForSelector('//*[@aria-label="projects"]') + const title = await window.locator('//*[@aria-label="projects"]').isVisible(); + await expect(title).toBe(true); +} + // Signs the user out. export const signOut = async (window, expect) => { // Open the user profile menu and signout @@ -96,9 +102,9 @@ export const showActiveUsers = async (window, expect) => { export const createProjectValidation = async (window, expect) => { await window.locator('//button[@aria-label="create"]').click() // Get the text content of the snackbar. - const snackbar = await window.locator('//*[@aria-label="snack-text"]').textContent() + const snackbar = await window.locator('//*[@aria-label="snack-text"]').isVisible() // Verify if the snackbar message is 'Fill all the fields.' - await expect(snackbar).toBe('Fill all the fields') + await expect(snackbar).toBe(true) // Wait for 3 seconds (3000 milliseconds). await window.waitForTimeout(3000) } @@ -196,9 +202,9 @@ export const checkProjectName = async (window, expect, name) => { } await window.waitForTimeout(1000) await window.waitForSelector('//*[@aria-label="editor-project-name"]',{ timeout: 120000 }) - const projectname = await window.locator('//*[@aria-label="editor-project-name"]').textContent() + const projectname = await window.locator('//*[@aria-label="editor-project-name"]', { timeout: 120000 }).textContent() // expecting project name in editor - expect(await projectname).toBe(name); + await expect(projectname).toBe(name); } // Checks for notifications. @@ -222,9 +228,8 @@ export const goToProjectPage = async (window, expect) => { await expect(window.locator('//*[@id="back-button"]')).toBeVisible() await window.locator('//*[@id="back-button"]').click(); // Check if the title on the project page is "Projects." - const title = await window.locator('//*[@aria-label="projects"]').textContent(); - await expect(title).toBe('Projects'); - await window.waitForTimeout(1000) + await window.waitForTimeout(500) + await projectPageExpect(window, expect) } // Common function for interacting with tables. @@ -263,8 +268,8 @@ export const exportProjects = async (window, expect, projectname) => { await window.locator('//*[@aria-label="export-projects"]').click() await window.waitForTimeout(2000) // Check for the success message. - const snackText = await window.locator('//*[@aria-label="snack-text"]').textContent() - await expect(snackText).toBe("Exported Successfully") + const snackText = await window.locator('//*[@aria-label="snack-text"]').isVisible() + await expect(snackText).toBe(true) await window.locator('//*[@aria-label="arrow-up"]').click() } @@ -281,8 +286,8 @@ export const exportAudioProject = async(window, expect, projectname, itemCheck) await window.locator('//*[@aria-label="export-projects"]').click() await window.waitForTimeout(2000) // Check for the success message. - const snackText = await window.locator('//*[@aria-label="snack-text"]').textContent() - await expect(snackText).toBe("Exported Successfully") + const snackText = await window.locator('//*[@aria-label="snack-text"]').isVisible() + await expect(snackText).toBe(true) await window.locator('//*[@aria-label="arrow-up"]').click() } @@ -293,22 +298,19 @@ export const archivedProjects = async (window, expect, projectname) => { // Click the "archived-projects" button. await window.locator('//*[@aria-label="archived-projects"]').click() // Check if the archive title is "Archived projects." - const archiveTitle = await window.locator('//*[@aria-label="projects"]').textContent() - await expect(archiveTitle).toBe("Archived projects") + await projectPageExpect(window, expect) const archiveProjectName = await window.locator(`//*[@id="${projectname}"]`).innerHTML() await expect(archiveProjectName).toBe(projectname); // Click the "active-projects" button to go back to the active projects. await window.locator('//*[@aria-label="active-projects"]').click() - const projectTitle = await window.locator('//*[@aria-label="projects"]').textContent() - await expect(projectTitle).toBe('Projects'); + await projectPageExpect(window, expect) } // Moves a project back from archived to active projects. export const unarchivedProjects = async (window, expect, projectname) => { // Click the "archived-projects" button to go to the archived projects. await window.locator('//*[@aria-label="archived-projects"]').click(); - const archiveTitle = await window.locator('//*[@aria-label="projects"]').textContent(); - await expect(archiveTitle).toBe("Archived projects"); + await projectPageExpect(window, expect) // Use the common function to locate the project and unarchive it. await commonFilterTable(window, expect, projectname, "archive-restore-project"); // Click the "active-projects" button to go back to the active projects. @@ -323,8 +325,7 @@ export const goToEditProject = async (window, expect, projectName) => { await commonFilterTable(window, expect, projectName, "edit-project"); await window.waitForTimeout(500); // Check if the title on the edit project page is "Edit Project." - const editTitle = await window.locator('//*[@aria-label="projects"]').textContent(); - await expect(editTitle).toBe('Edit Project'); + await projectPageExpect(window, expect) } // Changes the target language for a project. @@ -356,8 +357,8 @@ export const projectTargetLanguage = async (window, expect, projectName, searchL } } // Verify the title of the page is "Projects." - const title = await window.textContent('//*[@aria-label="projects"]', { timeout: 10000 }); - expect(title).toBe('Projects'); + await projectPageExpect(window, expect) + } // Updates the project description and abbreviation. @@ -375,11 +376,8 @@ export const updateDescriptionAbbriviation = async (window, expect, descriptionT await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible(); // Click the "Save" button. await window.locator('//*[@aria-label="save-edit-project"]').click(); - // Wait for the page to load. - await window.waitForTimeout(3000); // Verify the title of the page is "Projects." - const title = await window.textContent('//*[@aria-label="projects"]'); - expect(await title).toBe('Projects'); + await projectPageExpect(window, expect) await window.waitForTimeout(500) await expect(window.locator('//*[@id="projects-list"]')).toBeVisible() const table = window.locator('//*[@id="projects-list"]') @@ -422,11 +420,8 @@ export const changeLicense = async (window, expect, currentLicense, newLicense) // Ensure the "Save" button is visible and click it. await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible(); await window.locator('//*[@aria-label="save-edit-project"]').click(); - // Wait for the page to load. - await window.waitForTimeout(3000); // Verify the title of the page is "Projects." - const title = await window.textContent('//*[@aria-label="projects"]'); - expect(await title).toBe('Projects'); + await projectPageExpect(window, expect) } export const checkingUpdatedLicense = async (window, expect, projectname, newLicense, flavorType) => { @@ -520,14 +515,14 @@ export const userProfileValidaiton = async(window, expect) => { expect(await window.locator('//*[@id="save-profile"]')).toBeVisible(); await window.locator('//*[@id="save-profile"]').click(); // Verify error messages for first/last name, email, organization, and region. - const firstLastNameError = await window.locator('//*[@aria-label="name-error"]').textContent(); - expect(firstLastNameError).toBe('The input has to be between 2 and 15 characters long'); - const emailError = await window.locator('//*[@aria-label="email-error"]').textContent(); - expect(emailError).toBe('Email is not valid!'); - const organizationError = await window.locator('//*[@aria-label="organization-error"]').textContent(); - expect(organizationError).toBe('The input has to be between 2 and 30 characters long'); - const regionError = await window.locator('//*[@aria-label="region-error"]').textContent(); - expect(regionError).toBe('The input has to be between 2 and 15 characters long'); + const firstLastNameError = await window.locator('//*[@aria-label="name-error"]').isVisible(); + await expect(firstLastNameError).toBe(true); + const emailError = await window.locator('//*[@aria-label="email-error"]').isVisible(); + await expect(emailError).toBe(true); + const organizationError = await window.locator('//*[@aria-label="organization-error"]').isVisible(); + await expect(organizationError).toBe(true); + const regionError = await window.locator('//*[@aria-label="region-error"]').isVisible(); + await expect(regionError).toBe(true); } diff --git a/e2e-tests/myFixtures.ts b/e2e-tests/myFixtures.ts index bd9182635..f41b097c8 100644 --- a/e2e-tests/myFixtures.ts +++ b/e2e-tests/myFixtures.ts @@ -30,7 +30,9 @@ type myFixture = { customObsLanguage: string, customAudioLanguage: string, english: string, - hindi: string + hindi: string, + russian: string, + farsi: string } const myFixtureTest = myTest.extend({ userName: "Playwright user", @@ -56,6 +58,8 @@ const myFixtureTest = myTest.extend({ customAudioLanguage: "custom audio project language", english: "English", hindi: "Hindi", + russian: "Russian", + farsi: "Farsi", textUnderscore: "Translation_test_project", obsUnderscore: "Obs_test_project", syncName: "Sync_Collab_Test", diff --git a/renderer/src/components/ProjectsPage/CreateProject/CustomCanonSpecification.js b/renderer/src/components/ProjectsPage/CreateProject/CustomCanonSpecification.js index 1ad017662..4fbcdde2d 100644 --- a/renderer/src/components/ProjectsPage/CreateProject/CustomCanonSpecification.js +++ b/renderer/src/components/ProjectsPage/CreateProject/CustomCanonSpecification.js @@ -97,6 +97,7 @@ const CustomCanonSpecification = ({ bibleNav, closeBibleNav, handleNav }) => { {lock ? (