Skip to content
Snippets Groups Projects
Commit 2878ccbe authored by Jens Grochtdreis's avatar Jens Grochtdreis
Browse files

Screenshot Spec erweitert und korrigiert

parent 9f1bc24f
Branches
No related tags found
No related merge requests found
const playwright = require('playwright'); const playwright = require('playwright');
const { test} = require('@playwright/test'); const { test,expect} = require('@playwright/test');
test("Screenshot Marketingseite", async({ page }) => { test("Screenshot Marketingseite", async({ page }) => {
await page.goto("https://www.tatort-game.de/index.html"); await page.goto("https://www.tatort-game.de/index.html");
...@@ -8,8 +8,12 @@ test("Screenshot Marketingseite", async({ page }) => { ...@@ -8,8 +8,12 @@ test("Screenshot Marketingseite", async({ page }) => {
test("SWR Startseite", async({ page }) => { test("SWR Startseite", async({ page }) => {
await page.goto("https://www.swr.de/index.html"); await page.goto("https://www.swr.de/index.html");
await page.screenshot({ path: "screenshots/swr/startseite-full.png", fullPage: true }); // Chill until the network is idle
await page.screenshot({ path: "screenshots/swr/startseite.png", fullPage: false }); await page.waitForLoadState('networkidle');
await page.evaluate(scroll, {direction: "down", speed: "slow"});
// await page.evaluate(scroll, {direction: "up", speed: "fast"});
await expect(page).toHaveScreenshot({ path: "screenshots/swr/startseite.png", fullPage: false });
await expect(page).toHaveScreenshot({ path: "screenshots/swr/startseite-full.png", fullPage: true });
}) })
test("SWR Logo", async({ page }) => { test("SWR Logo", async({ page }) => {
...@@ -32,3 +36,18 @@ test("Pagination", async({ page }) => { ...@@ -32,3 +36,18 @@ test("Pagination", async({ page }) => {
await page.goto("http://localhost:3020/components/preview/pagination--default"); await page.goto("http://localhost:3020/components/preview/pagination--default");
await page.locator('.pagination').screenshot({ path: 'screenshots/swr/module/pagination/pagination.png' }); await page.locator('.pagination').screenshot({ path: 'screenshots/swr/module/pagination/pagination.png' });
}) })
let scroll = async (args) => {
const {direction, speed} = args;
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const scrollHeight = () => document.body.scrollHeight;
const start = direction === "down" ? 0 : scrollHeight();
const shouldStop = (position) => direction === "down" ? position > scrollHeight() : position < 0;
const increment = direction === "down" ? 100 : -100;
const delayTime = speed === "slow" ? 50 : 10;
console.error(start, shouldStop(start), increment)
for (let i = start; !shouldStop(i); i += increment) {
window.scrollTo(0, i);
await delay(delayTime);
}
};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment