From 620e6f6837a81c1eeb0991aea60f9e08fd9a4e55 Mon Sep 17 00:00:00 2001 From: Bobbykumar706584 Date: Tue, 14 Nov 2023 14:44:27 +0530 Subject: [PATCH] test for updated target language --- e2e-tests/base.test.ts | 6 ++-- e2e-tests/common.js | 74 ++++++++++++++++++++++-------------------- 2 files changed, 42 insertions(+), 38 deletions(-) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index 6c7774d8c..9d122cea9 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -598,17 +598,17 @@ test('Search a new custom text translation project in all projects list', async /* Changing text translation project target language */ //text translation project -test("Changing text translation project language from English to Persian", async ({ textProject }) => { +test("Changing text translation project language from English to Persian, checking in Projects and edit page", async ({ textProject }) => { // Change the text translation project language await projectTargetLanguage(window, expect, textProject, "persian", "Persian (Farsi)") }) -test("Changing text translation project language from Persian to English", async ({ textProject, english }) => { +test("Changing text translation project language from Persian to English, checking in Projects and Edit page", async ({ textProject, english }) => { // Change the text translation project language await projectTargetLanguage(window, expect, textProject, english.toLowerCase(), english) }) -test("Changing text translation project language from English to new custom created language", async ({ textProject, customTextLanguage }) => { +test("Changing text translation project language from English to new custom created language, checking in Projects and Edit page", async ({ textProject, customTextLanguage }) => { // Change the text translation project language await projectTargetLanguage(window, expect, textProject, "custom text", customTextLanguage) await checkProjectName(window, expect, textProject) diff --git a/e2e-tests/common.js b/e2e-tests/common.js index 6a13e671a..f73aa697b 100644 --- a/e2e-tests/common.js +++ b/e2e-tests/common.js @@ -76,6 +76,16 @@ export const projectPageExpect = async (window, expect) => { await expect(title).toBe(true); } +export const clickUserImage = async (window, expect, itemClick) => { + // Ensure the user profile image is visible and click on it. + expect(await window.locator('//*[@id="user-profile-image"]')).toBeVisible(); + await window.locator('//*[@id="user-profile-image"]').click(); + // Verify that the user profile is visible and click on it. + await window.waitForSelector(`//*[@aria-label="${itemClick}"]`) + expect(await window.locator(`//*[@aria-label="${itemClick}"]`)).toBeVisible(); + await window.locator(`//*[@aria-label="${itemClick}"]`).click(); +} + // Signs the user out. export const signOut = async (window, expect) => { // Open the user profile menu and signout @@ -337,32 +347,36 @@ export const projectTargetLanguage = async (window, expect, projectName, searchL // Navigate to the project editing page. await goToEditProject(window, expect, projectName); // Ensure the custom dropdown is visible. - expect(await window.locator('//*[@aria-label="custom-dropdown"]')).toBeVisible(); - // Fill in the search language. - await window.locator('//*[@aria-label="custom-dropdown"]').fill(searchLangauge); - // Click on the selectLanguage in the dropdown. - await window.locator(`//*[@aria-label="${selectLanguage}"]`).click(); - // 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 and verify that the projects list is visible. - await window.waitForTimeout(2000); - await expect(window.locator('//*[@id="projects-list"]')).toBeVisible(); - // Locate the projects list, find the target project, and verify the selected language. - const table = window.locator('//*[@id="projects-list"]'); - const body = table.locator('//*[@id="projects-list-body"]'); - const rows = 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) { - // Verify the language of the selected project. - expect(await tds.nth(2).textContent()).toBe(selectLanguage); - } - } - // Verify the title of the page is "Projects." + await window.waitForSelector('//*[@aria-label="custom-dropdown"]') + const searchLang = await window.locator('//*[@aria-label="custom-dropdown"]') + expect(await searchLang).toBeVisible(); + // Fill in the search language. + await searchLang.click() + await searchLang.fill(searchLangauge); + // Click on the selectLanguage in the dropdown. + await window.locator(`//*[@aria-label="${selectLanguage}"]`).click(); + // 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 and verify that the projects list is visible. + await window.waitForTimeout(2000); + await expect(window.locator('//*[@id="projects-list"]')).toBeVisible(); + // Locate the projects list, find the target project, and verify the selected language. + const table = window.locator('//*[@id="projects-list"]'); + const body = table.locator('//*[@id="projects-list-body"]'); + const rows = 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) { + // Verify the language of the selected project. + expect(await tds.nth(2).textContent()).toBe(selectLanguage); + } + } + await goToEditProject(window, expect, projectName); + await window.locator('//*[@aria-label="cancel-edit-project"]').click() await projectPageExpect(window, expect) - + } // Updates the project description and abbreviation. @@ -469,16 +483,6 @@ export const customProjectTargetLanguage = async (window, expect, projectname, f await expect(projectName).toBe(projectname); } -export const clickUserImage = async (window, expect, itemClick) => { - // Ensure the user profile image is visible and click on it. - await window.waitForSelector('//*[@id="user-profile-image"]') - expect(await window.locator('//*[@id="user-profile-image"]')).toBeVisible(); - await window.locator('//*[@id="user-profile-image"]').click(); - // Verify that the user profile is visible and click on it. - expect(await window.locator(`//*[@aria-label="${itemClick}"]`)).toBeVisible(); - await window.locator(`//*[@aria-label="${itemClick}"]`).click(); -} - // Performs user profile validation checks. export const userProfileValidaiton = async(window, expect) => { await clickUserImage(window, expect, "user-profile")