Adds complete initial codebase for the RJ Bulk Supplies fuel delivery backoffice: - Authentication pages and protected route layouts - Customer, supplier, fuel purchase, and delivery note management - Custom reporting and customer statement sending tools - Full UI component library and Tailwind styling - Server actions, API routes, and PocketBase integration - Development scripts and project configuration updates - Updated README and package metadata
53 lines
2.2 KiB
JavaScript
53 lines
2.2 KiB
JavaScript
import puppeteer from "puppeteer-core";
|
|
import { config } from "dotenv";
|
|
|
|
const TOK = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjb2xsZWN0aW9uSWQiOiJwYmNfMzE0MjYzNTgyMyIsImV4cCI6MTc4NDAyNjY5MiwiaWQiOiI4bjdrNmE1NmVrMng5ZzEiLCJyZWZyZXNoYWJsZSI6dHJ1ZSwidHlwZSI6ImF1dGgifQ.yUEfTJ-hHbjz21QjERs-uoJSp8wR8oYsKG5k7vPLBPU";
|
|
|
|
async function getAppToken() {
|
|
const res = await fetch("http://pocketbase-zinlbpsext2ro0lgb2558vfy.169.239.180.130.sslip.io/api/collections/users/auth-with-password", {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json" },
|
|
body: JSON.stringify({ identity: "david@rjbulk.local", password: "ChangeMe123!" }),
|
|
});
|
|
const data = await res.json();
|
|
return data.token;
|
|
}
|
|
|
|
async function shoot(url, name, viewport = { width: 1280, height: 900 }, action) {
|
|
const browser = await puppeteer.launch({
|
|
executablePath: "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
headless: "new",
|
|
args: ["--no-sandbox", "--disable-gpu"],
|
|
});
|
|
const page = await browser.newPage();
|
|
await page.setViewport(viewport);
|
|
const token = await getAppToken();
|
|
await page.setCookie({ name: "pb_auth", value: token, domain: "localhost", path: "/" });
|
|
await page.goto(`http://localhost:4004${url}`, { waitUntil: "networkidle2" });
|
|
if (action) {
|
|
await page.evaluate(action);
|
|
await new Promise((r) => setTimeout(r, 600));
|
|
}
|
|
await page.screenshot({ path: `/tmp/rjbulk-screens/${name}.png` });
|
|
await browser.close();
|
|
console.log(` ✓ ${name}.png`);
|
|
}
|
|
|
|
async function main() {
|
|
// New delivery note form
|
|
await shoot("/delivery-notes/new", "20-new-dn-form");
|
|
|
|
// Click the Auto-Number button
|
|
await shoot("/delivery-notes/new", "21-new-dn-form-autonumber", { width: 1280, height: 900 }, () => {
|
|
const btn = Array.from(document.querySelectorAll("button")).find((b) => b.textContent?.includes("Auto-Number"));
|
|
if (btn) btn.click();
|
|
});
|
|
|
|
// Open the customer combobox
|
|
await shoot("/delivery-notes/new", "22-new-dn-combobox-open", { width: 1280, height: 900 }, () => {
|
|
const inp = document.querySelector("input[role=combobox]");
|
|
if (inp) inp.focus();
|
|
});
|
|
}
|
|
|
|
main().catch((e) => { console.error(e); process.exit(1); });
|