Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nav block: link text color inheritance fixes and tests #51710

Merged
merged 66 commits into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
d7587f4
tests and fix for link color inheritance
MaggieCabrera Jun 20, 2023
7d1c89d
test agains emptytheme too, refactor setup, added better comments
MaggieCabrera Jun 21, 2023
4fcc62c
change setup for tests
MaggieCabrera Jun 28, 2023
830a356
removed inherit color for the moment on the block
MaggieCabrera Jun 28, 2023
489f2a4
finished the first test with all cases
MaggieCabrera Jun 30, 2023
e419f4f
finished second test
MaggieCabrera Jun 30, 2023
798a886
finished third test
MaggieCabrera Jun 30, 2023
1f5e5f2
started the last test
MaggieCabrera Jun 30, 2023
1b65241
spacing on comments
MaggieCabrera Jul 4, 2023
c5c6778
removed unnecessary actions from before/after testing functions
MaggieCabrera Jul 4, 2023
1c772ab
insert specific id of nav directly to speed up things
MaggieCabrera Jul 4, 2023
307123f
finish checking colors in the editor on desktop
MaggieCabrera Jul 4, 2023
186338a
test the overlay and reset settings
MaggieCabrera Jul 4, 2023
1f1fd9e
use variables for colors, cover rest of the cases to test
MaggieCabrera Jul 5, 2023
ce5a726
introduced a third link to cover non submenu links
MaggieCabrera Jul 5, 2023
53c8461
undo unwanted change
MaggieCabrera Jul 5, 2023
d737271
finish the overlay background tests and fix issues with inheritance
MaggieCabrera Jul 5, 2023
eb194a1
turn colors into variables for readibility
MaggieCabrera Jul 6, 2023
5f50ed5
fix wrong color syntax
MaggieCabrera Jul 6, 2023
eec98d1
Create test page before creating navigation menu
jeryj Jul 6, 2023
77d3df0
Add test coverage for selecting group text color that should be inher…
jeryj Jul 6, 2023
7d90814
Fix incorrect selector structure.
jeryj Jul 7, 2023
a436cd3
Update tests to check for black text defaults on navigation links
jeryj Jul 7, 2023
ce82292
Big refactor of navigation color tests
jeryj Jul 7, 2023
4541b41
Revert link color settings changing the navigation link colors
jeryj Jul 7, 2023
65ea6ca
Large refactor of navigation color tests
jeryj Jul 11, 2023
0f6473c
Add test for navigation background colors
jeryj Jul 11, 2023
42086c5
Add test to ensure navigation text does not inherit link color from t…
jeryj Jul 11, 2023
1a3c0b3
Only set default navigation submenu and overlay text colors if no nav…
jeryj Jul 11, 2023
e7c72ed
Have li navigation items inherit background color so it can be inheri…
jeryj Jul 12, 2023
8f27fd3
Change how to test editor mobile overlay colors
jeryj Jul 12, 2023
c693611
Move navigation color tests to own file
jeryj Jul 12, 2023
db21c63
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
ada037c
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
8786a7c
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
3131a7d
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
680072d
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
716d992
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
e726585
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
e49f423
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
ffc6806
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
57fe3b1
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
6988f59
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
1bdd9aa
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
05927a0
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
50113d2
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
53c4d8d
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
c5e10fd
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
83d168c
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
6a80a1b
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
6b3710d
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
2115868
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
b1a9724
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
92f289d
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
ca77108
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
299c028
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
3a261f7
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
4c111b9
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
27a1694
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
ff5be80
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
f1e0f3d
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
f10b86a
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
cfb8266
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
2aa309d
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
6a0cc47
update comments
scruffian Jul 13, 2023
1b66e92
Update test/e2e/specs/editor/blocks/navigation-colors.spec.js
scruffian Jul 13, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finished the first test with all cases
  • Loading branch information
MaggieCabrera committed Jul 6, 2023
commit 489f2a451657e171ebfb15ac7d365503d039f936
2 changes: 1 addition & 1 deletion packages/block-library/src/navigation/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ button.wp-block-navigation-item__content {
right: 0;
bottom: 0;

.wp-block-navigation-link a {
.wp-block-navigation-item a {
color: inherit;
}

Expand Down
91 changes: 76 additions & 15 deletions test/e2e/specs/editor/blocks/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -936,6 +936,7 @@ test.describe( 'Navigation block', () => {
//we want emptytheme because it doesn't have any styles
await requestUtils.activateTheme( 'emptytheme' );
await requestUtils.deleteAllTemplates( 'wp_template_part' );
await requestUtils.deleteAllTemplates( 'wp_template' );
await requestUtils.deleteAllPages();
await requestUtils.deleteAllMenus();
} );
Expand All @@ -950,30 +951,97 @@ test.describe( 'Navigation block', () => {
title: 'Hidden menu',
content:
'<!-- wp:navigation-submenu {"label":"First link","type":"custom","url":"http://www.wordpress.org/","kind":"custom"} --><!-- wp:navigation-link {"label":"Second Link","type":"custom","url":"http://www.wordpress.org/","kind":"custom"} /--><!-- /wp:navigation-submenu -->',
attributes: { openSubmenusOnClick: true },
} );
await editor.insertBlock( {
name: 'core/navigation',
} );

await editor.saveSiteEditorEntities();
await admin.visitSiteEditor();
await editor.canvas.click( 'body' );
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllTemplates( 'wp_template_part' );
await requestUtils.deleteAllTemplates( 'wp_template' );
await requestUtils.deleteAllPages();
await requestUtils.deleteAllMenus();
} );

test( 'As a user I expect my navigation links to have appropriate default colors', async ( {
editor,
page,
} ) => {
const firstlink = editor.canvas.locator(
`role=textbox[name="Navigation link text"i] >> text="First link"`
);
const firstLink = editor.canvas
.locator( 'a' )
.filter( { hasText: 'First Link' } );
//Expect the first link to default to black when the theme doesn't define a link color
await expect( firstlink ).toHaveCSS( 'color', 'rgb(0, 0, 0)' );
//TODO check frontend on desktop and mobile
//TODO then the same for second link (make sure it has a background color!)
//Then the same for background colors. This one is important when the theme doesn't define an overlay background color
await expect( firstLink ).toHaveCSS( 'color', 'rgb(0, 0, 0)' );
await editor.canvas
.getByRole( 'document', { name: 'Block: header' } )
.click();
await editor.canvas
.getByRole( 'document', { name: 'Block: Navigation' } )
.click();
await firstLink.click();
//We check that the submenu links also have black text
const secondLink = editor.canvas
.locator( 'a' )
.filter( { hasText: 'Second Link' } );
const submenuWrapper = editor.canvas
.getByRole( 'document', { name: 'Block: Custom Link' } )
.filter( { has: secondLink } );
await expect( secondLink ).toHaveCSS( 'color', 'rgb(0, 0, 0)' );
//We check for the submenu's background color. This one is important when the theme doesn't define an overlay background color
await expect( submenuWrapper ).toHaveCSS(
'background-color',
'rgb(255, 255, 255)'
);

//We test the overlay on mobile too.
await page
.getByRole( 'button', { name: 'View', exact: true } )
.click();
await page.getByRole( 'menuitem', { name: 'Mobile' } ).click();
await editor.canvas
.getByRole( 'button', { name: 'Open menu' } )
.click();
const overlay = editor.canvas
.locator( '.wp-block-navigation__responsive-container' )
.filter( { hasText: 'Second Link' } );
await expect( overlay ).toHaveCSS(
'background-color',
'rgb(255, 255, 255)'
);
await expect( firstLink ).toHaveCSS( 'color', 'rgb(0, 0, 0)' );
await expect( secondLink ).toHaveCSS( 'color', 'rgb(0, 0, 0)' );

//And finally we check the frontend
await page.goto( '/' );
const firstLinkFront = page
.locator( 'a' )
.filter( { hasText: 'First Link' } );
const secondLinkFront = page
.locator( 'a' )
.filter( { hasText: 'Second Link' } );
const submenuWrapperFront = page
.locator( '.wp-block-navigation__submenu-container' )
.filter( { has: secondLinkFront } );
await expect( firstLinkFront ).toHaveCSS( 'color', 'rgb(0, 0, 0)' );
await firstLinkFront.hover();
await expect( secondLinkFront ).toHaveCSS(
'color',
'rgb(0, 0, 0)'
);
await expect( secondLinkFront ).toHaveCSS(
'color',
'rgb(0, 0, 0)'
);
await expect( submenuWrapperFront ).toHaveCSS(
'background-color',
'rgb(255, 255, 255)'
);
} );

test( 'As a user I expect my navigation links to inherit the colors from the theme', async ( {
Expand All @@ -995,14 +1063,7 @@ test.describe( 'Navigation block', () => {
await page
.getByRole( 'button', { name: 'Color: Vivid red' } )
.click();
await page
.getByRole( 'button', { name: 'Save', exact: true } )
.click();
await page
.getByRole( 'region', { name: 'Save panel' } )
.getByRole( 'button', { name: 'Save' } )
.click();
await editor.page.pause();
//TODO Hover too!
//Expect the first link to inherit the nav link color from the theme
await expect( firstlink ).toHaveCSS( 'color', 'rgb(207, 46, 46)' );

Expand Down