Files
loki/scripts/notif-shot.mjs
T

26 lines
1.3 KiB
JavaScript

import fs from "node:fs";
import path from "node:path";
import { chromium } from "playwright";
const envLines = fs.readFileSync(".env.local", "utf8").split(/\r?\n/);
for (const line of envLines) {
const m = line.match(/^([A-Z_]+)=(.*)$/);
if (m && !process.env[m[1]]) process.env[m[1]] = m[2].replace(/^"|"$/g, "");
}
const pw = process.env.LOCAL_AUTH_PASSWORD;
const outDir = ".tmp/notif";
fs.mkdirSync(outDir, { recursive: true });
const browser = await chromium.launch({ headless: true, executablePath: "/usr/bin/google-chrome" });
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } });
const page = await ctx.newPage();
await page.goto("http://localhost:3000/sign-in?callbackUrl=/settings#notifications", { waitUntil: "networkidle" });
await page.waitForTimeout(1200);
await page.getByRole("button", { name: /owner key/i }).click();
await page.waitForTimeout(500);
await page.locator('input[type="password"]').first().fill(pw);
await page.getByRole("button", { name: /sign in as owner/i }).click();
await page.waitForURL((u) => !u.pathname.startsWith("/sign-in"), { timeout: 15000 });
await page.goto("http://localhost:3000/settings#notifications", { waitUntil: "load" });
await page.waitForTimeout(2000);
await page.screenshot({ path: path.join(outDir, "settings-notifications.png"), fullPage: false });
await browser.close();