test: dedicated bulk edit test suite (#11756)

Consolidates all bulk edit related tests into a single, dedicated suite.

Currently, bulk edit tests are dispersed throughout the Admin > General
and the Versions test suites, which are considerably bloated for their
own purposes. This made them very hard to locate, mentally digest, and
add on new tests. Going forward, many more tests specifically for bulk
edit will need to be written. This gives us a simple, isolated place for
that.

With this change are also a few improvements to the tests themselves to
make them more predictable and efficient.
This commit is contained in:
Jacob Fletcher
2025-03-18 13:31:51 -04:00
committed by GitHub
parent 3f23160a96
commit a44a252f31
19 changed files with 2847 additions and 459 deletions

View File

@@ -36,10 +36,8 @@ import {
changeLocale,
ensureCompilationIsDone,
exactText,
findTableCell,
initPageConsoleErrorCatch,
saveDocAndAssert,
selectTableRow,
} from '../helpers.js'
import { AdminUrlUtil } from '../helpers/adminUrlUtil.js'
import { assertNetworkRequests } from '../helpers/e2e/assertNetworkRequests.js'
@@ -47,7 +45,6 @@ import { initPayloadE2ENoConfig } from '../helpers/initPayloadE2ENoConfig.js'
import { reInitializeDB } from '../helpers/reInitializeDB.js'
import { waitForAutoSaveToRunAndComplete } from '../helpers/waitForAutoSaveToRunAndComplete.js'
import { POLL_TOPASS_TIMEOUT, TEST_TIMEOUT_LONG } from '../playwright.config.js'
import { titleToDelete } from './shared.js'
import {
autosaveCollectionSlug,
autoSaveGlobalSlug,
@@ -125,130 +122,6 @@ describe('Versions', () => {
postURL = new AdminUrlUtil(serverURL, postCollectionSlug)
})
// This test has to run before bulk updates that will rename the title
test('should delete', async () => {
await page.goto(url.list)
const rows = page.locator(`tr`)
const rowToDelete = rows.filter({ hasText: titleToDelete })
await rowToDelete.locator('.cell-_select input').check()
await page.locator('.delete-documents__toggle').click()
await page.locator('#delete-draft-posts #confirm-action').click()
await expect(page.locator('.payload-toast-container .toast-success')).toContainText(
'Deleted 1 Draft Post successfully.',
)
await expect(page.locator('.row-1 .cell-title')).not.toHaveText(titleToDelete)
})
test('bulk update - should publish many', async () => {
await page.goto(url.list)
// Select specific rows by title
await selectTableRow(page, 'Published Title')
await selectTableRow(page, 'Draft Title')
// Bulk edit the selected rows
await page.locator('.publish-many__toggle').click()
await page.locator('#publish-draft-posts #confirm-action').click()
// Check that the statuses for each row has been updated to `published`
await expect(findTableCell(page, '_status', 'Published Title')).toContainText('Published')
await expect(findTableCell(page, '_status', 'Draft Title')).toContainText('Published')
})
test('bulk publish with autosave documents', async () => {
const title = 'autosave title'
const description = 'autosave description'
await page.goto(autosaveURL.create)
// gets redirected from /create to /slug/id due to autosave
await page.waitForURL(new RegExp(`${autosaveURL.edit('')}`))
await wait(500)
await expect(page.locator('#field-title')).toBeEnabled()
await page.locator('#field-title').fill(title)
await expect(page.locator('#field-description')).toBeEnabled()
await page.locator('#field-description').fill(description)
await waitForAutoSaveToRunAndComplete(page)
await page.goto(autosaveURL.list)
await expect(findTableCell(page, '_status', title)).toContainText('Draft')
await selectTableRow(page, title)
await page.locator('.publish-many__toggle').click()
await page.locator('#publish-autosave-posts #confirm-action').click()
await expect(findTableCell(page, '_status', title)).toContainText('Published')
})
test('bulk update - should unpublish many', async () => {
await page.goto(url.list)
// Select specific rows by title
await selectTableRow(page, 'Published Title')
await selectTableRow(page, 'Draft Title')
// Bulk edit the selected rows
await page.locator('.unpublish-many__toggle').click()
await page.locator('#unpublish-draft-posts #confirm-action').click()
// Check that the statuses for each row has been updated to `draft`
await expect(findTableCell(page, '_status', 'Published Title')).toContainText('Draft')
await expect(findTableCell(page, '_status', 'Draft Title')).toContainText('Draft')
})
test('bulk update — should publish changes', async () => {
const description = 'published document'
await page.goto(url.list)
// Select specific rows by title
await selectTableRow(page, 'Published Title')
await selectTableRow(page, 'Draft Title')
// Bulk edit the selected rows to `published` status
await page.locator('.edit-many__toggle').click()
await page.locator('.field-select .rs__control').click()
const options = page.locator('.rs__option')
const field = options.locator('text=Description')
await field.click()
await page.locator('#field-description').fill(description)
await page.locator('.form-submit .edit-many__publish').click()
await expect(page.locator('.payload-toast-container .toast-success')).toContainText(
'Draft Posts successfully.',
)
// Check that the statuses for each row has been updated to `published`
await expect(findTableCell(page, '_status', 'Published Title')).toContainText('Published')
await expect(findTableCell(page, '_status', 'Draft Title')).toContainText('Published')
})
test('bulk update — should draft changes', async () => {
const description = 'draft document'
await page.goto(url.list)
// Select specific rows by title
await selectTableRow(page, 'Published Title')
await selectTableRow(page, 'Draft Title')
// Bulk edit the selected rows to `draft` status
await page.locator('.edit-many__toggle').click()
await page.locator('.field-select .rs__control').click()
const options = page.locator('.rs__option')
const field = options.locator('text=Description')
await field.click()
await page.locator('#field-description').fill(description)
await page.locator('.form-submit .edit-many__draft').click()
await expect(page.locator('.payload-toast-container .toast-success')).toContainText(
'Draft Posts successfully.',
)
// Check that the statuses for each row has been updated to `draft`
await expect(findTableCell(page, '_status', 'Published Title')).toContainText('Draft')
await expect(findTableCell(page, '_status', 'Draft Title')).toContainText('Draft')
})
test('collection — has versions tab', async () => {
await page.goto(url.list)
await page.locator('tbody tr .cell-title a').first().click()

View File

@@ -6,7 +6,6 @@ import type { DraftPost } from './payload-types.js'
import { devUser } from '../credentials.js'
import { executePromises } from '../helpers/executePromises.js'
import { titleToDelete } from './shared.js'
import {
autosaveWithValidateCollectionSlug,
diffCollectionSlug,
@@ -113,18 +112,6 @@ export async function seed(_payload: Payload, parallel: boolean = false) {
draft: false,
})
await _payload.create({
collection: draftCollectionSlug,
data: {
blocksField,
description: 'Description',
title: titleToDelete,
},
depth: 0,
overrideAccess: true,
draft: true,
})
await _payload.create({
collection: autosaveWithValidateCollectionSlug,
data: {

View File

@@ -1 +0,0 @@
export const titleToDelete = 'Title To Delete'