Skip to content

Commit

Permalink
added comment line for newly obs test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobbykumar706584 committed Nov 20, 2023
1 parent 5b33eae commit b33cf4d
Show file tree
Hide file tree
Showing 2 changed files with 92 additions and 7 deletions.
60 changes: 56 additions & 4 deletions e2e-tests/base.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,107 +280,159 @@ test('Add content in verses 1 and 2 in the obs story 1 editor', async () => {
expect(verse3).toBe('Story content added in verse 3');
});

// 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 refernce panels and removing 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 section for resource in 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 () => {
//removing added section 2 from reference panel 1
// Remove section 2 from reference panel 1
await removeResource(window, expect, 2, "confirm-remove")
//removing added section 4 from reference panel 2
// Remove section 4 from reference panel 2
await removeResource(window, expect, 4, "confirm-remove")
// removing 1 resource panel
// Remove 1 resource panel
await removeResource(window, expect, 1, "confirm-remove")
expect(await window.innerText('//*[@aria-label="number-of-panels"]')).toBe('2')
// removing 2 resource panel
// 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", async () => {
// Add a panel
await addPanel(window)
// Click to load module in the first panel
await window.locator('//*[@aria-label="load-module-1"]').click()
// Get the tab text and expect it to be 'obs'
const tab = await window.locator('//*[@aria-label="obs"]').textContent()
await expect(tab).toBe('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 and download a obs english resource from resource tab and display in added panel", async () => {
// Click to load module in the first panel
await window.locator('//*[@aria-label="load-module-1"]').click()
// Get the tab text and expect it to be 'obs'
const tab = await window.locator('//*[@aria-label="obs"]').textContent()
await expect(tab).toBe('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 resource, download and display", async ({ hindi }) => {
// Add a panel
await addPanel(window)
// Click to load module in the third panel
await window.locator('//*[@aria-label="load-module-3"]').click()
// Get the tab text and expect it to be 'obs'
const tab = await window.locator('//*[@aria-label="obs"]').textContent()
await expect(tab).toBe('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 langague and pre-release version", async () => {
// Switch to the third resource panel
await window.locator('//*[@aria-label="resources-selector-3"]').click()
// Get the tab text and expect it to be 'obs'
const tab = await window.locator('//*[@aria-label="obs"]').textContent()
await expect(tab).toBe('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
await window.locator('//*[@aria-label="resources-selector-3"]').click()
// Get the tab text and expect it to be 'obs'
const tab = await window.locator('//*[@aria-label="obs"]').textContent()
await expect(tab).toBe('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
39 changes: 36 additions & 3 deletions e2e-tests/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,69 +255,102 @@ export const removeResource = async (window, expect, resourcePaneNo, confirmButt
await window.locator(`//*[@aria-label="${confirmButton}"]`).click()
}

// This function is responsible for searching and selecting a language in a custom dropdown.
export const searchResourceLanguage = async (window, expect, searchLanguage) => {
// Wait for the custom dropdown to be visible.
await window.waitForSelector('//*[@aria-label="custom-dropdown"]')
const searchLang = await window.locator('//*[@aria-label="custom-dropdown"]')
// Ensure that the custom dropdown is visible.
expect(await searchLang).toBeVisible();
// Fill in the search language.

// Click on the custom dropdown to activate the language search.
await searchLang.click()
// Fill in the search language in the dropdown.
await searchLang.fill(searchLanguage)
// Click on the selectLanguage in the dropdown.
await window.locator(`//*[@aria-label="${searchLanguage}"]`).click({ timeout: 10000 });
// Wait for 2000 milliseconds (2 seconds).
await window.waitForTimeout(2000)
}

// download resource and display in panel
// This function is responsible for navigating to the resources tab, locating a specific resource, and downloading it.
export const downloadResource = async (window, expect, resourceName, tabType) => {
// Navigate to the resources tab.
await window.locator('//*[@aria-label="resources-tab"]').click()
// Wait for the resource table to be visible.
await window.waitForSelector('//*[@id="resource-table"]')
// Ensure that the resource table is visible.
await expect(window.locator('//*[@id="resource-table"]')).toBeVisible()
const table = window.locator('//*[@id="resource-table"]')
const body = table.locator('//*[@id="resources-tab-body"]')
const rows = await body.locator('tr')

// Iterate through each row in the resource table.
for (let i = 0; i < await rows.count(); i++) {
const row = await rows.nth(i);
const tds = await row.locator('td');

// Check if the resource name in the current row matches the target resource name.
if (await tds.nth(1).textContent() === resourceName) {
// Check if the "download-resource" button is visible and click it.
await window.waitForSelector('//*[@aria-label="download-resource"]')
await tds.last().locator('//*[@aria-label="download-resource"]').click()
// Wait for 1000 milliseconds (1 second).
await window.waitForTimeout(1000)
// wait for until the resource may download
// Check if the downloaded resource name matches the target resource name.
expect(await tds.nth(1).textContent({ timeout: 100000 })).toBe(resourceName)
break;
}
}

// Switch to the specified tab type.
const bibleObsTab = await window.locator(`//*[@aria-label="${tabType}"]`)
expect(await bibleObsTab).toBeVisible()
await bibleObsTab.click()
expect(await bibleObsTab.textContent()).toBe(tabType)
}

// This function is responsible for navigating to the downloaded resources table and verifying the presence of a specific resource.
export const downloadedResourceTable = async (window, expect, resourceName, panelNo, tabType) => {
// Wait for the specified tab type to be visible.
const bibleObsTab = await window.locator(`//*[@aria-label="${tabType}"]`, { timeout: 10000 })
expect(await bibleObsTab).toBeVisible()

// Wait for the downloaded resources table to be visible.
await window.waitForSelector('//*[@id="downloaded-resources-table"]')
await expect(window.locator('//*[@id="downloaded-resources-table"]')).toBeVisible()
const table = window.locator('//*[@id="downloaded-resources-table"]')
const body = table.locator('//*[@id="downloaded-resources-table-body"]')
const rows = await body.locator('tr')

// Iterate through each row in the downloaded resources table.
for (let i = 0; i < await rows.count(); i++) {
const row = await rows.nth(i);
const tds = await row.locator('td');
const data = await tds.nth(0).textContent()
const dataSplit = data.slice(0, 6)

// Check if the resource name in the current row matches the target resource name.
if (await dataSplit === resourceName) {
// Click on the resource in the downloaded resources table.
await tds.nth(0).click()
break;
}
}

// Wait for the resource panel to be visible.
await window.waitForSelector(`//*[@aria-label="obs-resource-${panelNo}"]`)
const resoursetitle = await window.locator(`//*[@aria-label="obs-resource-${panelNo}"]`, { timeout: 10000 }).innerHTML()
const splitString = await resoursetitle.slice(0, 6)

// Verify that the displayed resource name in the panel matches the target resource name.
expect(await splitString).toBe(resourceName)

// Get and verify the story title in the panel.
const storyTitle = await window.locator(`//*[@aria-label="obs-story-book-title-${panelNo}"]`).innerHTML()
expect(await storyTitle).toBe(storyTitle)

// Wait for 1000 milliseconds (1 second).
await window.waitForTimeout(1000)
}

Expand Down

0 comments on commit b33cf4d

Please sign in to comment.