From ff19d8abfea5b4872b46d37feaf1b01a6982b899 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Fri, 10 Feb 2023 14:20:47 +0000 Subject: [PATCH] Navigation: Add warning test (#45207) * give the test a proper name * use role instead of class name for locating the element * fix syntax error * Update test/e2e/specs/editor/blocks/navigation.spec.js Co-authored-by: Kai Hao --------- Co-authored-by: Kai Hao --- .../specs/editor/blocks/navigation.spec.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/e2e/specs/editor/blocks/navigation.spec.js b/test/e2e/specs/editor/blocks/navigation.spec.js index c362e23a36b83..9b4ad7123bcbb 100644 --- a/test/e2e/specs/editor/blocks/navigation.spec.js +++ b/test/e2e/specs/editor/blocks/navigation.spec.js @@ -146,3 +146,43 @@ class NavigationBlockUtils { ); } } + +test.describe( 'Navigation block', () => { + test.describe( + 'As a user I want to see a warning if the menu referenced by a navigation block is not available', + () => { + test.beforeEach( async ( { admin } ) => { + await admin.createNewPost(); + } ); + + test( 'warning message shows when given an unknown ref', async ( { + editor, + } ) => { + await editor.insertBlock( { + name: 'core/navigation', + attributes: { + ref: 1, + }, + } ); + + // Check the markup of the block is correct. + await editor.publishPost(); + + await expect.poll( editor.getBlocks ).toMatchObject( [ + { + name: 'core/navigation', + attributes: { ref: 1 }, + }, + ] ); + + // Find the warning message + const warningMessage = editor.canvas + .getByRole( 'document', { name: 'Block: Navigation' } ) + .getByText( + 'Navigation menu has been deleted or is unavailable.' + ); + await expect( warningMessage ).toBeVisible(); + } ); + } + ); +} );