UNPKG

playwright-fluent

Version:
122 lines (121 loc) 4.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const path = tslib_1.__importStar(require("path")); const SUT = tslib_1.__importStar(require("../../playwright-fluent")); const utils_1 = require("../../../utils"); describe('Playwright Fluent - expectThat isDisabled', () => { let p; beforeEach(() => { p = new SUT.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should give back an error when selector does not exists', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-disabled.test.html')}`; const selector = 'foobar'; // When let result = undefined; try { await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isDisabled({ timeoutInMilliseconds: 2000 }); } catch (error) { result = error; } // Then expect(result && result.message).toContain("Selector 'foobar' was not found in DOM."); }); test('should give back an error when selector object does not exists', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-disabled.test.html')}`; const selector = p.selector('foobar'); // When let result = undefined; try { await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isDisabled({ timeoutInMilliseconds: 2000 }); } catch (error) { result = error; } // Then expect(result && result.message).toContain("Selector 'selector(foobar)' was not found in DOM."); }); test('should wait until selector exists and is disabled - chromium', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-disabled.test.html')}`; const selector = '#dynamically-added-input'; // When await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isDisabled(); // Then const isDisabled = await p.isDisabled(selector, utils_1.noWaitNoThrowOptions); expect(isDisabled).toBe(true); }); test('should wait until selector object exists and is disabled - chromium', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-disabled.test.html')}`; const selector = p.selector('input').withValue('dynamically added'); // When await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isDisabled(); // Then const isDisabled = await p.isDisabled(selector, utils_1.noWaitNoThrowOptions); expect(isDisabled).toBe(true); }); test('should wait until selector exists and is readOnly - chromium', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-disabled.test.html')}`; const selector = '#dynamically-added-readonly-input'; // When await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isDisabled(); // Then const isDisabled = await p.isDisabled(selector, utils_1.noWaitNoThrowOptions); expect(isDisabled).toBe(true); }); test('should wait until selector object exists and is read-only - chromium', async () => { // Given const url = `file:${path.join(__dirname, 'expect-is-disabled.test.html')}`; const selector = p.selector('input').withValue('dynamically added readonly input'); // When await p .withBrowser('chromium') .withOptions({ headless: false }) .withCursor() .navigateTo(url) .expectThatSelector(selector) .isDisabled(); // Then const isDisabled = await p.isDisabled(selector, utils_1.noWaitNoThrowOptions); expect(isDisabled).toBe(true); }); });