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

@@ -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)
})

View File

@@ -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()

View File

@@ -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)
})