Skip to content

Commit

Permalink
target langauge test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbykumar706584 committed Oct 12, 2023
1 parent 98e649c commit 3c46ecb
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 30 deletions.
83 changes: 54 additions & 29 deletions e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -297,72 +297,97 @@ 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')
})

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')
})

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')
})

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')
})

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("[email protected]")
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 () => {
Expand Down
54 changes: 54 additions & 0 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -54,7 +55,7 @@ function CustomMultiComboBox({
{filteredData.length > 0
? filteredData.map((data) => (
// <Combobox.Option key={data?.id || data?.pk} className={`${selectedList.includes(data) ? 'bg-gray-400' : ''} hover:bg-gray-300 p-1`} value={data}>
<Combobox.Option key={data?.id || data?.pk} className=" hover:bg-gray-300 p-1" value={data}>
<Combobox.Option key={data?.id || data?.pk} className=" hover:bg-gray-300 p-1" value={data} aria-label={data[filterParams]} >

Check failure on line 58 in renderer/src/components/Resources/ResourceUtils/CustomMultiComboBox.js

View workflow job for this annotation

GitHub Actions / Lint Run

A space is forbidden before closing bracket
{data[filterParams] }
{' '}
{showLangCode.show && (
Expand Down

0 comments on commit 3c46ecb

Please sign in to comment.