Skip to content

Commit

Permalink
Navigation: Add warning test (#45207)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

---------

Co-authored-by: Kai Hao <[email protected]>
  • Loading branch information
scruffian and kevin940726 authored Feb 10, 2023
1 parent 9b1f1af commit ff19d8a
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/e2e/specs/editor/blocks/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
} );
}
);
} );

0 comments on commit ff19d8a

Please sign in to comment.