test(datetime): improve reliability of focus trap test (#22742)

This commit is contained in:
Liam DeBeasi
2021-01-07 11:37:19 -05:00
committed by GitHub
parent 67b0853b28
commit fbb777ab5a

View File

@ -5,6 +5,11 @@ const getActiveElementText = async (page) => {
return await page.evaluate(el => el && el.textContent, activeElement);
}
const getActiveElementClass = async (page) => {
const activeElement = await page.evaluateHandle(() => document.activeElement);
return await page.evaluate(el => el && el.className, activeElement);
}
test('datetime/picker: focus trap', async () => {
const page = await newE2EPage({ url: '/src/components/datetime/test/basic?ionic:_testing=true' });
await page.click('#datetime-part');
@ -15,7 +20,7 @@ test('datetime/picker: focus trap', async () => {
expect(datetime).not.toBe(null);
// TODO fix
await page.waitFor(100);
await page.waitFor(250);
await page.keyboard.press('Tab');
@ -26,8 +31,8 @@ test('datetime/picker: focus trap', async () => {
await page.keyboard.press('Tab');
await page.keyboard.up('Shift');
const activeElementTextTwo = await getActiveElementText(page);
expect(activeElementTextTwo).toEqual('1920');
const activeElementClass = await getActiveElementClass(page);
expect(activeElementClass).toEqual('picker-opt');
await page.keyboard.press('Tab');