From 93dd6b5a981eafb7a2e9d9c1026ae601fb1792e5 Mon Sep 17 00:00:00 2001 From: Alessio Gravili <70709113+AlessioGr@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:36:05 -0400 Subject: [PATCH] chore: add skipped, failing lexical e2e test for errors within nested block fields, fix lexical seed data, disable access-control test (#5508) --- test/access-control/e2e.spec.ts | 3 ++- test/fields/collections/Lexical/blocks.ts | 11 +++++++++ .../Lexical/generateLexicalRichText.ts | 2 -- test/fields/lexical.e2e.spec.ts | 24 +++++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/test/access-control/e2e.spec.ts b/test/access-control/e2e.spec.ts index 6c68500c8..ea71b5dcc 100644 --- a/test/access-control/e2e.spec.ts +++ b/test/access-control/e2e.spec.ts @@ -257,7 +257,8 @@ describe('access control', () => { }) }) - test('should show test global immediately after allowing access', async () => { + // TODO: Test flakes. In CI, test global does not appear in nav. Perhaps the checkbox setValue is not triggered BEFORE the document is saved, as the custom save button can be clicked even if the form has not been set to modified. + test.skip('should show test global immediately after allowing access', async () => { await page.goto(`${serverURL}/admin/globals/settings`) await openNav(page) diff --git a/test/fields/collections/Lexical/blocks.ts b/test/fields/collections/Lexical/blocks.ts index af0cd1e11..768b2c909 100644 --- a/test/fields/collections/Lexical/blocks.ts +++ b/test/fields/collections/Lexical/blocks.ts @@ -16,6 +16,17 @@ export const BlockColumns = ({ name }: { name: string }): ArrayField => ({ name: 'text', type: 'text', }, + { + name: 'subArray', + type: 'array', + fields: [ + { + name: 'requiredText', + type: 'text', + required: true, + }, + ], + }, ], }) export const ConditionalLayoutBlock: Block = { diff --git a/test/fields/collections/Lexical/generateLexicalRichText.ts b/test/fields/collections/Lexical/generateLexicalRichText.ts index 2ec4bac0f..b38d2fd61 100644 --- a/test/fields/collections/Lexical/generateLexicalRichText.ts +++ b/test/fields/collections/Lexical/generateLexicalRichText.ts @@ -270,8 +270,6 @@ export function generateLexicalRichText() { text: 'text in conditionalLayout block', }, ], - columns2: null, - columns3: null, }, }, // Do not remove this blocks node. It ensures that validation passes when it's created { diff --git a/test/fields/lexical.e2e.spec.ts b/test/fields/lexical.e2e.spec.ts index 255b22d6c..7aa6d5144 100644 --- a/test/fields/lexical.e2e.spec.ts +++ b/test/fields/lexical.e2e.spec.ts @@ -763,5 +763,29 @@ describe('lexical', () => { await expect(page.locator('.Toastify')).not.toContainText('Please correct invalid fields.') }) + + test.skip('should respect required error state in deeply nested text field', async () => { + await navigateToLexicalFields() + const richTextField = page.locator('.rich-text-lexical').nth(1) // second + await richTextField.scrollIntoViewIfNeeded() + await expect(richTextField).toBeVisible() + + const conditionalArrayBlock = richTextField.locator('.lexical-block').nth(7) + + await conditionalArrayBlock.scrollIntoViewIfNeeded() + await expect(conditionalArrayBlock).toBeVisible() + + await conditionalArrayBlock.locator('.btn__label:has-text("Add Sub Array")').first().click() + + await page.click('#action-save', { delay: 100 }) + await expect(page.locator('.Toastify')).toContainText('The following field is invalid') + + // Check if error is shown next to field + await expect( + conditionalArrayBlock + .locator('.tooltip-content:has-text("This field is required.")') + .first(), + ).toBeVisible() + }) }) })