Skip to content

Commit

Permalink
test: re-enable Tab-related e2e tests in Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
maxokorokov committed Nov 22, 2023
1 parent 99c058e commit 861ec71
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 25 deletions.
11 changes: 3 additions & 8 deletions e2e-app/src/app/datepicker/focus/datepicker-focus.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,7 @@ test.describe('Datepicker', () => {
).toBeFocused();
});

test(`should trap focus inside opened popup (Tab)`, async ({ browserName }) => {
test.skip(browserName === 'webkit');

test(`should trap focus inside opened popup (Tab)`, async () => {
await openDatepicker();

// today -> prev. month -> month -> year -> next month -> today -> ...
Expand All @@ -142,9 +140,7 @@ test.describe('Datepicker', () => {
await expect(getPage().locator(SELECTOR_DAY(new Date())), `Today's date should be focused`).toBeFocused();
});

test(`should trap focus inside opened popup with (Shift+Tab)`, async ({ browserName }) => {
test.skip(browserName === 'webkit');

test(`should trap focus inside opened popup with (Shift+Tab)`, async () => {
await openDatepicker();

// today -> next month -> year -> month -> prev. month -> today -> ...
Expand Down Expand Up @@ -203,8 +199,7 @@ test.describe('Datepicker', () => {
await expect(getPage().locator(SELECTOR_DAY(new Date())), `Today's date should stay focused`).toBeFocused();
});

test(`should allow focusing datepicker input`, async ({ browserName }) => {
test.skip(browserName === 'webkit');
test(`should allow focusing datepicker input`, async () => {
await openDatepicker();

// focus input
Expand Down
11 changes: 4 additions & 7 deletions e2e-app/src/app/dropdown/focus/dropdown-focus.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@playwright/test';
import { isDropdownOpened, openDropdown } from '../dropdown.po';
import { test, getPage, setPage } from '../../../../baseTest';
import { getPage, setPage, test } from '../../../../baseTest';
import { sendKey } from '../../tools.po';

const SELECTOR_DROPDOWN = '[ngbDropdown]';
Expand Down Expand Up @@ -144,15 +144,12 @@ test.describe(`Dropdown focus`, () => {
await expect(getPage().locator(SELECTOR_DROPDOWN_TOGGLE), `Toggling element should be focused`).toBeFocused();
});

test(`should focus dropdown first item with Tab when dropdown is opened (toggle was focused)`, async ({
browserName,
}) => {
test.skip(browserName === 'webkit');
test(`should focus dropdown first item with Tab when dropdown is opened (toggle was focused)`, async () => {
await openDropdown('Dropdown should be opened', SELECTOR_DROPDOWN, container === 'body');
await expect(getPage().locator(SELECTOR_DROPDOWN_TOGGLE), `Toggling element should be focused`).toBeFocused();

// Tab -> first
await sendKey('Tab');
await sendKey('Tab', false);
await expect(
getPage().locator(SELECTOR_DROPDOWN_ITEM(1)),
`first dropdown item should be focused`,
Expand All @@ -178,7 +175,7 @@ test.describe(`Dropdown focus`, () => {
).toBeFocused();

// Tab -> another element
await sendKey('Tab');
await sendKey('Tab', false);
expect(await isDropdownOpened(), `Dropdown should be closed`).toBeFalsy();
});
});
Expand Down
4 changes: 2 additions & 2 deletions e2e-app/src/app/tools.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { expect } from '@playwright/test';
* @param keys list of keys to send
* https://playwright.dev/docs/api/class-keyboard?_highlight=keyboard#keyboardpresskey-options
*/
export const sendKey = async (key: string) => {
export const sendKey = async (key: string, patchSafari = true) => {
// Add Alt modifier for Tabs and Safari
if (getBrowserName() === 'webkit' && ['Tab', 'Shift+Tab'].includes(key)) {
if (getBrowserName() === 'webkit' && ['Tab', 'Shift+Tab'].includes(key) && patchSafari) {
key = `Alt+${key}`;
}
await getPage().keyboard.press(key);
Expand Down
8 changes: 2 additions & 6 deletions e2e-app/src/app/tooltip/triggers/tooltip-triggers.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ test.describe('Tooltip Triggers', () => {
await expectTooltipToBeClosed(`Tooltip should close after clicking the outside element`);
});

test(`should close tooltip on blur`, async ({ browserName }) => {
test.skip(browserName === 'webkit');

test(`should close tooltip on blur`, async () => {
await getPage().click('#before');

await sendKey('Tab');
Expand All @@ -49,9 +47,7 @@ test.describe('Tooltip Triggers', () => {
await expectTooltipToBeClosed(`Tooltip should close after focusing outside the element`);
});

test(`should not close tooltip on blur after triggering element click`, async ({ browserName }) => {
test.skip(browserName === 'webkit');

test(`should not close tooltip on blur after triggering element click`, async () => {
await getPage().click('#before');

await sendKey('Tab');
Expand Down
3 changes: 1 addition & 2 deletions e2e-app/src/app/typeahead/focus/typeahead-focus.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ test.describe('Typeahead', () => {
await waitForTypeaheadFocused();
});

test(`should select element on tab`, async ({ browserName }) => {
test.skip(browserName === 'webkit');
test(`should select element on tab`, async () => {
await focusElement(SELECTOR_TYPEAHEAD);
await sendKey('Tab');
await waitForTypeaheadFocused();
Expand Down

0 comments on commit 861ec71

Please sign in to comment.