From fbb777ab5a04846cc3347ea92cd6e4f5ee71f6ba Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Thu, 7 Jan 2021 11:37:19 -0500 Subject: [PATCH] test(datetime): improve reliability of focus trap test (#22742) --- core/src/components/datetime/test/basic/e2e.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/core/src/components/datetime/test/basic/e2e.ts b/core/src/components/datetime/test/basic/e2e.ts index 7a3ea3347d..2c474f3a13 100644 --- a/core/src/components/datetime/test/basic/e2e.ts +++ b/core/src/components/datetime/test/basic/e2e.ts @@ -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');