playwright-fluent
Version:
Fluent API around playwright
84 lines (83 loc) • 3.07 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
const playwright_fluent_1 = require("../../playwright-fluent");
const devices_1 = require("../../../devices");
describe('Playwright Fluent - withWindowSize', () => {
let p;
beforeEach(() => {
p = new playwright_fluent_1.PlaywrightFluent();
});
afterEach(async () => {
await p.close();
});
test('should target chromium in headfull with window size 800x600', async () => {
// Given
const browser = 'chromium';
const options = {
headless: false,
};
const url = 'https://reactstrap.github.io';
const size = devices_1.sizeOf._800x600;
// When
// prettier-ignore
await p
.withBrowser(browser)
.withOptions(options)
.withWindowSize(size)
.navigateTo(url);
// Then
const windowState = await p.getCurrentWindowState();
expect(Math.abs(windowState.outerWidth - size.width)).toBeLessThanOrEqual(10);
expect(Math.abs(windowState.outerHeight - size.height)).toBeLessThanOrEqual(10);
});
test('should target chromium in headfull with window size 1280x720', async () => {
// Given
const browser = 'chromium';
const options = {
headless: false,
};
const url = 'https://reactstrap.github.io';
const size = devices_1.sizeOf._1280x720;
// When
// prettier-ignore
await p
.withBrowser(browser)
.withOptions(options)
.withWindowSize(size)
.navigateTo(url);
// Then
const windowState = await p.getCurrentWindowState();
if (windowState.isMaximized) {
// eslint-disable-next-line no-console
console.log('1280x720 oversizes actual screen', windowState);
return;
}
expect(Math.abs(windowState.outerWidth - size.width)).toBeLessThanOrEqual(10);
expect(Math.abs(windowState.outerHeight - size.height)).toBeLessThanOrEqual(50);
});
test('should target chromium in headfull with window size 1600x900', async () => {
// Given
const browser = 'chromium';
const options = {
headless: false,
};
const url = 'https://reactstrap.github.io';
const size = devices_1.sizeOf._1600x900;
// When
// prettier-ignore
await p
.withBrowser(browser)
.withOptions(options)
.withWindowSize(size)
.navigateTo(url);
// Then
const windowState = await p.getCurrentWindowState();
if (windowState.isMaximized) {
// eslint-disable-next-line no-console
console.log('1600x900 oversizes actual screen', windowState);
return;
}
expect(Math.abs(windowState.outerWidth - size.width)).toBeLessThanOrEqual(300);
expect(Math.abs(windowState.outerHeight - size.height)).toBeLessThanOrEqual(200);
});
});
;