Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test obs editor #249

Open
wants to merge 12 commits into
base: development
Choose a base branch
from
178 changes: 160 additions & 18 deletions e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
exportAudioProject, updateDescriptionAbbriviation, changeLicense,
customAddEditLanguage, customProjectTargetLanguage, starUnstar,
clickUserImageToLogout, confirmBookInEditor, checkingUpdatedLicense,
createUser, projectPageExpect
createUser, projectPageExpect, removeResource, addPanel, downloadResource,
searchResourceLanguage, downloadedResourceTable, loadResource
} from './common';

const fs = require('fs');
Expand Down Expand Up @@ -47,7 +48,7 @@ test.beforeAll(async ({ userName }) => {
const folder = await userFolder(window, userName, packageInfo, path)
// If 'projects' is not visible, check the 'welcome' element
const welcome = await window.locator('//*[@aria-label="welcome"]', { timeout: 5000 }).textContent()
await expect(welcome).toBe(welcome)
await expect(welcome).toEqual(expect.stringContaining(welcome))
// On the login page, if the playwright user exists, reload the app and remove it
const existUser = await json.some((item) => item.username.toLowerCase() === userName.toLowerCase());
if (await existUser && await fs.existsSync(folder)) {
Expand All @@ -69,8 +70,8 @@ test('check user length should be between 3 and 15 characters long', async () =>
await window.waitForSelector('//*[@aria-label="welcome"]')
await createUser(window, expect, "jo")
// Check for a length error message
const lengthError = await window.locator('//*[@id="show-error"]')
expect(await lengthError.textContent()).toBe('The input has to be between 3 and 15 characters long')
const lengthError = await window.locator('//*[@id="show-error"]').textContent()
expect(lengthError).toEqual(expect.stringContaining(lengthError))
await window.locator('//*[@aria-label="cancel"]').click()

})
Expand Down Expand Up @@ -103,7 +104,7 @@ test("check the user is already created", async ({ userName }) => {
await createUser(window, expect, userName)
// Check for a length error message
const userExist = await window.locator('//*[@id="show-error"]').textContent()
expect(await userExist).toBe('User exists, Check archived and active tab by click on view more.')
expect(userExist).toEqual(expect.stringContaining(userExist))
await window.waitForTimeout(200)
await window.locator('//*[@aria-label="cancel"]').click()
await window.locator(`//*[@id="${userName.toLowerCase()}"]`).click()
Expand Down Expand Up @@ -139,6 +140,13 @@ test("Click the view users button and delete the playwright user from the active
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)
})

/*changing app language english to hindi */
test("App language change English to hindi", async ({ english, hindi }) => {
// Change the app language from English to hindi
Expand All @@ -147,18 +155,13 @@ test("App language change English to hindi", async ({ 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"]').textContent();
expect(await snackbar).toBe("Updated the Profile.");
expect(snackbar).toEqual(expect.stringContaining(snackbar));

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*/
/*CREATE PROJECTS FOR ALL FLAVOR TYPE */
Expand All @@ -182,7 +185,7 @@ test('Click New button button and fill a new project detail for text translation
await window.locator('//*[@id="save-canon"]').click()
await window.locator('//button[@aria-label="create"]').click()
const projectName = await window.locator(`//*[@id="${textProject}"]`).innerHTML()
await expect(projectName).toBe(textProject);
await expect(projectName).toEqual(expect.stringContaining(textProject));
})

/* Obs translation project */
Expand Down Expand Up @@ -272,11 +275,150 @@ test('Add content in verses 1 and 2 in the obs story 1 editor', async () => {
await window.locator('div:nth-child(3) > .flex-grow').fill("Story content added in verse 3");
// Verify if the content was added to verse 2 and verse 3
const verse2 = await window.textContent('div:nth-child(2) > .flex-grow');
expect(verse2).toBe('God created heavens and earth');
expect(verse2).toEqual(expect.stringContaining(verse2));
const verse3 = await window.textContent('div:nth-child(3) > .flex-grow');
expect(verse3).toBe('Story content added in verse 3');
expect(verse3).toEqual(expect.stringContaining(verse3));
});

// Test case for adding panels and verifying the panel count.
test('Adding panels', async () => {
// Add a panel
await addPanel(window)
// Get the panel count and expect it to be '2'
let title = await window.innerText('//*[@aria-label="number-of-panels"]');
expect(title).toBe('2');
// Add another panel
await addPanel(window)
// Get the panel count and expect it to be '3'
title = await window.innerText('//*[@aria-label="number-of-panels"]');
expect(title).toBe('3');
// Add one more panel
await addPanel(window)
// Get the panel count and expect it to be '1' (cycling back to 1)
title = await window.innerText('//*[@aria-label="number-of-panels"]');
expect(title).toBe('1');
});

// Test case for adding reference panels, removing them, and verifying the panel count.
test("Adding reference panels and removing them from the editor", async () => {
// Add two panels
await addPanel(window)
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('2')
await addPanel(window)
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('3')
// Remove a panel (reference panel 1)
await removeResource(window, expect, 1, "confirm-remove")
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('2')
// Remove another panel (reference panel 3)
await removeResource(window, expect, 3, "confirm-remove")
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('1')
})

// Test case for adding sections for a resource in the editor.
test("Adding some more sections for resources in the editor", async () => {
// Add two panels
await addPanel(window)
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('2')
await addPanel(window)
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('3')
// Hover over the first panel, add a section
await window.locator('//*[@aria-label="resources-panel-1"]').hover()
await window.locator('//*[@aria-label="add-section-1"]').click()
// Hover over the third panel, add a section
await window.locator('//*[@aria-label="resources-panel-3"]').hover()
await window.locator('//*[@aria-label="add-section-3"]').click()
})

// Test case for removing all panels.
test("Removing all the panels", async () => {
// Remove section 2 from reference panel 1
await removeResource(window, expect, 2, "confirm-remove")
// Remove section 4 from reference panel 2
await removeResource(window, expect, 4, "confirm-remove")
// Remove 1 resource panel
await removeResource(window, expect, 1, "confirm-remove")
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('2')
// Remove 2 resource panels
await removeResource(window, expect, 3, "confirm-remove")
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('1')
})

// Test case for opening a resource panel, checking the tab is obs, and closing.
test("Open a resource panel, check the tab is obs, and close the resource panel", async () => {
// Add a panel
await addPanel(window)
// Click to load module in the first panel
await loadResource(window, expect, "load-module-1", "obs")
// Click to close the resource panel
await window.locator('//*[@aria-label="close-resource-pop"]').click()
})

// Test case for opening a resource panel, downloading an obs English resource, and displaying it in the added panel.
test("Open a resource panel download an obs English resource from the resource tab and display in it the added panel", async () => {
// Click to load module in the first panel
await loadResource(window, expect, "load-module-1", "obs")
// Download the English obs resource and display it in the added panel
await downloadResource(window, expect, "en_obs", "obs")
await downloadedResourceTable(window, expect, "en_obs", 1, "obs")
})

// Test case for adding a new resource panel, searching for a Hindi resource, downloading, and displaying it.
test(" Add a new resource panel, search Hindi resources, download and display", async ({ hindi }) => {
// Add a panel
await addPanel(window)
// Click to load module in the third panel
await loadResource(window, expect, "load-module-3", "obs")
// Switch to the resources tab and search for Hindi resource
await window.locator('//*[@aria-label="resources-tab"]').click()
await searchResourceLanguage(window, expect, hindi)
await window.locator('//*[@aria-label="resources-tab"]').click()
// Save the filter, download the Hindi obs resource, and display it in the third panel
await window.locator('//*[@aria-label="save-filter"]').click()
await downloadResource(window, expect, "hi_obs", "obs")
await downloadedResourceTable(window, expect, "hi_obs", 3, "obs")
})

// Test case for clearing search language and pre-release version filters.
test("Clear search language and pre-release version", async () => {
// Switch to the third resource panel
await loadResource(window, expect, "resources-selector-3", "obs")
// Switch to the resources tab and search for Urdu language
await window.locator('//*[@aria-label="resources-tab"]').click()
await searchResourceLanguage(window, expect, "Urdu")
await window.locator('//*[@aria-label="resources-tab"]').click()
// Check the pre-release version, clear search language and pre-release version filters, and close the resource panel
await window.locator('//*[@id="pre-prod"]').check()
await window.locator('//*[@aria-label="clear-language-version"]').click()
await window.locator('//*[@aria-label="close-resource-pop"]').click()
})

// Test case for downloading Persian obs resource with pre-release and replacing it with Hindi resource.
test("Download Persian obs resource with pre-release and replace with Hindi resource", async ({ farsi }) => {
// Switch to the third resource panel
// Get the tab text and expect it to be 'obs'
await loadResource(window, expect, "resources-selector-3", "obs")

// Switch to the resources tab
await window.locator('//*[@aria-label="resources-tab"]').click()

// Search for Persian (Farsi) language resource
await searchResourceLanguage(window, expect, "Persian (Farsi)")

// Switch back to the resources tab
await window.locator('//*[@aria-label="resources-tab"]').click()

// Check the pre-release version filter
await window.locator('//*[@id="pre-prod"]').check()

// Save the filter settings
await window.locator('//*[@aria-label="save-filter"]').click()

// Download the Persian obs resource and display it in the third panel
await downloadResource(window, expect, "fa_obs", "obs")
await downloadedResourceTable(window, expect, "fa_obs", 3, "obs")
})


test('Increase the font size in the obs editor', async () => {
await window.waitForSelector('//*[@aria-label="increase-font"]', { timeout: 5000 });
await window.locator('//*[@aria-label="increase-font"]').click();
Expand Down Expand Up @@ -353,7 +495,7 @@ test("Export text translation project without add any content in the Downloads f
await exportProjects(window, expect, textProject)
})

test("Export the obs project without add any content in the Downloads folder", async ({ obsProject }) => {
test("Export the obs project with content in the Downloads folder", async ({ obsProject }) => {
await exportProjects(window, expect, obsProject)
})

Expand Down Expand Up @@ -543,7 +685,7 @@ test("App language change Hindi to English", async ({ 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"]').textContent();
expect(await snackbar).toBe("Updated the Profile.");
expect(snackbar).toEqual(expect.stringContaining(snackbar));

await window.locator('//*[@aria-label="projectList"]').click();
await projectPageExpect(window, expect)
Expand Down Expand Up @@ -645,6 +787,6 @@ test("Update user Profile details", async () => {
// Verify the success message
await window.waitForSelector('//*[@aria-label="snack-text"]')
const snackbar = await window.locator('//*[@aria-label="snack-text"]').textContent();
expect(await snackbar).toBe("Updated the Profile.");
expect(snackbar).toEqual(expect.stringContaining(snackbar));
await window.locator('//*[@aria-label="projectList"]').click();
})
Loading
Loading