UNPKG

playwright-fluent

Version:
51 lines (50 loc) 2.17 kB
"use strict"; 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 dom_actions_1 = require("../../../dom-actions"); const utils_1 = require("../../../../utils"); describe('handle is moving', () => { let browser = undefined; // eslint-disable-next-line @typescript-eslint/no-empty-function beforeEach(() => { }); afterEach(async () => { if (browser) { await browser.close(); } }); test('should detect that selector is moving - chromium', async () => { // Given browser = await playwright_1.chromium.launch({ headless: true }); 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, 'is-handle-moving.test1.html')}`; await page.goto(url); await (0, utils_1.sleep)(100); // wait for the animation to be started // When const selector = '#moving'; const handle = await page.$(selector); const isMoving = await SUT.isHandleMoving(handle); // Then expect(isMoving).toBe(true); }); test('should detect that selector is not moving - chromium', async () => { // Given browser = await playwright_1.chromium.launch({ headless: true }); 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, 'is-handle-moving.test2.html')}`; await page.goto(url); await (0, utils_1.sleep)(2000); // wait twice the animation duration // When const selector = '#moving'; const handle = await page.$(selector); const isMoving = await SUT.isHandleMoving(handle); // Then expect(isMoving).toBe(false); }); });