fix: helper.ts issues with changing locales in tests

This commit is contained in:
Paul Popus
2024-03-13 18:16:27 -03:00
parent 4f730410bc
commit eee44a9919

View File

@@ -54,6 +54,7 @@ export async function saveDocHotkeyAndAssert(page: Page): Promise<void> {
export async function saveDocAndAssert(page: Page, selector = '#action-save'): Promise<void> {
await page.click(selector, { delay: 100 })
await expect(page.locator('.Toastify')).toContainText('successfully')
await wait(500)
expect(page.url()).not.toContain('create')
}
@@ -73,13 +74,20 @@ export async function closeNav(page: Page): Promise<void> {
}
export async function openDocControls(page: Page): Promise<void> {
await page.locator('.doc-controls__popup .popup-button').click()
await expect(page.locator('.doc-controls__popup .popup__content')).toBeVisible()
await page.locator('.doc-controls__popup >> .popup-button').click()
await expect(page.locator('.doc-controls__popup >> .popup__content')).toBeVisible()
}
export async function changeLocale(page: Page, newLocale: string) {
await page.locator('.localizer >> button').first().click()
await page.locator(`.localizer >> a[href="/?locale=${newLocale}"]`).click()
await page
.locator(`.localizer`)
.locator(`.popup >> button`, {
hasText: newLocale,
})
.first()
.click()
await wait(500)
expect(page.url()).toContain(`locale=${newLocale}`)
}