Skip to content

Commit

Permalink
test: update menu modifier chord tests to workaround chromium bug
Browse files Browse the repository at this point in the history
It seems that after the recent chromium update, two menu e2e tests started
to fail consistently given the use of `Key.chord` with a modifier key. The
problem seems to be that chromium has a bug with the revision we are using,
where the chord `Key.NULL` reset key is sent as actual character to the active
element instead of the key state/modifier state being reset.

Related: https://bugs.chromium.org/p/chromedriver/issues/detail?id=3999.

It's low-effort to just release the keys manually here.

(cherry picked from commit e99d633)
  • Loading branch information
devversion authored and wagnermaciel committed Feb 16, 2022
1 parent 4385603 commit 156ac3a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions src/material-experimental/mdc-menu/menu.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {browser, by, element, ExpectedConditions, Key, protractor} from 'protractor';
import {browser, by, element, ExpectedConditions, Key} from 'protractor';
import {
expectAlignedWith,
expectFocusOn,
Expand Down Expand Up @@ -135,7 +135,8 @@ describe('MDC-based menu', () => {
await pressKeys(Key.TAB, Key.ENTER);
await expectToExist(menuSelector);

await pressKeys(protractor.Key.chord(Key.SHIFT, Key.TAB));
// Press SHIFT+TAB, but make sure to release SHIFT again.
await pressKeys(Key.SHIFT, Key.TAB, Key.SHIFT);
await expectToExist(menuSelector, false);
});

Expand All @@ -149,13 +150,14 @@ describe('MDC-based menu', () => {
});

it('should focus before and after trigger when tabbing past items', async () => {
let shiftTab = protractor.Key.chord(Key.SHIFT, Key.TAB);
// Press SHIFT+TAB, but make sure to release SHIFT again.
let shiftTab = [Key.SHIFT, Key.TAB, Key.SHIFT];

await pressKeys(Key.ENTER, Key.TAB);
await expectFocusOn(page.triggerTwo());

// navigate back to trigger
await pressKeys(shiftTab, Key.ENTER, shiftTab);
await pressKeys(...shiftTab, Key.ENTER, ...shiftTab);
await expectFocusOn(page.start());
});
});
Expand Down
10 changes: 6 additions & 4 deletions src/material/menu/menu.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {browser, by, element, ExpectedConditions, Key, protractor} from 'protractor';
import {browser, by, element, ExpectedConditions, Key} from 'protractor';
import {
expectAlignedWith,
expectFocusOn,
Expand Down Expand Up @@ -135,7 +135,8 @@ describe('menu', () => {
await pressKeys(Key.TAB, Key.ENTER);
await expectToExist(menuSelector);

await pressKeys(protractor.Key.chord(Key.SHIFT, Key.TAB));
// Press SHIFT+TAB, but make sure to release SHIFT again.
await pressKeys(Key.SHIFT, Key.TAB, Key.SHIFT);
await expectToExist(menuSelector, false);
});

Expand All @@ -149,13 +150,14 @@ describe('menu', () => {
});

it('should focus before and after trigger when tabbing past items', async () => {
let shiftTab = protractor.Key.chord(Key.SHIFT, Key.TAB);
// Press SHIFT+TAB, but make sure to release SHIFT again.
let shiftTab = [Key.SHIFT, Key.TAB, Key.SHIFT];

await pressKeys(Key.ENTER, Key.TAB);
await expectFocusOn(page.triggerTwo());

// navigate back to trigger
await pressKeys(shiftTab, Key.ENTER, shiftTab);
await pressKeys(...shiftTab, Key.ENTER, ...shiftTab);
await expectFocusOn(page.start());
});
});
Expand Down

0 comments on commit 156ac3a

Please sign in to comment.