diff --git a/test/access-control/e2e.spec.ts b/test/access-control/e2e.spec.ts index 90edf52996..006f94542f 100644 --- a/test/access-control/e2e.spec.ts +++ b/test/access-control/e2e.spec.ts @@ -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.', diff --git a/test/admin/e2e/document-view/e2e.spec.ts b/test/admin/e2e/document-view/e2e.spec.ts index b4b92ee806..08dd762143 100644 --- a/test/admin/e2e/document-view/e2e.spec.ts +++ b/test/admin/e2e/document-view/e2e.spec.ts @@ -146,7 +146,6 @@ describe('Document View', () => { test('collection — should render preview button when `admin.preview` is set', async () => { const collectionWithPreview = new AdminUrlUtil(serverURL, postsCollectionSlug) await page.goto(collectionWithPreview.create) - await page.waitForURL(collectionWithPreview.create) await page.locator('#field-title').fill(title) await saveDocAndAssert(page) await expect(page.locator('.btn.preview-btn')).toBeVisible() @@ -155,7 +154,6 @@ describe('Document View', () => { test('collection — should not render preview button when `admin.preview` is not set', async () => { const collectionWithoutPreview = new AdminUrlUtil(serverURL, group1Collection1Slug) await page.goto(collectionWithoutPreview.create) - await page.waitForURL(collectionWithoutPreview.create) await page.locator('#field-title').fill(title) await saveDocAndAssert(page) await expect(page.locator('.btn.preview-btn')).toBeHidden() @@ -222,7 +220,6 @@ describe('Document View', () => { const { id } = await createPost() const postURL = postsUrl.edit(id) await page.goto(postURL) - await page.waitForURL(postURL) await wait(500) await page.locator('#field-title')?.fill('') await expect(page.locator('.doc-header__title.render-title:has-text("ID:")')).toBeVisible() @@ -231,7 +228,6 @@ describe('Document View', () => { test('global — should render custom, localized label', async () => { await page.goto(globalURL.global(globalSlug)) - await page.waitForURL(globalURL.global(globalSlug)) await openNav(page) const label = 'My Global Label' const globalLabel = page.locator(`#nav-global-global`) @@ -247,7 +243,6 @@ describe('Document View', () => { test('global — should render simple label strings', async () => { await page.goto(postsUrl.admin) - await page.waitForURL(postsUrl.admin) await openNav(page) const label = 'Group Globals 1' const globalLabel = page.locator(`#nav-global-group-globals-one`) @@ -259,7 +254,6 @@ describe('Document View', () => { test('global — should render slug in sentence case as fallback', async () => { await page.goto(postsUrl.admin) - await page.waitForURL(postsUrl.admin) await openNav(page) const label = 'Group Globals Two' const globalLabel = page.locator(`#nav-global-group-globals-two`) @@ -311,7 +305,6 @@ describe('Document View', () => { const customNestedTabViewURL = `${pageURL}${customNestedTabViewPath}` await page.goto(customNestedTabViewURL) - await page.waitForURL(customNestedTabViewURL) await expect(page.locator('h1#custom-view-title')).toContainText(customNestedTabViewTitle) }) @@ -385,7 +378,6 @@ describe('Document View', () => { describe('descriptions', () => { test('should render tab admin description', async () => { await page.goto(postsUrl.create) - await page.waitForURL(postsUrl.create) const tabsContent = page.locator('.tabs-field__content-wrap') await expect(tabsContent.locator('.field-description')).toHaveText(customTabAdminDescription) @@ -393,7 +385,6 @@ describe('Document View', () => { test('should render tab admin description as a translation function', async () => { await page.goto(postsUrl.create) - await page.waitForURL(postsUrl.create) const secondTab = page.locator('.tabs-field__tab-button').nth(1) await secondTab.click() @@ -410,27 +401,23 @@ describe('Document View', () => { describe('custom fields', () => { test('should render custom field component', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await expect(page.locator('#field-customTextClientField')).toBeVisible() }) test('renders custom label component', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await expect(page.locator('#custom-client-field-label')).toBeVisible() await expect(page.locator('#custom-server-field-label')).toBeVisible() }) test('renders custom field description text', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await expect(page.locator('#custom-client-field-description')).toBeVisible() await expect(page.locator('#custom-server-field-description')).toBeVisible() }) test('custom server components should receive field props', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await expect( page.locator('#custom-server-field-label', { hasText: exactText('Label: the max length of this field is: 100'), @@ -446,12 +433,13 @@ describe('Document View', () => { test('custom client components should receive field props', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) + await expect( page.locator('#custom-client-field-label', { hasText: exactText('Label: the max length of this field is: 100'), }), ).toBeVisible() + await expect( page.locator('#custom-client-field-description', { hasText: exactText('Description: the max length of this field is: 100'), @@ -461,7 +449,6 @@ describe('Document View', () => { test('custom select input can have its value cleared', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await expect(page.locator('#field-customSelectInput')).toBeVisible() await page.locator('#field-customSelectInput .rs__control').click() @@ -480,7 +467,7 @@ describe('Document View', () => { describe('field descriptions', () => { test('should render static field description', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) + await expect(page.locator('.field-description-descriptionAsString')).toContainText( 'Static field description.', ) @@ -488,7 +475,6 @@ describe('Document View', () => { test('should render functional field description', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await page.locator('#field-descriptionAsFunction').fill('functional') await expect(page.locator('.field-description-descriptionAsFunction')).toContainText( 'Function description', @@ -498,7 +484,6 @@ describe('Document View', () => { test('should render component field description', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await page.locator('#field-descriptionAsComponent').fill('component') await expect(page.locator('.field-description-descriptionAsComponent')).toContainText( 'Component description: descriptionAsComponent - component', @@ -507,7 +492,6 @@ describe('Document View', () => { test('should render custom error component', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) const input = page.locator('input[id="field-customTextClientField"]') await input.fill('ab') await expect(input).toHaveValue('ab') @@ -539,7 +523,6 @@ describe('Document View', () => { describe('select field', () => { test('should render custom select options', async () => { await page.goto(customFieldsURL.create) - await page.waitForURL(customFieldsURL.create) await page.locator('#field-customSelectField .rs__control').click() await expect(page.locator('#field-customSelectField .rs__option')).toHaveCount(2) }) diff --git a/test/admin/e2e/general/e2e.spec.ts b/test/admin/e2e/general/e2e.spec.ts index ec77d11e64..44139d1927 100644 --- a/test/admin/e2e/general/e2e.spec.ts +++ b/test/admin/e2e/general/e2e.spec.ts @@ -521,6 +521,8 @@ describe('General', () => { test('should render protected nested custom view', async () => { await page.goto(`${serverURL}${adminRoutes.routes.admin}${protectedCustomNestedViewPath}`) + + // wait for redirect to unauthorized page await page.waitForURL(`**${adminRoutes.routes.admin}/unauthorized`) await expect(page.locator('.unauthorized')).toBeVisible() diff --git a/test/admin/e2e/list-view/e2e.spec.ts b/test/admin/e2e/list-view/e2e.spec.ts index 30c6490b78..2e063210e7 100644 --- a/test/admin/e2e/list-view/e2e.spec.ts +++ b/test/admin/e2e/list-view/e2e.spec.ts @@ -100,7 +100,6 @@ describe('List View', () => { // delete all posts created by the seed await deleteAllPosts() await page.goto(postsUrl.list) - await page.waitForURL((url) => url.toString().startsWith(postsUrl.list)) await expect(page.locator(tableRowLocator)).toBeHidden() await createPost({ title: 'post1' }) @@ -245,7 +244,6 @@ describe('List View', () => { // prefill search with "a" from the query param await page.goto(`${postsUrl.list}?search=dennis`) - await page.waitForURL(new RegExp(`${postsUrl.list}\\?search=dennis`)) // input should be filled out, list should filter await expect(page.locator('.search-filter__input')).toHaveValue('dennis') @@ -256,7 +254,6 @@ describe('List View', () => { const { id } = await createPost() const url = `${postsUrl.list}?limit=10&page=1&search=${id}` await page.goto(url) - await page.waitForURL(url) const tableItems = page.locator(tableRowLocator) await expect(tableItems).toHaveCount(1) }) @@ -265,7 +262,6 @@ describe('List View', () => { const { id } = await createGeo() const url = `${geoUrl.list}?limit=10&page=1&search=${id}` await page.goto(url) - await page.waitForURL(url) const tableItems = page.locator(tableRowLocator) await expect(tableItems).toHaveCount(1) }) @@ -286,7 +282,6 @@ describe('List View', () => { test('search should persist through browser back button', async () => { const url = `${postsUrl.list}?limit=10&page=1&search=post1` await page.goto(url) - await page.waitForURL(url) await expect(page.locator('#search-filter-input')).toHaveValue('post1') await goToFirstCell(page, postsUrl) await page.goBack() @@ -297,7 +292,6 @@ describe('List View', () => { test('search should not persist between navigation', async () => { const url = `${postsUrl.list}?limit=10&page=1&search=test` await page.goto(url) - await page.waitForURL(url) await expect(page.locator('#search-filter-input')).toHaveValue('test') @@ -306,7 +300,6 @@ describe('List View', () => { const uploadsUrl = await page.locator('#nav-uploads').getAttribute('href') await page.goto(serverURL + uploadsUrl) - await page.waitForURL(serverURL + uploadsUrl) await expect(page.locator('#search-filter-input')).toHaveValue('') }) @@ -339,7 +332,6 @@ describe('List View', () => { test('should respect base list filters', async () => { await page.goto(baseListFiltersUrl.list) - await page.waitForURL((url) => url.toString().startsWith(baseListFiltersUrl.list)) await expect(page.locator(tableRowLocator)).toHaveCount(1) }) diff --git a/test/auth/e2e.spec.ts b/test/auth/e2e.spec.ts index c3c2b3ea6f..02253074d5 100644 --- a/test/auth/e2e.spec.ts +++ b/test/auth/e2e.spec.ts @@ -188,7 +188,6 @@ describe('Auth', () => { test('should have up-to-date user in `useAuth` hook', async () => { await page.goto(url.account) - await page.waitForURL(url.account) await expect(page.locator('#users-api-result')).toHaveText('Hello, world!') await expect(page.locator('#use-auth-result')).toHaveText('Hello, world!') const field = page.locator('#field-custom') diff --git a/test/fields-relationship/e2e.spec.ts b/test/fields-relationship/e2e.spec.ts index 56f1802a6b..b68204071a 100644 --- a/test/fields-relationship/e2e.spec.ts +++ b/test/fields-relationship/e2e.spec.ts @@ -494,7 +494,6 @@ describe('Relationship Field', () => { test.skip('should open document drawer from read-only relationships', async () => { const editURL = url.edit(docWithExistingRelations.id) await page.goto(editURL) - await page.waitForURL(editURL) await openDocDrawer( page, diff --git a/test/fields/collections/Date/e2e.spec.ts b/test/fields/collections/Date/e2e.spec.ts index bc86060e4e..773d91a169 100644 --- a/test/fields/collections/Date/e2e.spec.ts +++ b/test/fields/collections/Date/e2e.spec.ts @@ -122,7 +122,6 @@ describe('Date', () => { }) test('create EST day only date', async () => { await page.goto(url.create) - await page.waitForURL(`**/${url.create}`) const dateField = page.locator('#field-default input') // enter date in default date field @@ -167,7 +166,6 @@ describe('Date', () => { test('create PDT day only date', async () => { await page.goto(url.create) - await page.waitForURL(`**/${url.create}`) const dateField = page.locator('#field-default input') // enter date in default date field @@ -212,7 +210,6 @@ describe('Date', () => { test('create ST day only date', async () => { await page.goto(url.create) - await page.waitForURL(`**/${url.create}`) const dateField = page.locator('#field-default input') // enter date in default date field diff --git a/test/fields/collections/Indexed/e2e.spec.ts b/test/fields/collections/Indexed/e2e.spec.ts index 0e64af60cf..73cf008cd8 100644 --- a/test/fields/collections/Indexed/e2e.spec.ts +++ b/test/fields/collections/Indexed/e2e.spec.ts @@ -85,7 +85,6 @@ describe('Radio', () => { }) await page.goto(url.create) - await page.waitForURL(url.create) await page.locator('#field-text').fill('test') await page.locator('#field-uniqueText').fill(uniqueText) diff --git a/test/fields/collections/JSON/e2e.spec.ts b/test/fields/collections/JSON/e2e.spec.ts index feafa0e053..f920534bc4 100644 --- a/test/fields/collections/JSON/e2e.spec.ts +++ b/test/fields/collections/JSON/e2e.spec.ts @@ -73,7 +73,6 @@ describe('JSON', () => { test('should create', async () => { const input = '{"foo": "bar"}' await page.goto(url.create) - await page.waitForURL(url.create) const jsonCodeEditor = page.locator('.json-field .code-editor').first() await expect(() => expect(jsonCodeEditor).toBeVisible()).toPass({ timeout: POLL_TOPASS_TIMEOUT, @@ -90,7 +89,6 @@ describe('JSON', () => { const input = '{"foo.with.periods": "bar"}' await page.goto(url.create) - await page.waitForURL(url.create) const jsonCodeEditor = page.locator('.group-field .json-field .code-editor').first() await expect(() => expect(jsonCodeEditor).toBeVisible()).toPass({ timeout: POLL_TOPASS_TIMEOUT, diff --git a/test/fields/collections/Point/e2e.spec.ts b/test/fields/collections/Point/e2e.spec.ts index c5f3dc3551..4a26a50094 100644 --- a/test/fields/collections/Point/e2e.spec.ts +++ b/test/fields/collections/Point/e2e.spec.ts @@ -113,7 +113,6 @@ describe('Point', () => { test('should update point', async () => { await page.goto(url.edit(emptyGroupPoint.id)) - await page.waitForURL(`**/${emptyGroupPoint.id}`) const longField = page.locator('#field-longitude-point') await longField.fill('9') @@ -144,7 +143,6 @@ describe('Point', () => { test('should be able to clear a value point', async () => { await page.goto(url.edit(filledGroupPoint.id)) - await page.waitForURL(`**/${filledGroupPoint.id}`) const groupLongitude = page.locator('#field-longitude-group__point') await groupLongitude.fill('') diff --git a/test/fields/collections/Relationship/e2e.spec.ts b/test/fields/collections/Relationship/e2e.spec.ts index 3564ec7268..34bbfadfa6 100644 --- a/test/fields/collections/Relationship/e2e.spec.ts +++ b/test/fields/collections/Relationship/e2e.spec.ts @@ -98,7 +98,7 @@ describe('relationship', () => { test('should create nested inline relationships', async () => { await page.goto(url.create) - await page.waitForURL(`**/${url.create}`) + // Open first modal await openCreateDocDrawer(page, '#field-relationToSelf') @@ -157,29 +157,36 @@ describe('relationship', () => { test('should hide relationship add new button', async () => { await page.goto(url.create) - await page.waitForURL(url.create) + const locator1 = page.locator( '#relationWithAllowEditToFalse-add-new .relationship-add-new__add-button', ) + await expect(locator1).toHaveCount(1) + // expect the button to not exist in the field const locator2 = page.locator( '#relationWithAllowCreateToFalse-add-new .relationship-add-new__add-button', ) + await expect(locator2).toHaveCount(0) }) test('should hide relationship edit button', async () => { await page.goto(url.create) - await page.waitForURL(url.create) + const locator1 = page .locator('#field-relationWithAllowEditToFalse') .getByLabel('Edit dev@payloadcms.com') + await expect(locator1).toHaveCount(0) + const locator2 = page .locator('#field-relationWithAllowCreateToFalse') .getByLabel('Edit dev@payloadcms.com') + await expect(locator2).toHaveCount(1) + // The reason why I check for locator 1 again is that I've noticed that sometimes // the default value does not appear after the first locator is tested. IDK why. await expect(locator1).toHaveCount(0) @@ -235,7 +242,6 @@ describe('relationship', () => { // TODO: React-Select not loading things sometimes. Fix later test.skip('should display `hasMany` polymorphic relationships', async () => { await page.goto(url.create) - await page.waitForURL(url.create) const field = page.locator('#field-relationHasManyPolymorphic') await field.click() @@ -271,7 +277,6 @@ describe('relationship', () => { test('should populate relationship dynamic default value', async () => { await page.goto(url.create) - await page.waitForURL(url.create) await expect( page.locator('#field-relationWithDynamicDefault .relationship--single-value__text'), ).toContainText('dev@payloadcms.com') @@ -291,7 +296,7 @@ describe('relationship', () => { // Related issue: https://github.com/payloadcms/payload/issues/2815 test('should edit document in relationship drawer', async () => { await page.goto(url.create) - await page.waitForURL(`**/${url.create}`) + // First fill out the relationship field, as it's required await openCreateDocDrawer(page, '#field-relationship') await page @@ -578,7 +583,7 @@ describe('relationship', () => { test('should fail min rows validation when rows are present', async () => { await page.goto(url.create) - await page.waitForURL(url.create) + // First fill out the relationship field, as it's required await openCreateDocDrawer(page, '#field-relationship') await page.locator('#field-relationship .value-container').click() @@ -601,7 +606,6 @@ describe('relationship', () => { test('should sort relationship options by sortOptions property (ID in ascending order)', async () => { await page.goto(url.create) - await page.waitForURL(url.create) const field = page.locator('#field-relationship') await field.click() @@ -615,7 +619,6 @@ describe('relationship', () => { test('should sort relationHasManyPolymorphic options by sortOptions property: text-fields collection (items in descending order)', async () => { await page.goto(url.create) - await page.waitForURL(url.create) const field = page.locator('#field-relationHasManyPolymorphic') @@ -637,7 +640,6 @@ describe('relationship', () => { await createRelationshipFieldDoc({ value: textDoc.id, relationTo: 'text-fields' }) await page.goto(url.list) - await page.waitForURL(new RegExp(url.list)) await addListFilter({ page, diff --git a/test/fields/collections/RichText/e2e.spec.ts b/test/fields/collections/RichText/e2e.spec.ts index 299aa308cf..ac5afdaafe 100644 --- a/test/fields/collections/RichText/e2e.spec.ts +++ b/test/fields/collections/RichText/e2e.spec.ts @@ -60,7 +60,6 @@ describe('Rich Text', () => { async function navigateToRichTextFields() { const url: AdminUrlUtil = new AdminUrlUtil(serverURL, 'rich-text-fields') await page.goto(url.list) - await page.waitForURL('**' + url.list + '**') const linkToDoc = page.locator('.row-1 .cell-title a').first() await expect(() => expect(linkToDoc).toBeTruthy()).toPass({ timeout: POLL_TOPASS_TIMEOUT }) diff --git a/test/fields/collections/Tabs/e2e.spec.ts b/test/fields/collections/Tabs/e2e.spec.ts index 0e59d50c35..4e55fa5261 100644 --- a/test/fields/collections/Tabs/e2e.spec.ts +++ b/test/fields/collections/Tabs/e2e.spec.ts @@ -73,7 +73,6 @@ describe('Tabs', () => { const jsonValue = '{ "foo": "bar"}' await page.goto(url.create) - await page.waitForURL(url.create) await switchTab(page, '.tabs-field__tab-button:has-text("Tab with Row")') await page.locator('#field-textInRow').fill(textInRowValue) diff --git a/test/helpers.ts b/test/helpers.ts index 11e4967404..3ee90344e2 100644 --- a/test/helpers.ts +++ b/test/helpers.ts @@ -103,6 +103,7 @@ export async function ensureCompilationIsDone({ ) await page.goto(adminURL) + await page.waitForURL( readyURL ?? (noAutoLogin ? `${adminURL + (adminURL.endsWith('/') ? '' : '/')}login` : adminURL), @@ -205,7 +206,6 @@ export async function login(args: LoginArgs): Promise { }) await page.goto(loginRoute) - await page.waitForURL(loginRoute) await wait(500) await page.fill('#field-email', data.email) await page.fill('#field-password', data.password) diff --git a/test/helpers/e2e/navigateToDoc.ts b/test/helpers/e2e/navigateToDoc.ts index 0c2cdda702..f2484802b8 100644 --- a/test/helpers/e2e/navigateToDoc.ts +++ b/test/helpers/e2e/navigateToDoc.ts @@ -5,11 +5,11 @@ export const goToFirstCell = async (page: Page, urlUtil: AdminUrlUtil) => { const cellLink = page.locator(`tbody tr:first-child td a`).first() const linkURL = await cellLink.getAttribute('href') await page.goto(`${urlUtil.serverURL}${linkURL}`) - await page.waitForURL(`**${linkURL}`) } export const navigateToDoc = async (page: Page, urlUtil: AdminUrlUtil) => { await page.goto(urlUtil.list) + // wait for query params to arrive const regex = new RegExp(`^${urlUtil.list}(?:\\?.*)?$`) await page.waitForURL(regex) await goToFirstCell(page, urlUtil) diff --git a/test/i18n/e2e.spec.ts b/test/i18n/e2e.spec.ts index c2373eb475..8880a8ec05 100644 --- a/test/i18n/e2e.spec.ts +++ b/test/i18n/e2e.spec.ts @@ -49,7 +49,6 @@ describe('i18n', () => { test('ensure i18n labels and useTranslation hooks display correct translation', async () => { await page.goto(serverURL + '/admin') - await page.waitForURL(serverURL + '/admin') await expect( page.locator('.componentWithDefaultI18n .componentWithDefaultI18nValidT'), diff --git a/test/live-preview/e2e.spec.ts b/test/live-preview/e2e.spec.ts index 0f08d8f6ca..300f531f82 100644 --- a/test/live-preview/e2e.spec.ts +++ b/test/live-preview/e2e.spec.ts @@ -2,6 +2,7 @@ import type { Page } from '@playwright/test' import { expect, test } from '@playwright/test' import path from 'path' +import { wait } from 'payload/shared' import { fileURLToPath } from 'url' import { @@ -32,7 +33,6 @@ import { ssrAutosavePagesSlug, ssrPagesSlug, } from './shared.js' -import { wait } from 'payload/shared' const filename = fileURLToPath(import.meta.url) const dirname = path.dirname(filename) @@ -210,7 +210,6 @@ describe('Live Preview', () => { test('global — has tab', async () => { const global = new AdminUrlUtil(serverURL, 'header') await page.goto(global.global('header')) - await page.waitForURL(global.global('header')) const docURL = page.url() const pathname = new URL(docURL).pathname @@ -248,7 +247,6 @@ describe('Live Preview', () => { test('device — properly measures size', async () => { await page.goto(pagesURLUtil.create) - await page.waitForURL(pagesURLUtil.create) await page.locator('#field-title').fill('Title 3') await page.locator('#field-slug').fill('slug-3') @@ -297,7 +295,6 @@ describe('Live Preview', () => { test('device — resizes to specified breakpoint', async () => { await page.goto(pagesURLUtil.create) - await page.waitForURL(pagesURLUtil.create) await page.locator('#field-title').fill('Title 4') await page.locator('#field-slug').fill('slug-4') diff --git a/test/live-preview/helpers.ts b/test/live-preview/helpers.ts index 792ab1e81e..fff96c9065 100644 --- a/test/live-preview/helpers.ts +++ b/test/live-preview/helpers.ts @@ -13,7 +13,6 @@ export const goToCollectionLivePreview = async ( ): Promise => { await navigateToDoc(page, urlUtil) await page.goto(`${page.url()}/preview`) - await page.waitForURL(`**/preview`) } export const goToGlobalLivePreview = async ( @@ -24,7 +23,6 @@ export const goToGlobalLivePreview = async ( const global = new AdminUrlUtil(serverURL, slug) const previewURL = `${global.global(slug)}/preview` await page.goto(previewURL) - await page.waitForURL(previewURL) } export const selectLivePreviewBreakpoint = async (page: Page, breakpointLabel: string) => { diff --git a/test/localization/e2e.spec.ts b/test/localization/e2e.spec.ts index c2403318b2..69be0abd5e 100644 --- a/test/localization/e2e.spec.ts +++ b/test/localization/e2e.spec.ts @@ -246,7 +246,6 @@ describe('Localization', () => { }) await page.goto(url.edit(id)) - await page.waitForURL(`**${url.edit(id)}`) await openDocControls(page) await page.locator('#action-duplicate').click() await expect(page.locator('.payload-toast-container')).toContainText('successfully') @@ -262,7 +261,6 @@ describe('Localization', () => { test('should duplicate localized checkbox correctly', async () => { await page.goto(url.create) - await page.waitForURL(url.create) await changeLocale(page, defaultLocale) await fillValues({ description, title: englishTitle }) await page.locator('#field-localizedCheckbox').click() @@ -329,9 +327,9 @@ describe('Localization', () => { await page.goto(url.list) - const localeLabel = page - .locator('.localizer.app-header__localizer .localizer-button__current-label') - + const localeLabel = page.locator( + '.localizer.app-header__localizer .localizer-button__current-label', + ) await expect(localeLabel).not.toHaveText('English') }) diff --git a/test/locked-documents/e2e.spec.ts b/test/locked-documents/e2e.spec.ts index 1c1f61c554..eb76472634 100644 --- a/test/locked-documents/e2e.spec.ts +++ b/test/locked-documents/e2e.spec.ts @@ -179,21 +179,18 @@ describe('Locked Documents', () => { test('should show lock icon on document row if locked', async () => { await page.goto(postsUrl.list) - await page.waitForURL(new RegExp(postsUrl.list)) await expect(page.locator('.table .row-2 .locked svg')).toBeVisible() }) test('should not show lock icon on document row if unlocked', async () => { await page.goto(postsUrl.list) - await page.waitForURL(new RegExp(postsUrl.list)) await expect(page.locator('.table .row-3 .checkbox-input__input')).toBeVisible() }) test('should not show lock icon on document if expired', async () => { await page.goto(testsUrl.list) - await page.waitForURL(new RegExp(testsUrl.list)) // Need to wait for lock duration to expire (lockDuration: 5 seconds) // eslint-disable-next-line payload/no-wait-function @@ -206,7 +203,6 @@ describe('Locked Documents', () => { test('should not show lock icon on document row if locked by current user', async () => { await page.goto(postsUrl.edit(anotherPostDoc.id)) - await page.waitForURL(postsUrl.edit(anotherPostDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('testing') @@ -214,7 +210,6 @@ describe('Locked Documents', () => { await page.reload() await page.goto(postsUrl.list) - await page.waitForURL(new RegExp(postsUrl.list)) await expect(page.locator('.table .row-1 .checkbox-input__input')).toBeVisible() }) @@ -238,7 +233,6 @@ describe('Locked Documents', () => { await page.reload() await page.goto(postsUrl.list) - await page.waitForURL(new RegExp(postsUrl.list)) await page.locator('input#select-all').check() await page.locator('.list-selection .list-selection__button').click() @@ -284,7 +278,6 @@ describe('Locked Documents', () => { test('should only allow bulk edit on unlocked documents on all pages', async () => { await page.goto(postsUrl.list) - await page.waitForURL(new RegExp(postsUrl.list)) const bulkText = 'Bulk update title' @@ -441,7 +434,6 @@ describe('Locked Documents', () => { test('should delete all expired locked documents upon initial editing of unlocked document', async () => { await page.goto(testsUrl.list) - await page.waitForURL(new RegExp(testsUrl.list)) await expect(page.locator('.table .row-2 .locked svg')).toBeVisible() await expect(page.locator('.table .row-3 .locked svg')).toBeVisible() @@ -462,7 +454,6 @@ describe('Locked Documents', () => { expect(lockedTestDocs.docs.length).toBe(2) await page.goto(testsUrl.edit(testDoc.id)) - await page.waitForURL(testsUrl.edit(testDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('some test doc') @@ -480,7 +471,6 @@ describe('Locked Documents', () => { test('should lock document upon initial editing of unlocked document', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('hello world') @@ -502,7 +492,6 @@ describe('Locked Documents', () => { test('should unlock document on save / publish', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('hello world') @@ -540,7 +529,6 @@ describe('Locked Documents', () => { test('should keep document locked when navigating to other tabs i.e. api', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('testing tab navigation...') @@ -594,7 +582,6 @@ describe('Locked Documents', () => { test('should unlock document on navigate away', async () => { await page.goto(postsUrl.edit(postDocTwo.id)) - await page.waitForURL(postsUrl.edit(postDocTwo.id)) const textInput = page.locator('#field-text') await textInput.fill('hello world') @@ -727,13 +714,11 @@ describe('Locked Documents', () => { test('should show Document Locked modal for incoming user when entering locked document', async () => { await page.goto(postsUrl.list) - await page.waitForURL(new RegExp(postsUrl.list)) // eslint-disable-next-line payload/no-wait-function await wait(500) await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const modalContainer = page.locator('.payload__modal-container') await expect(modalContainer).toBeVisible() @@ -746,7 +731,6 @@ describe('Locked Documents', () => { test('should not show Document Locked modal for incoming user when entering expired locked document', async () => { await page.goto(testsUrl.list) - await page.waitForURL(new RegExp(testsUrl.list)) // Need to wait for lock duration to expire (lockDuration: 5 seconds) // eslint-disable-next-line payload/no-wait-function @@ -755,7 +739,6 @@ describe('Locked Documents', () => { await page.reload() await page.goto(testsUrl.edit(expiredTestDoc.id)) - await page.waitForURL(testsUrl.edit(expiredTestDoc.id)) const modalContainer = page.locator('.payload__modal-container') await expect(modalContainer).toBeHidden() @@ -763,7 +746,6 @@ describe('Locked Documents', () => { test('should show fields in read-only if incoming user views locked doc in read-only mode', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const modalContainer = page.locator('.payload__modal-container') await expect(modalContainer).toBeVisible() @@ -835,7 +817,6 @@ describe('Locked Documents', () => { test('should update user data if incoming user takes over from document modal', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const modalContainer = page.locator('.payload__modal-container') await expect(modalContainer).toBeVisible() @@ -925,7 +906,6 @@ describe('Locked Documents', () => { test('should update user data if incoming user takes over from within document', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const modalContainer = page.locator('.payload__modal-container') await expect(modalContainer).toBeVisible() @@ -995,7 +975,6 @@ describe('Locked Documents', () => { }) test('should show Document Take Over modal for previous user if taken over', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('hello world') @@ -1046,7 +1025,6 @@ describe('Locked Documents', () => { test('should take previous user back to dashboard on dashboard button click', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('hello world') @@ -1102,7 +1080,6 @@ describe('Locked Documents', () => { test('should show fields in read-only if previous user views doc in read-only mode', async () => { await page.goto(postsUrl.edit(postDoc.id)) - await page.waitForURL(postsUrl.edit(postDoc.id)) const textInput = page.locator('#field-text') await textInput.fill('hello world') @@ -1216,7 +1193,6 @@ describe('Locked Documents', () => { test('should show lock on document card in dashboard view if locked', async () => { await page.goto(postsUrl.admin) - await page.waitForURL(new RegExp(postsUrl.admin)) await expect(page.locator('.dashboard__card-list #card-menu .locked svg')).toBeVisible() }) @@ -1231,14 +1207,12 @@ describe('Locked Documents', () => { await wait(500) await page.goto(postsUrl.admin) - await page.waitForURL(new RegExp(postsUrl.admin)) await expect(page.locator('.dashboard__card-list #card-menu .locked')).toBeHidden() }) test('should not show lock on document card in dashboard view if locked by current user', async () => { await page.goto(globalUrl.global('menu')) - await page.waitForURL(globalUrl.global('menu')) const textInput = page.locator('#field-globalText') await textInput.fill('this is a global menu text field') @@ -1246,14 +1220,12 @@ describe('Locked Documents', () => { await page.reload() await page.goto(postsUrl.admin) - await page.waitForURL(new RegExp(postsUrl.admin)) await expect(page.locator('.dashboard__card-list #card-menu .locked')).toBeHidden() }) test('should not show lock on document card in dashboard view if lock expired', async () => { await page.goto(postsUrl.admin) - await page.waitForURL(new RegExp(postsUrl.admin)) await expect(page.locator('.dashboard__card-list #card-admin .locked svg')).toBeVisible() @@ -1285,7 +1257,6 @@ describe('Locked Documents', () => { }) await page.goto(postsUrl.admin) - await page.waitForURL(new RegExp(postsUrl.admin)) await expect(page.locator('.dashboard__card-list #card-admin .locked svg')).toBeVisible() diff --git a/test/uploads/e2e.spec.ts b/test/uploads/e2e.spec.ts index 66e54f0e90..28b1f747f2 100644 --- a/test/uploads/e2e.spec.ts +++ b/test/uploads/e2e.spec.ts @@ -168,7 +168,6 @@ describe('Uploads', () => { ).docs[0] await page.goto(relationURL.edit(relationDoc.id)) - await page.waitForURL(relationURL.edit(relationDoc.id)) const filename = page.locator('.upload-relationship-details__filename a').nth(0) await expect(filename).toContainText('image.png') @@ -398,7 +397,6 @@ describe('Uploads', () => { ).docs[0] await page.goto(audioURL.edit(audioDoc.id)) - await page.waitForURL(audioURL.edit(audioDoc.id)) // remove the selection and open the list drawer await wait(500) // flake workaround @@ -441,7 +439,6 @@ describe('Uploads', () => { ).docs[0] await page.goto(audioURL.edit(audioDoc.id)) - await page.waitForURL(audioURL.edit(audioDoc.id)) // remove the selection and open the list drawer await wait(500) // flake workaround @@ -562,7 +559,6 @@ describe('Uploads', () => { test('should detect correct mimeType', async () => { await page.goto(mediaURL.create) - await page.waitForURL(mediaURL.create) await page.setInputFiles('input[type="file"]', path.resolve(dirname, './image.png')) await saveDocAndAssert(page) @@ -579,7 +575,6 @@ describe('Uploads', () => { test('should upload image with metadata', async () => { await page.goto(withMetadataURL.create) - await page.waitForURL(withMetadataURL.create) const fileChooserPromise = page.waitForEvent('filechooser') await page.getByText('Select a file').click() @@ -607,7 +602,6 @@ describe('Uploads', () => { test('should upload image without metadata', async () => { await page.goto(withoutMetadataURL.create) - await page.waitForURL(withoutMetadataURL.create) const fileChooserPromise = page.waitForEvent('filechooser') await page.getByText('Select a file').click() @@ -635,7 +629,6 @@ describe('Uploads', () => { test('should only upload image with metadata if jpeg mimetype', async () => { await page.goto(withOnlyJPEGMetadataURL.create) - await page.waitForURL(withOnlyJPEGMetadataURL.create) const fileChooserPromiseForJPEG = page.waitForEvent('filechooser') await page.getByText('Select a file').click() @@ -662,7 +655,6 @@ describe('Uploads', () => { expect(acceptableFileSizesForJPEG).toContain(jpegMediaDoc.sizes.sizeThree.filesize) await page.goto(withOnlyJPEGMetadataURL.create) - await page.waitForURL(withOnlyJPEGMetadataURL.create) const fileChooserPromiseForWEBP = page.waitForEvent('filechooser') await page.getByText('Select a file').click() @@ -705,7 +697,6 @@ describe('Uploads', () => { test('should bulk upload multiple files', async () => { // Navigate to the upload creation page await page.goto(uploadsOne.create) - await page.waitForURL(uploadsOne.create) // Upload single file await page.setInputFiles( @@ -760,7 +751,6 @@ describe('Uploads', () => { // Navigate to the upload creation page await page.goto(uploadsOne.create) - await page.waitForURL(uploadsOne.create) // Upload single file await page.setInputFiles( @@ -858,7 +848,6 @@ describe('Uploads', () => { test('should remove validation errors from bulk upload files after correction in edit many drawer', async () => { // Navigate to the upload creation page await page.goto(uploadsOne.create) - await page.waitForURL(uploadsOne.create) // Upload single file await page.setInputFiles( @@ -1010,7 +999,6 @@ describe('Uploads', () => { const createFocalCrop = async (page: Page, position: 'bottom-right' | 'top-left') => { const { dragX, dragY, focalX, focalY } = positions[position] await page.goto(mediaURL.create) - await page.waitForURL(mediaURL.create) // select and upload file const fileChooserPromise = page.waitForEvent('filechooser') await page.getByText('Select a file').click() @@ -1070,7 +1058,6 @@ describe('Uploads', () => { test('should update image alignment based on focal point', async () => { const updateFocalPosition = async (page: Page) => { await page.goto(focalOnlyURL.create) - await page.waitForURL(focalOnlyURL.create) // select and upload file const fileChooserPromise = page.waitForEvent('filechooser') await page.getByText('Select a file').click() @@ -1107,7 +1094,6 @@ describe('Uploads', () => { test('should resize image after crop if resizeOptions defined', async () => { await page.goto(animatedTypeMediaURL.create) - await page.waitForURL(animatedTypeMediaURL.create) const fileChooserPromise = page.waitForEvent('filechooser') await page.getByText('Select a file').click() @@ -1181,14 +1167,11 @@ describe('Uploads', () => { test('should hide file input when disableCreateFileInput is true on collection create', async () => { await page.goto(hideFileInputOnCreateURL.create) - await page.waitForURL(hideFileInputOnCreateURL.create) - await expect(page.locator('.file-field__upload')).toBeHidden() }) test('should hide bulk upload from list view when disableCreateFileInput is true', async () => { await page.goto(hideFileInputOnCreateURL.list) - await expect(page.locator('.list-header')).not.toContainText('Bulk Upload') }) diff --git a/test/versions/e2e.spec.ts b/test/versions/e2e.spec.ts index d7d44c0842..0348e303d1 100644 --- a/test/versions/e2e.spec.ts +++ b/test/versions/e2e.spec.ts @@ -311,7 +311,6 @@ describe('Versions', () => { test('should restore version with correct data', async () => { await page.goto(url.create) - await page.waitForURL(url.create) await page.locator('#field-title').fill('v1') await page.locator('#field-description').fill('hello') await saveDocAndAssert(page) @@ -322,7 +321,6 @@ describe('Versions', () => { const row2 = page.locator('tbody .row-2') const versionID = await row2.locator('.cell-id').textContent() await page.goto(`${savedDocURL}/versions/${versionID}`) - await page.waitForURL(`${savedDocURL}/versions/${versionID}`) await expect(page.locator('.render-field-diffs')).toBeVisible() await page.locator('.restore-version__button').click() await page.locator('button:has-text("Confirm")').click() @@ -481,7 +479,6 @@ describe('Versions', () => { test('collection - should update updatedAt', async () => { await page.goto(url.create) - await page.waitForURL(`**/${url.create}`) // fill out doc in english await page.locator('#field-title').fill('title') @@ -535,7 +532,6 @@ describe('Versions', () => { test('global - should autosave', async () => { const url = new AdminUrlUtil(serverURL, autoSaveGlobalSlug) await page.goto(url.global(autoSaveGlobalSlug)) - await page.waitForURL(`**/${autoSaveGlobalSlug}`) const titleField = page.locator('#field-title') await titleField.fill('global title') await waitForAutoSaveToRunAndComplete(page) @@ -577,7 +573,6 @@ describe('Versions', () => { const englishTitle = 'english title' await page.goto(url.create) - await page.waitForURL(`**/${url.create}`) // fill out doc in english await page.locator('#field-title').fill(englishTitle) @@ -640,7 +635,6 @@ describe('Versions', () => { test('should save versions with custom IDs', async () => { await page.goto(customIDURL.create) - await page.waitForURL(`${customIDURL.create}`) await page.locator('#field-id').fill('custom') await page.locator('#field-title').fill('title') await saveDocAndAssert(page) @@ -792,7 +786,6 @@ describe('Versions', () => { test('should schedule publish', async () => { await page.goto(url.create) - await page.waitForURL(url.create) await page.locator('#field-title').fill('scheduled publish') await page.locator('#field-description').fill('scheduled publish description') @@ -1220,14 +1213,12 @@ describe('Versions', () => { async function navigateToVersionDiff() { const versionURL = `${serverURL}/admin/collections/${draftCollectionSlug}/${postID}/versions/${versionID}` await page.goto(versionURL) - await page.waitForURL(versionURL) await expect(page.locator('.render-field-diffs').first()).toBeVisible() } async function navigateToVersionFieldsDiff() { const versionURL = `${serverURL}/admin/collections/${diffCollectionSlug}/${diffID}/versions/${versionDiffID}` await page.goto(versionURL) - await page.waitForURL(versionURL) await expect(page.locator('.render-field-diffs').first()).toBeVisible() }