chore: e2e: replace flaky manual save actions with non-flaky saveDocAndAssert helper
This commit is contained in:
@@ -9,10 +9,12 @@ import type { ReadOnlyCollection, RestrictedVersion } from './payload-types.js'
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
closeNav,
|
closeNav,
|
||||||
|
delayNetwork,
|
||||||
exactText,
|
exactText,
|
||||||
initPageConsoleErrorCatch,
|
initPageConsoleErrorCatch,
|
||||||
openDocControls,
|
openDocControls,
|
||||||
openNav,
|
openNav,
|
||||||
|
saveDocAndAssert,
|
||||||
} from '../helpers.js'
|
} from '../helpers.js'
|
||||||
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
|
||||||
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
import { initPayloadE2E } from '../helpers/initPayloadE2E.js'
|
||||||
@@ -58,6 +60,7 @@ describe('access control', () => {
|
|||||||
const context = await browser.newContext()
|
const context = await browser.newContext()
|
||||||
page = await context.newPage()
|
page = await context.newPage()
|
||||||
initPageConsoleErrorCatch(page)
|
initPageConsoleErrorCatch(page)
|
||||||
|
await delayNetwork({ context, page, delay: 'Slow 4G' })
|
||||||
})
|
})
|
||||||
|
|
||||||
test('field without read access should not show', async () => {
|
test('field without read access should not show', async () => {
|
||||||
@@ -248,7 +251,7 @@ describe('access control', () => {
|
|||||||
await expect(deleteAction).toBeHidden()
|
await expect(deleteAction).toBeHidden()
|
||||||
|
|
||||||
await page.locator('#field-approvedForRemoval').check()
|
await page.locator('#field-approvedForRemoval').check()
|
||||||
await page.locator('#action-save').click()
|
await saveDocAndAssert(page)
|
||||||
|
|
||||||
await openDocControls(page)
|
await openDocControls(page)
|
||||||
const deleteAction2 = page.locator('#action-delete')
|
const deleteAction2 = page.locator('#action-delete')
|
||||||
@@ -272,7 +275,7 @@ describe('access control', () => {
|
|||||||
|
|
||||||
// Allow access to test global.
|
// Allow access to test global.
|
||||||
await page.locator('.checkbox-input:has(#field-test) input').check()
|
await page.locator('.checkbox-input:has(#field-test) input').check()
|
||||||
await page.locator('#action-save').click()
|
await saveDocAndAssert(page)
|
||||||
|
|
||||||
await openNav(page)
|
await openNav(page)
|
||||||
|
|
||||||
@@ -299,8 +302,7 @@ describe('access control', () => {
|
|||||||
const documentDrawer = page.locator('[id^=doc-drawer_user-restricted_1_]')
|
const documentDrawer = page.locator('[id^=doc-drawer_user-restricted_1_]')
|
||||||
await expect(documentDrawer).toBeVisible()
|
await expect(documentDrawer).toBeVisible()
|
||||||
await documentDrawer.locator('#field-name').fill('anonymous@email.com')
|
await documentDrawer.locator('#field-name').fill('anonymous@email.com')
|
||||||
await documentDrawer.locator('#action-save').click()
|
await saveDocAndAssert(page)
|
||||||
await expect(page.locator('.Toastify')).toContainText('successfully')
|
|
||||||
|
|
||||||
// ensure user is not allowed to edit this document
|
// ensure user is not allowed to edit this document
|
||||||
await expect(documentDrawer.locator('#field-name')).toBeDisabled()
|
await expect(documentDrawer.locator('#field-name')).toBeDisabled()
|
||||||
@@ -311,8 +313,7 @@ describe('access control', () => {
|
|||||||
const documentDrawer2 = page.locator('[id^=doc-drawer_user-restricted_1_]')
|
const documentDrawer2 = page.locator('[id^=doc-drawer_user-restricted_1_]')
|
||||||
await expect(documentDrawer2).toBeVisible()
|
await expect(documentDrawer2).toBeVisible()
|
||||||
await documentDrawer2.locator('#field-name').fill('dev@payloadcms.com')
|
await documentDrawer2.locator('#field-name').fill('dev@payloadcms.com')
|
||||||
await documentDrawer2.locator('#action-save').click()
|
await saveDocAndAssert(page)
|
||||||
await expect(page.locator('.Toastify')).toContainText('successfully')
|
|
||||||
|
|
||||||
// ensure user is allowed to edit this document
|
// ensure user is allowed to edit this document
|
||||||
await expect(documentDrawer2.locator('#field-name')).toBeEnabled()
|
await expect(documentDrawer2.locator('#field-name')).toBeEnabled()
|
||||||
|
|||||||
@@ -1386,7 +1386,8 @@ describe('fields', () => {
|
|||||||
await expect(dateField).toBeVisible()
|
await expect(dateField).toBeVisible()
|
||||||
await dateField.fill('02/07/2023')
|
await dateField.fill('02/07/2023')
|
||||||
await expect(dateField).toHaveValue('02/07/2023')
|
await expect(dateField).toHaveValue('02/07/2023')
|
||||||
await page.locator('#action-save').click()
|
await saveDocAndAssert(page)
|
||||||
|
|
||||||
const clearButton = page.locator('#field-default .date-time-picker__clear-button')
|
const clearButton = page.locator('#field-default .date-time-picker__clear-button')
|
||||||
await expect(clearButton).toBeVisible()
|
await expect(clearButton).toBeVisible()
|
||||||
await clearButton.click()
|
await clearButton.click()
|
||||||
@@ -1409,10 +1410,7 @@ describe('fields', () => {
|
|||||||
|
|
||||||
// enter date in default date field
|
// enter date in default date field
|
||||||
await dateField.fill('02/07/2023')
|
await dateField.fill('02/07/2023')
|
||||||
await page.locator('#action-save').click()
|
await saveDocAndAssert(page)
|
||||||
|
|
||||||
// wait for navigation to update route
|
|
||||||
await expect.poll(() => page.url(), { timeout: 1000 }).not.toContain('create')
|
|
||||||
|
|
||||||
// get the ID of the doc
|
// get the ID of the doc
|
||||||
const routeSegments = page.url().split('/')
|
const routeSegments = page.url().split('/')
|
||||||
@@ -1473,10 +1471,7 @@ describe('fields', () => {
|
|||||||
|
|
||||||
// enter date in default date field
|
// enter date in default date field
|
||||||
await dateField.fill('02/07/2023')
|
await dateField.fill('02/07/2023')
|
||||||
await page.locator('#action-save').click()
|
await saveDocAndAssert(page)
|
||||||
|
|
||||||
// wait for navigation to update route
|
|
||||||
await expect.poll(() => page.url(), { timeout: 1000 }).not.toContain('create')
|
|
||||||
|
|
||||||
// get the ID of the doc
|
// get the ID of the doc
|
||||||
const routeSegments = page.url().split('/')
|
const routeSegments = page.url().split('/')
|
||||||
|
|||||||
Reference in New Issue
Block a user