From 3c46ecb587d3ff5e8d60f8eca7d126d34a2b5b79 Mon Sep 17 00:00:00 2001 From: Bobbykumar706584 Date: Thu, 12 Oct 2023 10:26:50 +0530 Subject: [PATCH] target langauge test --- e2e-tests/base.test.ts | 83 ++++++++++++------- e2e-tests/common.js | 54 ++++++++++++ .../CreateProject/AdvancedSettingsDropdown.js | 1 + .../ResourceUtils/CustomMultiComboBox.js | 3 +- 4 files changed, 111 insertions(+), 30 deletions(-) diff --git a/e2e-tests/base.test.ts b/e2e-tests/base.test.ts index d3d432d1f..3d2b3d981 100644 --- a/e2e-tests/base.test.ts +++ b/e2e-tests/base.test.ts @@ -9,7 +9,7 @@ import { userValidation, signOut, showActiveUsers, searchProject, checkProjectName, checkNotification, goToProjectPage, exportProjects, archivedProjects, - unarchivedProjects, goToEditProject, changeAppLanguage + unarchivedProjects, goToEditProject, changeAppLanguage, changeTargetLanguage, projectTargetLanguage, userProfileValidaiton } from './common'; const fs = require('fs'); @@ -97,10 +97,10 @@ test('Click New and Fill project page details to create a new project for text t await window.locator('//textarea[@id="project_description"]').fill('test description') await expect(window.locator('//input[@id="version_abbreviated"]')).toBeVisible() 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="custom-book"]')).toBeVisible() - await window.locator('//div[@aria-label="custom-book"]').click() + await expect(window.locator('//*[@id="open-advancesettings"]')).toBeVisible() + await window.locator('//*[@id="open-advancesettings"]').click() + await expect(window.locator('//*[@aria-label="custom-book"]')).toBeVisible() + await window.locator('//*[@aria-label="custom-book"]').click() await window.locator('//*[@aria-label="nt-Matthew"]').click() await window.locator('//*[@id="save-canon"]').click() await window.locator('//button[@aria-label="create"]').click() @@ -297,8 +297,8 @@ test("Update/Edit text translation project of description and abbreviation", asy 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 expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible() + await window.locator('//*[@aria-label="save-edit-project"]').click() await window.waitForTimeout(3000) const title = await window.textContent('[aria-label=projects]'); expect(await title).toBe('Projects') @@ -306,15 +306,15 @@ test("Update/Edit text translation project of description and abbreviation", asy test("Update/Edit text translation project scope mark and luke", async ({ textProject }) => { await goToEditProject(window, expect, textProject) - await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible() - await window.locator('//button[@id="open-advancesettings"]').click() - await expect(window.locator('//div[@aria-label="custom-book"]')).toBeVisible() - await window.locator('//div[@aria-label="custom-book"]').click() + await expect(window.locator('//*[@id="open-advancesettings"]')).toBeVisible() + await window.locator('//*[@id="open-advancesettings"]').click() + await expect(window.locator('//*[@aria-label="custom-book"]')).toBeVisible() + await window.locator('//*[@aria-label="custom-book"]').click() await window.locator('//*[@aria-label="nt-Mark"]').click() await window.locator('//*[@aria-label="nt-Luke"]').click() await window.locator('//*[@id="save-canon"]').click() - await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible() - await window.locator('//button[@aria-label="save-edit-project"]').click() + await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible() + await window.locator('//*[@aria-label="save-edit-project"]').click() await window.waitForTimeout(2500) const title = await window.textContent('[aria-label=projects]'); expect(await title).toBe('Projects') @@ -322,13 +322,13 @@ test("Update/Edit text translation project scope mark and luke", async ({ textPr test("Update/Edit text translation project scope custom book into NT", async ({ textProject }) => { await goToEditProject(window, expect, textProject) - 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 expect(window.locator('//*[@id="open-advancesettings"]')).toBeVisible() + await window.locator('//*[@id="open-advancesettings"]').click() + await expect(window.locator('//*[@aria-label="new-testament"]')).toBeVisible() + await window.locator('//*[@aria-label="new-testament"]').click() await window.locator('//button[contains(text(),"Ok")]').click() - await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible() - await window.locator('//button[@aria-label="save-edit-project"]').click() + await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible() + await window.locator('//*[@aria-label="save-edit-project"]').click() await window.waitForTimeout(3000) const title = await window.textContent('[aria-label=projects]'); expect(await title).toBe('Projects') @@ -336,15 +336,15 @@ test("Update/Edit text translation project scope custom book into NT", async ({ test("Update/Edit text transaltion project scope custom book genesis and exodus from OT", async ({ textProject }) => { await goToEditProject(window, expect, textProject) - await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible() - await window.locator('//button[@id="open-advancesettings"]').click() - await expect(window.locator('//div[@aria-label="custom-book"]')).toBeVisible() - await window.locator('//div[@aria-label="custom-book"]').click() + await expect(window.locator('//*[@id="open-advancesettings"]')).toBeVisible() + await window.locator('//*[@id="open-advancesettings"]').click() + await expect(window.locator('//*[@aria-label="custom-book"]')).toBeVisible() + await window.locator('//*[@aria-label="custom-book"]').click() await window.locator('//*[@aria-label="ot-Genesis"]').click() await window.locator('//*[@aria-label="ot-Exodus"]').click() await window.locator('//*[@id="save-canon"]').click() - await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible() - await window.locator('//button[@aria-label="save-edit-project"]').click() + await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible() + await window.locator('//*[@aria-label="save-edit-project"]').click() await window.waitForTimeout(3000) const title = await window.textContent('[aria-label=projects]'); expect(await title).toBe('Projects') @@ -352,17 +352,42 @@ test("Update/Edit text transaltion project scope custom book genesis and exodus test("Update/Edit text translation project license", async ({ textProject }) => { await goToEditProject(window, expect, textProject) - await expect(window.locator('//button[@id="open-advancesettings"]')).toBeVisible() - await window.locator('//button[@id="open-advancesettings"]').click() + await expect(window.locator('//*[@id="open-advancesettings"]')).toBeVisible() + await window.locator('//*[@id="open-advancesettings"]').click() await window.getByRole('button', { name: 'CC BY-SA' }).click() await window.getByRole('option', { name: 'CC BY', exact: true }).click() - await expect(window.locator('//button[@aria-label="save-edit-project"]')).toBeVisible() - await window.locator('//button[@aria-label="save-edit-project"]').click() + await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible() + await window.locator('//*[@aria-label="save-edit-project"]').click() await window.waitForTimeout(3000) const title = await window.textContent('[aria-label=projects]'); expect(await title).toBe('Projects') }) +test("Changing text translation project language from English to Persian", async ({ textProject }) => { + await projectTargetLanguage(window, expect, textProject, "persian", "Persian (Farsi)") +}) + +test("Changing text translation project language from Persian to English", async ({ textProject }) => { + await projectTargetLanguage(window, expect, textProject, "english", "English") +}) + +test("Update user Profile", async () => { + await userProfileValidaiton(window, expect) + await expect(window.locator('input[name="given-name"]')).toBeVisible(); + await window.locator('input[name="given-name"]').fill("Bobby") + await expect(window.locator('input[name="family-name"]')).toBeVisible(); + await window.locator('input[name="family-name"]').fill("kumar") + await expect(window.locator('input[name="email"]')).toBeVisible(); + await window.locator('input[name="email"]').fill("kumar@gamil.com") + await expect(window.locator('input[name="organization"]')).toBeVisible(); + await window.locator('input[name="organization"]').fill("vidya foundation") + await expect(window.locator('input[name="selectedregion"]')).toBeVisible(); + await window.locator('input[name="selectedregion"]').fill("India") + expect(await window.locator('//*[@id="save-profile"]')).toBeVisible() + await window.locator('//*[@id="save-profile"]').click() + 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 () => { diff --git a/e2e-tests/common.js b/e2e-tests/common.js index 77167782d..cb2d0aa5c 100644 --- a/e2e-tests/common.js +++ b/e2e-tests/common.js @@ -158,6 +158,7 @@ export const checkProjectName = async (window, expect, name) => { // Checks for notifications. export const checkNotification = async (window, expect) => { + await window.waitForSelector('//*[@aria-label="notification-button"]', {timeout : 5000}) await window.locator('//*[@aria-label="notification-button"]').click() await window.waitForTimeout(1000) const title = await window.locator('[aria-label=notification-title]').textContent(); @@ -241,6 +242,59 @@ export const goToEditProject = async (window, expect, projectName) => { const editTitle = await window.locator('//*[@aria-label="projects"]').textContent() await expect(editTitle).toBe('Edit Project'); } +// change project target language +export const projectTargetLanguage = async (window, expect, projectName, searchLangauge, selectLanguage) => { + await goToEditProject(window, expect, projectName) + expect(await window.locator('//*[@aria-label="custom-dropdown"]')).toBeVisible() + await window.locator('//*[@aria-label="custom-dropdown"]').fill(searchLangauge) + await window.locator(`//*[@aria-label="${selectLanguage}"]`).click() + await expect(window.locator('//*[@aria-label="save-edit-project"]')).toBeVisible() + await window.locator('//*[@aria-label="save-edit-project"]').click() + await window.waitForTimeout(2000) + await expect(window.locator('//*[@id="projects-list"]')).toBeVisible() + 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) { + // expecting language + expect(await tds.nth(2).textContent()).toBe(selectLanguage) + } + } + const title = await window.textContent('[aria-label=projects]', { timeout: 10000 }); + expect(title).toBe('Projects'); +} + +// Performs user profile validation checks. +export const userProfileValidaiton = async(window, expect) => { + expect(await window.locator('//*[@id="user-profile-image"]')).toBeVisible() + await window.locator('//*[@id="user-profile-image"]').click() + expect(await window.locator('//*[@aria-label="user-profile"]')).toBeVisible() + await window.locator('//*[@aria-label="user-profile"]').click() + await expect(window.locator('input[name="given-name"]')).toBeVisible(); + await window.locator('input[name="given-name"]').fill("b") + await expect(window.locator('input[name="family-name"]')).toBeVisible(); + await window.locator('input[name="family-name"]').fill("k") + await expect(window.locator('input[name="email"]')).toBeVisible(); + await window.locator('input[name="email"]').fill("kumar") + await expect(window.locator('input[name="organization"]')).toBeVisible(); + await window.locator('input[name="organization"]').fill("v") + await expect(window.locator('input[name="selectedregion"]')).toBeVisible(); + await window.locator('input[name="selectedregion"]').fill("I") + expect(await window.locator('//*[@id="save-profile"]')).toBeVisible() + await window.locator('//*[@id="save-profile"]').click() + const firstLastNameError = await window.locator('//*[@id="__next"]/div[1]/div[2]/div/div[2]/form/div[2]/span').textContent() + expect(firstLastNameError).toBe('The input has to be between 2 and 15 characters long') + const emailError = await window.locator('//*[@id="__next"]/div[1]/div[2]/div/div[2]/form/div[3]/span').textContent() + expect(emailError).toBe('Email is not valid!') + const organizationError = await window.locator('//*[@id="__next"]/div[1]/div[2]/div/div[2]/form/div[4]/span').textContent() + expect(organizationError).toBe('The input has to be between 2 and 30 characters long') + const regionError = await window.locator('//*[@id="__next"]/div[1]/div[2]/div/div[2]/form/div[5]/span').textContent() + expect(regionError).toBe('The input has to be between 2 and 15 characters long') +} + // Changes the application's language. export const changeAppLanguage = async (window, expect, fromLanguage, toLanguage) => { diff --git a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js index eb7bae0dc..42dec8b77 100644 --- a/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js +++ b/renderer/src/components/ProjectsPage/CreateProject/AdvancedSettingsDropdown.js @@ -284,6 +284,7 @@ export default function AdvancedSettingsDropdown({ call, project, projectType }) 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)`} diff --git a/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js b/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js index adf7854a3..bf86aadb5 100644 --- a/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js +++ b/renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js @@ -33,6 +33,7 @@ function CustomMultiComboBox({ // displayValue={(language) => language?.ang} displayValue={(selectedList) => `${selectedList.length > 0 ? `${selectedList[0][filterParams]}${multiSelect ? '... click for more' : '' }` : ''}`} placeholder="Select Language" + aria-label="custom-dropdown" onFocus={() => !open && setIsActive(true)} onBlur={() => setIsActive(false)} onChange={(event) => setQuery(event.target.value)} @@ -54,7 +55,7 @@ function CustomMultiComboBox({ {filteredData.length > 0 ? filteredData.map((data) => ( // - + {data[filterParams] } {' '} {showLangCode.show && (