-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added new test that navigates between pages by changing the URL and edits them. One of the pages has a sheet the other has text (covers 3 of the 4 items on https://github.com/adobe/da-live/wiki/TODO-%E2%80%90-Playwright-tests ) * Support for running the tests against a locally running da-collab and da-admin (triggered by setting the env var GITHUB_HEAD_REF=local which now also selects these locally via query param) * Updated the regionaledit test to run in its own unique directory to allow multi browser tests to run concurrently without tripping over each other
- Loading branch information
1 parent
658dcc0
commit da40850
Showing
5 changed files
with
109 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,42 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import path from 'path'; | ||
import ENV from '../utils/env.js'; | ||
import { getTestFolderURL } from '../utils/page.js'; | ||
|
||
const deleteTestPage = async () => { | ||
// Delete the document even if the test fails; | ||
const pageName = 'regionaledit.html'; | ||
const adminURL = `https://admin.da.live/source/da-sites/da-status/tests/${pageName}`; | ||
await fetch(adminURL, { method: 'DELETE' }); | ||
}; | ||
|
||
test('Regional Edit Document', async ({ page }) => { | ||
test('Regional Edit Document', async ({ page }, workerInfo) => { | ||
test.setTimeout(15000); | ||
await deleteTestPage(); | ||
|
||
try { | ||
await page.goto(`${ENV}/#/da-sites/da-status/tests`); | ||
await page.getByRole('button', { name: 'New' }).click(); | ||
await page.getByRole('button', { name: 'Media' }).click(); | ||
|
||
const [fileChooser] = await Promise.all([ | ||
page.waitForEvent('filechooser'), | ||
page.getByText('Select file').click(), | ||
]); | ||
|
||
const htmlFile = path.join(__dirname, '/mocks/regionaledit.html'); | ||
console.log(htmlFile); | ||
await fileChooser.setFiles([`${htmlFile}`]); | ||
|
||
await page.getByRole('button', { name: 'Upload' }).click(); | ||
await page.getByRole('link', { name: 'regionaledit' }).click(); | ||
|
||
await expect(page.locator('div.loc-color-overlay.loc-langstore')).toBeVisible(); | ||
await expect(page.locator('div.loc-color-overlay.loc-regional')).toBeVisible(); | ||
|
||
expect(page.getByText('Deleted H1 Here', { exact: true })).toBeVisible(); | ||
expect(page.getByText('Added H1 Here', { exact: true })).toBeVisible(); | ||
|
||
await page.locator('div.loc-color-overlay.loc-langstore').hover(); | ||
await page.locator('da-loc-deleted').getByText('Delete', { exact: true }).click(); | ||
await expect(page.getByText('Deleted H1 Here', { exact: true })).not.toBeVisible(); | ||
|
||
await page.locator('div.loc-color-overlay.loc-regional').hover(); | ||
await page.locator('da-loc-added').getByText('Keep', { exact: true }).click(); | ||
await expect(page.getByText('Added H1 Here', { exact: true })).toBeVisible(); | ||
await expect(page.locator('div.loc-color-overlay.loc-regional')).not.toBeVisible(); | ||
} finally { | ||
deleteTestPage(); | ||
} | ||
|
||
const folderURL = getTestFolderURL('regionaledit', workerInfo); | ||
await page.goto(folderURL); | ||
await page.getByRole('button', { name: 'New' }).click(); | ||
await page.getByRole('button', { name: 'Media' }).click(); | ||
|
||
const [fileChooser] = await Promise.all([ | ||
page.waitForEvent('filechooser'), | ||
page.getByText('Select file').click(), | ||
]); | ||
|
||
const htmlFile = path.join(__dirname, '/mocks/regionaledit.html'); | ||
console.log(htmlFile); | ||
await fileChooser.setFiles([`${htmlFile}`]); | ||
|
||
await page.getByRole('button', { name: 'Upload' }).click(); | ||
await page.getByRole('link', { name: 'regionaledit', exact: true }).click(); | ||
|
||
await expect(page.locator('div.loc-color-overlay.loc-langstore')).toBeVisible(); | ||
await expect(page.locator('div.loc-color-overlay.loc-regional')).toBeVisible(); | ||
|
||
expect(page.getByText('Deleted H1 Here', { exact: true })).toBeVisible(); | ||
expect(page.getByText('Added H1 Here', { exact: true })).toBeVisible(); | ||
|
||
await page.locator('div.loc-color-overlay.loc-langstore').hover(); | ||
await page.locator('da-loc-deleted').getByText('Delete', { exact: true }).click(); | ||
await expect(page.getByText('Deleted H1 Here', { exact: true })).not.toBeVisible(); | ||
|
||
await page.locator('div.loc-color-overlay.loc-regional').hover(); | ||
await page.locator('da-loc-added').getByText('Keep', { exact: true }).click(); | ||
await expect(page.getByText('Added H1 Here', { exact: true })).toBeVisible(); | ||
await expect(page.locator('div.loc-color-overlay.loc-regional')).not.toBeVisible(); | ||
|
||
// Note that the test folder will be automatically cleaned up in subsequent runs | ||
// by the delete.spec.js test | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters