From 5bf1c03b510aa2416636fb8b5f14057a37a10530 Mon Sep 17 00:00:00 2001 From: Pavel Feldman Date: Wed, 27 Oct 2021 15:12:54 -0800 Subject: [PATCH] test: add several toBeEnabled methods (#9821) --- .../playwright.expect.true.spec.ts | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/tests/playwright-test/playwright.expect.true.spec.ts b/tests/playwright-test/playwright.expect.true.spec.ts index c94d469635..0657acf6bf 100644 --- a/tests/playwright-test/playwright.expect.true.spec.ts +++ b/tests/playwright-test/playwright.expect.true.spec.ts @@ -96,6 +96,30 @@ test('should support toBeEditable, toBeEnabled, toBeDisabled, toBeEmpty', async await expect(locator).toBeEnabled(); }); + test('failed', async ({ page }) => { + await page.setContent(''); + const locator = page.locator('button'); + await expect(locator).toBeEnabled({ timeout: 500 }); + }); + + test('eventually enabled', async ({ page }) => { + await page.setContent(''); + const locator = page.locator('button'); + setTimeout(() => { + locator.evaluate(e => e.removeAttribute('disabled')).catch(() => {}); + }, 500); + await expect(locator).toBeEnabled(); + }); + + test('eventually disabled', async ({ page }) => { + await page.setContent(''); + const locator = page.locator('button'); + setTimeout(() => { + locator.evaluate(e => e.setAttribute('disabled', '')).catch(() => {}); + }, 500); + await expect(locator).not.toBeEnabled(); + }); + test('disabled', async ({ page }) => { await page.setContent(''); const locator = page.locator('button'); @@ -121,8 +145,11 @@ test('should support toBeEditable, toBeEnabled, toBeDisabled, toBeEmpty', async }); `, }, { workers: 1 }); - expect(result.passed).toBe(6); - expect(result.exitCode).toBe(0); + expect(result.passed).toBe(8); + expect(result.failed).toBe(1); + expect(result.exitCode).toBe(1); + const output = stripAscii(result.output); + expect(output).toContain('expect(locator).toBeEnabled({ timeout: 500 }'); }); test('should support toBeVisible, toBeHidden', async ({ runInlineTest }) => {