UNPKG

playwright-fluent

Version:
94 lines (93 loc) 3.39 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("../../../fluent-api")); describe('Selector API - isDisabled', () => { let p; beforeEach(() => { p = new SUT.PlaywrightFluent(); }); afterEach(async () => { await p.close(); }); test('should return false on wrong selector', async () => { // Given const url = `file:${path.join(__dirname, 'is-disabled.test.html')}`; // prettier-ignore await p .withBrowser('chromium') .withOptions({ headless: true }) .withCursor() .navigateTo(url); // When const selector = p.selector('input').withValue('foo'); const result = await selector.isDisabled(); // Then expect(result).toBe(false); }); test('should return true when selector is disabled', async () => { // Given const url = `file:${path.join(__dirname, 'is-disabled.test.html')}`; // prettier-ignore await p .withBrowser('chromium') .withOptions({ headless: true }) .withCursor() .navigateTo(url); // When const selector = p.selector('input').withValue('I am disabled'); const result = await selector.isDisabled(); // Then expect(result).toBe(true); }); test('should return true when selector is disabled #2', async () => { // Given const url = `file:${path.join(__dirname, 'is-disabled.test.html')}`; // create selector before browser is launched const selector = p.selector('input').withValue('I am disabled'); // prettier-ignore await p .withBrowser('chromium') .withOptions({ headless: true }) .withCursor() .navigateTo(url); // When const result = await selector.isDisabled(); // Then expect(result).toBe(true); }); test('should return false when selector is enabled', async () => { // Given const url = `file:${path.join(__dirname, 'is-disabled.test.html')}`; // prettier-ignore await p .withBrowser('chromium') .withOptions({ headless: true }) .withCursor() .navigateTo(url); // When const selector = p.selector('input').withValue('I am enabled'); const result = await selector.isDisabled(); // Then expect(result).toBe(false); }); test('should wait for selector to be disabled', async () => { // Given const url = `file:${path.join(__dirname, 'is-disabled.test.html')}`; // prettier-ignore await p .withBrowser('chromium') .withOptions({ headless: true }) .withCursor() .navigateTo(url); const selector = p.selector('input#enabled-then-disabled-input'); const initialDisabledStatus = await selector.isDisabled(); // When await p.waitUntil(() => selector.isDisabled()); const finalDisabledStatus = await selector.isDisabled(); // Then expect(initialDisabledStatus).toBe(false); expect(finalDisabledStatus).toBe(true); }); });