playwright-fluent
Version:
Fluent API around playwright
80 lines (79 loc) • 4.08 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const path = tslib_1.__importStar(require("path"));
const playwright_1 = require("playwright");
const SUT = tslib_1.__importStar(require("../index"));
const click_on_handle_1 = require("../click-on-handle");
const has_handle_focus_1 = require("../../has-handle-focus");
const dom_actions_1 = require("../../../dom-actions");
const utils_1 = require("../../../../utils");
describe.skip('click on handle', () => {
let browser = undefined;
// eslint-disable-next-line @typescript-eslint/no-empty-function
beforeEach(() => { });
afterEach(async () => {
if (browser) {
await browser.close();
}
});
test('should throw when selector is undefined - chrome', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: true, executablePath: (0, utils_1.getChromePath)() });
const browserContext = await browser.newContext();
const page = await browserContext.newPage();
const url = `file:${path.join(__dirname, 'click-on-handle.test.html')}`;
await page.goto(url);
// When
// Then
const expectedError = new Error("Cannot click on 'foobar' because selector was not found in DOM");
await SUT.clickOnHandle(undefined, 'foobar', page, click_on_handle_1.defaultClickOptions).catch((error) => expect(error).toMatchObject(expectedError));
});
test('should throw when selector is null - chrome', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: true, executablePath: (0, utils_1.getChromePath)() });
const browserContext = await browser.newContext({ viewport: null });
const page = await browserContext.newPage();
const url = `file:${path.join(__dirname, 'click-on-handle.test.html')}`;
await page.goto(url);
// When
// Then
const expectedError = new Error("Cannot click on 'foobar' because selector was not found in DOM");
await SUT.clickOnHandle(null, 'foobar', page, click_on_handle_1.defaultClickOptions).catch((error) => expect(error).toMatchObject(expectedError));
});
test('should wait for the selector to be enabled - chrome', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: true, executablePath: (0, utils_1.getChromePath)() });
const browserContext = await browser.newContext({ viewport: null });
const page = await browserContext.newPage();
await (0, dom_actions_1.showMousePosition)(page);
const url = `file:${path.join(__dirname, 'click-on-handle.test.html')}`;
await page.goto(url);
// When
const selector = '#disabled-then-enabled';
const handle = await page.$('#disabled-then-enabled');
await SUT.clickOnHandle(handle, selector, page, click_on_handle_1.defaultClickOptions);
// Then
expect(handle).toBeDefined();
expect(await (0, has_handle_focus_1.hasHandleFocus)(handle)).toBe(true);
});
test('should wait for the selector to be enabled (verbose) - chrome', async () => {
// Given
browser = await playwright_1.chromium.launch({ headless: true, executablePath: (0, utils_1.getChromePath)() });
const browserContext = await browser.newContext({ viewport: null });
const page = await browserContext.newPage();
await (0, dom_actions_1.showMousePosition)(page);
const url = `file:${path.join(__dirname, 'click-on-handle.test.html')}`;
await page.goto(url);
// When
const selector = '#disabled-then-enabled';
const handle = await page.$('#disabled-then-enabled');
const options = {
...click_on_handle_1.defaultClickOptions,
};
await SUT.clickOnHandle(handle, selector, page, options);
// Then
expect(handle).toBeDefined();
expect(await (0, has_handle_focus_1.hasHandleFocus)(handle)).toBe(true);
});
});
;