Skip to content

Commit

Permalink
Initial Commit of Translation Version Name in Title Bar
Browse files Browse the repository at this point in the history
Sefaria/Sefaria-Playwright-Tests#18

TODO: Decide if we want to test for default translation title.
  • Loading branch information
b-w-cole committed Jul 24, 2024
1 parent e4446cc commit 622d4c7
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions e2e-tests/tests/translation-version-name-appears-in-title.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import {test, expect} from '@playwright/test';
import {goToPageWithLang} from "../utils";
import {LANGUAGES} from '../globals'

[
{interfaceLanguage: 'Hebrew', interfaceLanguageToggle: LANGUAGES.HE, translations: 'תרגומים', currentlySelected: 'נוכחי', secondTranslation: 'חומש רש״י, רבי שרגא זילברשטיין', thirdTranslation: '«Да» project'},
{interfaceLanguage: 'English', interfaceLanguageToggle: LANGUAGES.EN, translations: 'Translations', currentlySelected: 'Currently Selected', secondTranslation: 'The Rashi chumash by Rabbi Shraga Silverstein', thirdTranslation: '«Да» project'}
].forEach(({interfaceLanguage, interfaceLanguageToggle, translations, currentlySelected, secondTranslation, thirdTranslation}) => {
test(`${interfaceLanguage} - translation name appears in title`, async ({ context }) => {

// Navigate to Bereshit in specified Interface Language
const page = await goToPageWithLang(context,'/Genesis.1', `${interfaceLanguageToggle}`)

// Retain the translation name locator
const translationNameInTitle = page.locator('span.readerTextVersion')

// Click on the text title
await translationNameInTitle.click()

// Click on Translations
await page.getByRole('link', {name: `${translations}`}).click()

// Wait for Translations side-bar to load
await page.waitForSelector('h3')

// Check if the default translation in the title matches the selected translation
const defaultTranslation = await translationNameInTitle.textContent()
await expect(page.locator('div.version-with-preview-title-line', {hasText: defaultTranslation}).getByRole('link')).toHaveText(`${currentlySelected}`)

// Translation name list
const translationNames = [`${secondTranslation}`, `${thirdTranslation}`]

// Utilizing this for-loop, as async issues were noticed with foreach
for(let i = 0; i < translationNames.length; i++){

// "Select" another translation. Directly using Select vs בחירה is unnecessary due to DOM structure
await page.locator('div.version-with-preview-title-line', {hasText: translationNames[i]}).getByRole('link').click()

// Validate selected translation is reflected in title
await expect(translationNameInTitle).toHaveText(translationNames[i])

// Validate selected translation says 'Currently Selected'
await expect(page.locator('div.version-with-preview-title-line', {hasText: translationNames[i]}).getByRole('link')).toHaveText(`${currentlySelected}`)
}
})
})

0 comments on commit 622d4c7

Please sign in to comment.