20c03acdaa
Deploy to route.crispygoat.com / deploy (push) Successful in 3m26s
The script kept failing on deploy (ESM vs CJS issue, plus the script file wasn't being shipped). User decided not to worry about it. The 26 manual rows will remain in the sheet without Entry IDs; the cron will retry them with a manual cleanup of any duplicates if needed.
61 lines
2.5 KiB
JavaScript
61 lines
2.5 KiB
JavaScript
// Reproduce the Test Connection error on prod.
|
|
import { chromium } from "playwright";
|
|
|
|
const BASE = process.env.BASE_URL ?? "http://crispygoat.com:3100";
|
|
|
|
const browser = await chromium.launch();
|
|
const ctx = await browser.newContext({ viewport: { width: 1100, height: 900 } });
|
|
const page = await ctx.newPage();
|
|
|
|
page.on("console", (msg) => {
|
|
const t = msg.type();
|
|
if (t === "error" || t === "warning") console.log(`[browser:${t}]`, msg.text());
|
|
});
|
|
page.on("pageerror", (err) => console.log(`[browser:pageerror]`, err.message, err.stack?.split("\n")[1]));
|
|
|
|
console.log("→ Opening /admin/water-log/settings");
|
|
await page.goto(`${BASE}/admin/water-log/settings`, { waitUntil: "domcontentloaded", timeout: 60000 });
|
|
console.log("→ Current URL:", page.url());
|
|
|
|
// Sign in via dev_login button (only visible when NODE_ENV != production).
|
|
const platformBtn = page.getByRole("button", { name: /^Platform$/ });
|
|
const hasDev = await platformBtn.isVisible().catch(() => false);
|
|
console.log("→ Dev login available:", hasDev);
|
|
|
|
if (hasDev) {
|
|
await platformBtn.click();
|
|
await page.waitForURL((url) => !url.toString().includes("/login"), { timeout: 15000 });
|
|
console.log("→ Signed in, now at:", page.url());
|
|
await page.goto(`${BASE}/admin/water-log/settings`, { waitUntil: "domcontentloaded", timeout: 60000 });
|
|
}
|
|
|
|
await page.getByText(/Smartsheet Integration/i).first().waitFor({ state: "visible", timeout: 30000 });
|
|
console.log("→ Smartsheet card visible");
|
|
|
|
// Snapshot inputs.
|
|
const sheetVal = await page.locator("#smartsheet-sheet").inputValue();
|
|
const tokenPlaceholder = await page.locator("#smartsheet-token").getAttribute("placeholder");
|
|
console.log("→ Sheet input value:", sheetVal);
|
|
console.log("→ Token placeholder:", tokenPlaceholder);
|
|
|
|
// Click Test Connection.
|
|
const testBtn = page.getByRole("button", { name: /test connection/i });
|
|
await testBtn.click();
|
|
console.log("→ Test Connection clicked, waiting up to 30s for response");
|
|
|
|
// Watch the test result panel.
|
|
try {
|
|
await page.getByText(/connected to/i).waitFor({ state: "visible", timeout: 30000 });
|
|
console.log("→ Test Connection succeeded (green panel appeared)");
|
|
} catch {
|
|
console.log("→ No green panel appeared within 30s. Looking for error panel…");
|
|
const errorTxt = await page.locator('[role="alert"]').allTextContents();
|
|
console.log("→ Error/alert text:", errorTxt);
|
|
}
|
|
|
|
// Also screenshot.
|
|
await page.screenshot({ path: "/tmp/test-conn-repro.png", fullPage: true });
|
|
console.log("→ Screenshot saved");
|
|
|
|
await browser.close();
|
|
console.log("✓ Done"); |