test: removes all unnecessary page.waitForURL methods (#11412)

Removes all unnecessary `page.waitForURL` methods within e2e tests.
These are unneeded when following a `page.goto` call because the
subsequent page load is already being awaited.

It is only a requirement when:

- Clicking a link and expecting navigation
- Expecting a redirect after a route change
- Waiting for a change in search params
This commit is contained in:
Jacob Fletcher
2025-02-26 16:54:39 -05:00
committed by GitHub
parent b540da53ec
commit b975858e76
22 changed files with 31 additions and 134 deletions

View File

@@ -232,16 +232,14 @@ describe('Access Control', () => {
test('ensure complex collection config fields show up in correct read-only state', async () => {
const regression1URL = new AdminUrlUtil(serverURL, 'regression1')
await page.goto(regression1URL.list)
// Click on first card
await page.locator('.cell-id a').first().click()
// wait for url
await page.waitForURL(`**/collections/regression1/**`)
await ensureRegression1FieldsHaveCorrectAccess()
// Edit any field
await page.locator('#field-group1__text').fill('test!')
// Save the doc
await saveDocAndAssert(page)
await wait(1000)
// Ensure fields still have the correct readOnly state. When saving the document, permissions are re-evaluated
@@ -278,18 +276,17 @@ describe('Access Control', () => {
test('ensure complex collection config fields show up in correct read-only state 2', async () => {
const regression2URL = new AdminUrlUtil(serverURL, 'regression2')
await page.goto(regression2URL.list)
// Click on first card
await page.locator('.cell-id a').first().click()
// wait for url
await page.waitForURL(`**/collections/regression2/**`)
await ensureRegression2FieldsHaveCorrectAccess()
// Edit any field
await page.locator('#field-group__text').fill('test!')
// Save the doc
await saveDocAndAssert(page)
await wait(1000)
// Ensure fields still have the correct readOnly state. When saving the document, permissions are re-evaluated
await ensureRegression2FieldsHaveCorrectAccess()
})
@@ -407,7 +404,6 @@ describe('Access Control', () => {
test('should not show edit button', async () => {
const createNotUpdateURL = new AdminUrlUtil(serverURL, createNotUpdateCollectionSlug)
await page.goto(createNotUpdateURL.create)
await page.waitForURL(createNotUpdateURL.create)
await expect(page.locator('#field-name')).toBeVisible()
await page.locator('#field-name').fill('name')
await expect(page.locator('#field-name')).toHaveValue('name')
@@ -450,7 +446,6 @@ describe('Access Control', () => {
test('should not show edit button', async () => {
const createNotUpdateURL = new AdminUrlUtil(serverURL, readNotUpdateGlobalSlug)
await page.goto(createNotUpdateURL.global(readNotUpdateGlobalSlug))
await page.waitForURL(createNotUpdateURL.global(readNotUpdateGlobalSlug))
await expect(page.locator('#field-name')).toBeVisible()
await expect(page.locator('#field-name')).toBeDisabled()
await expect(page.locator('#action-save')).toBeHidden()
@@ -513,7 +508,6 @@ describe('Access Control', () => {
describe('global', () => {
test('should restrict update access based on document field', async () => {
await page.goto(userRestrictedGlobalURL.global(userRestrictedGlobalSlug))
await page.waitForURL(userRestrictedGlobalURL.global(userRestrictedGlobalSlug))
await expect(page.locator('#field-name')).toBeVisible()
await expect(page.locator('#field-name')).toHaveValue(devUser.email)
await expect(page.locator('#field-name')).toBeEnabled()
@@ -531,7 +525,6 @@ describe('Access Control', () => {
})
await page.goto(userRestrictedGlobalURL.global(userRestrictedGlobalSlug))
await page.waitForURL(userRestrictedGlobalURL.global(userRestrictedGlobalSlug))
await expect(page.locator('#field-name')).toBeDisabled()
await expect(page.locator('#action-save')).toBeHidden()
})
@@ -620,7 +613,6 @@ describe('Access Control', () => {
describe('admin access', () => {
test('unauthenticated users should not have access to the admin panel', async () => {
await page.goto(url.logout)
await page.waitForURL(url.logout)
await expect(page.locator('.payload-toast-container')).toContainText(
'You have been logged out successfully.',
@@ -629,13 +621,15 @@ describe('Access Control', () => {
await expect(page.locator('form.login__form')).toBeVisible()
await page.goto(url.admin)
// wait for redirect to login
await page.waitForURL(url.login)
expect(page.url()).toEqual(url.login)
})
test('non-admin users should not have access to the admin panel', async () => {
await page.goto(url.logout)
await page.waitForURL(url.logout)
await login({
data: {
@@ -651,7 +645,6 @@ describe('Access Control', () => {
)
await page.goto(url.logout)
await page.waitForURL(url.logout)
await expect(page.locator('.payload-toast-container')).toContainText(
'You have been logged out successfully.',
@@ -662,7 +655,6 @@ describe('Access Control', () => {
test('public users should not have access to access admin', async () => {
await page.goto(url.logout)
await page.waitForURL(url.logout)
const user = await payload.login({
collection: publicUsersSlug,
@@ -686,6 +678,8 @@ describe('Access Control', () => {
await page.reload()
await page.goto(url.admin)
// await for redirect to unauthorized
await page.waitForURL(/unauthorized$/)
await expect(page.locator('.unauthorized .form-header h1')).toHaveText(
@@ -693,7 +687,6 @@ describe('Access Control', () => {
)
await page.goto(url.logout)
await page.waitForURL(url.logout)
await expect(page.locator('.payload-toast-container')).toContainText(
'You have been logged out successfully.',