Skip to content

Commit a22f27d

Browse files
test: stabilize frequent fails (#13318)
Adjusts tests that "flake" frequently.
1 parent e7124f6 commit a22f27d

File tree

13 files changed

+47
-71
lines changed

13 files changed

+47
-71
lines changed

packages/ui/src/views/List/GroupByHeader/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ export const GroupByHeader: React.FC<{
1515
}> = ({ collectionConfig, groupByFieldPath, groupByValue, heading }) => {
1616
return (
1717
<header className={baseClass}>
18-
<h4 className={`${baseClass}__heading`}>{heading}</h4>
18+
<h4 className={`${baseClass}__heading`} data-group-id={groupByValue}>
19+
{heading}
20+
</h4>
1921
<ListSelection
2022
collectionConfig={collectionConfig}
2123
label={heading}

test/access-control/e2e.spec.ts

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { devUser } from 'credentials.js'
66
import { openDocControls } from 'helpers/e2e/openDocControls.js'
77
import { openNav } from 'helpers/e2e/toggleNav.js'
88
import path from 'path'
9-
import { email, wait } from 'payload/shared'
9+
import { wait } from 'payload/shared'
1010
import { fileURLToPath } from 'url'
1111

1212
import type { PayloadTestSDK } from '../helpers/sdk/index.js'
@@ -16,7 +16,6 @@ import {
1616
closeNav,
1717
ensureCompilationIsDone,
1818
exactText,
19-
getRoutes,
2019
initPageConsoleErrorCatch,
2120
login,
2221
saveDocAndAssert,
@@ -71,7 +70,6 @@ describe('Access Control', () => {
7170
let disabledFields: AdminUrlUtil
7271
let serverURL: string
7372
let context: BrowserContext
74-
let logoutURL: string
7573
let authFields: AdminUrlUtil
7674

7775
beforeAll(async ({ browser }, testInfo) => {
@@ -98,17 +96,6 @@ describe('Access Control', () => {
9896
await ensureCompilationIsDone({ page, serverURL, noAutoLogin: true })
9997

10098
await login({ page, serverURL })
101-
102-
await ensureCompilationIsDone({ page, serverURL })
103-
104-
const {
105-
admin: {
106-
routes: { logout: logoutRoute },
107-
},
108-
routes: { admin: adminRoute },
109-
} = getRoutes({})
110-
111-
logoutURL = `${serverURL}${adminRoute}${logoutRoute}`
11299
})
113100

114101
describe('fields', () => {
@@ -515,6 +502,13 @@ describe('Access Control', () => {
515502

516503
describe('global', () => {
517504
test('should restrict update access based on document field', async () => {
505+
await payload.updateGlobal({
506+
slug: userRestrictedGlobalSlug,
507+
data: {
508+
name: 'dev@payloadcms.com',
509+
},
510+
})
511+
518512
await page.goto(userRestrictedGlobalURL.global(userRestrictedGlobalSlug))
519513
await expect(page.locator('#field-name')).toBeVisible()
520514
await expect(page.locator('#field-name')).toHaveValue(devUser.email)

test/eslint.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const testEslintConfig = [
7575
'createFolder',
7676
'createFolderFromDoc',
7777
'assertURLParams',
78+
'uploadImage',
7879
],
7980
},
8081
],

test/fields/collections/JSON/e2e.spec.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,23 @@ describe('JSON', () => {
131131
const jsonField = page.locator('.json-field:not(.read-only) #field-customJSON')
132132
await expect(jsonField).toContainText('"default": "value"')
133133

134-
const originalHeight =
135-
(await page.locator('.json-field:not(.read-only) #field-customJSON').boundingBox())?.height ||
136-
0
137-
await page.locator('#set-custom-json').click()
138-
const newHeight =
139-
(await page.locator('.json-field:not(.read-only) #field-customJSON').boundingBox())?.height ||
140-
0
141-
expect(newHeight).toBeGreaterThan(originalHeight)
134+
const boundingBox = await page
135+
.locator('.json-field:not(.read-only) #field-customJSON')
136+
.boundingBox()
137+
await expect(() => expect(boundingBox).not.toBeNull()).toPass()
138+
const originalHeight = boundingBox!.height
139+
140+
// click the button to set custom JSON
141+
await page.locator('#set-custom-json').click({ delay: 1000 })
142+
143+
const newBoundingBox = await page
144+
.locator('.json-field:not(.read-only) #field-customJSON')
145+
.boundingBox()
146+
await expect(() => expect(newBoundingBox).not.toBeNull()).toPass()
147+
const newHeight = newBoundingBox!.height
148+
149+
await expect(() => {
150+
expect(newHeight).toBeGreaterThan(originalHeight)
151+
}).toPass()
142152
})
143153
})

test/fields/collections/Relationship/e2e.spec.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ import { AdminUrlUtil } from '../../../helpers/adminUrlUtil.js'
2323
import { assertToastErrors } from '../../../helpers/assertToastErrors.js'
2424
import { initPayloadE2ENoConfig } from '../../../helpers/initPayloadE2ENoConfig.js'
2525
import { reInitializeDB } from '../../../helpers/reInitializeDB.js'
26-
import { RESTClient } from '../../../helpers/rest.js'
2726
import { POLL_TOPASS_TIMEOUT, TEST_TIMEOUT_LONG } from '../../../playwright.config.js'
2827
import { relationshipFieldsSlug, textFieldsSlug } from '../../slugs.js'
2928
const filename = fileURLToPath(import.meta.url)
@@ -33,7 +32,6 @@ const dirname = path.resolve(currentFolder, '../../')
3332
const { beforeAll, beforeEach, describe } = test
3433

3534
let payload: PayloadTestSDK<Config>
36-
let client: RESTClient
3735
let page: Page
3836
let serverURL: string
3937
// If we want to make this run in parallel: test.describe.configure({ mode: 'parallel' })
@@ -59,12 +57,6 @@ describe('relationship', () => {
5957
uploadsDir: path.resolve(dirname, './collections/Upload/uploads'),
6058
})
6159

62-
if (client) {
63-
await client.logout()
64-
}
65-
client = new RESTClient({ defaultSlug: 'users', serverURL })
66-
await client.login()
67-
6860
await ensureCompilationIsDone({ page, serverURL })
6961
})
7062

@@ -693,7 +685,7 @@ describe('relationship', () => {
693685
await createRelationshipFieldDoc({ value: textDoc.id, relationTo: 'text-fields' })
694686

695687
await page.goto(url.list)
696-
await wait(300)
688+
await wait(1000) // wait for page to load
697689

698690
await addListFilter({
699691
page,

test/fields/collections/Upload/e2e.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {
1717
import { AdminUrlUtil } from '../../../helpers/adminUrlUtil.js'
1818
import { initPayloadE2ENoConfig } from '../../../helpers/initPayloadE2ENoConfig.js'
1919
import { reInitializeDB } from '../../../helpers/reInitializeDB.js'
20-
import { RESTClient } from '../../../helpers/rest.js'
2120
import { POLL_TOPASS_TIMEOUT, TEST_TIMEOUT_LONG } from '../../../playwright.config.js'
2221
import { uploadsSlug } from '../../slugs.js'
2322

@@ -28,7 +27,6 @@ const dirname = path.resolve(currentFolder, '../../')
2827
const { beforeAll, beforeEach, describe } = test
2928

3029
let payload: PayloadTestSDK<Config>
31-
let client: RESTClient
3230
let page: Page
3331
let serverURL: string
3432
// If we want to make this run in parallel: test.describe.configure({ mode: 'parallel' })
@@ -57,12 +55,6 @@ describe('Upload', () => {
5755
uploadsDir: path.resolve(dirname, './collections/Upload/uploads'),
5856
})
5957

60-
if (client) {
61-
await client.logout()
62-
}
63-
client = new RESTClient({ defaultSlug: 'users', serverURL })
64-
await client.login()
65-
6658
await ensureCompilationIsDone({ page, serverURL })
6759
})
6860

test/group-by/e2e.spec.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,6 @@ test.describe('Group By', () => {
5757
password: devUser.password,
5858
},
5959
})
60-
61-
// Fetch category IDs from already-seeded data
62-
const categories = await payload.find({
63-
collection: 'categories',
64-
limit: 1,
65-
sort: 'title',
66-
where: { title: { equals: 'Category 1' } },
67-
})
68-
69-
const [category1] = categories.docs
70-
category1Id = category1?.id as number | string
7160
})
7261

7362
beforeEach(async () => {
@@ -649,7 +638,12 @@ test.describe('Group By', () => {
649638
await firstTable.locator('.row-1 .cell-_select input').check()
650639
await firstTable.locator('.list-selection__button[aria-label="Delete"]').click()
651640

652-
const modalId = `[id^="${category1Id}-confirm-delete-many-docs"]`
641+
const firstGroupID = await firstTable
642+
.locator('.group-by-header__heading')
643+
.getAttribute('data-group-id')
644+
645+
const modalId = `[id^="${firstGroupID}-confirm-delete-many-docs"]`
646+
await expect(page.locator(modalId)).toBeVisible()
653647

654648
// Confirm trash (skip permanent delete)
655649
await page.locator(`${modalId} #confirm-action`).click()

test/helpers/e2e/openListFilters.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const openListFilters = async (
1818
): Promise<{
1919
filterContainer: Locator
2020
}> => {
21+
await expect(page.locator(togglerSelector)).toBeVisible()
2122
const filterContainer = page.locator(filterContainerSelector).first()
2223

2324
const isAlreadyOpen = await filterContainer.isVisible()

test/i18n/e2e.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ describe('i18n', () => {
4444

4545
const context = await browser.newContext()
4646
page = await context.newPage()
47-
initPageConsoleErrorCatch(page)
4847

48+
initPageConsoleErrorCatch(page)
4949
await ensureCompilationIsDone({ page, serverURL })
5050
})
5151
beforeEach(async () => {

test/lexical/collections/RichText/e2e.spec.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import {
1313
import { AdminUrlUtil } from '../../../helpers/adminUrlUtil.js'
1414
import { initPayloadE2ENoConfig } from '../../../helpers/initPayloadE2ENoConfig.js'
1515
import { reInitializeDB } from '../../../helpers/reInitializeDB.js'
16-
import { RESTClient } from '../../../helpers/rest.js'
1716
import { POLL_TOPASS_TIMEOUT, TEST_TIMEOUT_LONG } from '../../../playwright.config.js'
1817

1918
const filename = fileURLToPath(import.meta.url)
@@ -22,7 +21,6 @@ const dirname = path.resolve(currentFolder, '../../')
2221

2322
const { beforeAll, beforeEach, describe } = test
2423

25-
let client: RESTClient
2624
let page: Page
2725
let serverURL: string
2826
// If we want to make this run in parallel: test.describe.configure({ mode: 'parallel' })
@@ -48,12 +46,6 @@ describe('Rich Text', () => {
4846
uploadsDir: [path.resolve(dirname, './collections/Upload/uploads')],
4947
})
5048

51-
if (client) {
52-
await client.logout()
53-
}
54-
client = new RESTClient({ defaultSlug: 'users', serverURL })
55-
await client.login()
56-
5749
await ensureCompilationIsDone({ page, serverURL })
5850
})
5951

0 commit comments

Comments
 (0)