← back to CelebritySignatures

screenrecord/verify-murals.mjs

56 lines

import { createRequire } from 'node:module';
import fs from 'fs';
const require = createRequire(import.meta.url);
const { chromium } = require('/Users/macstudio3/.npm-global/lib/node_modules/playwright');
const PORT = fs.readFileSync('/tmp/cs_murals_port', 'utf8').trim();
const BASE = `http://127.0.0.1:${PORT}`;
const sleep = ms => new Promise(r => setTimeout(r, ms));

const b = await chromium.launch();
const ctx = await b.newContext();
const p = await ctx.newPage();
await ctx.route('**/*', r => { const u = r.request().url(); if (r.request().isNavigationRequest() && !u.includes('127.0.0.1:' + PORT) && !u.startsWith('data:')) return r.abort(); return r.continue(); });
const checkoutCalls = [];
p.on('response', r => { if (r.url().includes('/api/mural-checkout')) checkoutCalls.push(r.status()); });

await p.goto(BASE + '/murals', { waitUntil: 'domcontentloaded' });
await sleep(1500);

const gal = await p.evaluate(() => ({
  dataPlace: document.querySelectorAll('#gallery [data-place]').length,
  rosterTrig: document.querySelectorAll('#gallery [data-roster]').length,
  selMuralOpts: document.querySelectorAll('#selMural option').length,
}));
console.log('GALLERY:', JSON.stringify(gal));

// place a mural so `cur` is set (checkout needs cur.slug)
await p.locator('#gallery [data-place]').first().click().catch(() => {});
await sleep(600);

// (B) fields intact, no prior submit -> Pay should fire checkout
await p.locator('#orderForm [name=name]').fill('Rec Test').catch(() => {});
await p.locator('#orderForm [name=email]').fill('t@example.com').catch(() => {});
await p.locator('#payBtn').click().catch(() => {});
await sleep(1300);
const msgB = await p.locator('#orderMsg').textContent().catch(() => '');
console.log('(B) PAY intact -> checkoutCalls=' + JSON.stringify(checkoutCalls) + ' msg="' + (msgB || '').trim() + '"');

// (C) reproduce: refill, click "Request a quote instead" (submit -> f.reset()), then Pay
checkoutCalls.length = 0;
await p.locator('#orderForm [name=name]').fill('Rec Test').catch(() => {});
await p.locator('#orderForm [name=email]').fill('t@example.com').catch(() => {});
await p.locator('#orderForm button[type=submit]').click().catch(() => {});
await sleep(900);
const afterSubmit = await p.evaluate(() => ({
  name: document.querySelector('#orderForm [name=name]').value,
  email: document.querySelector('#orderForm [name=email]').value,
  msg: (document.querySelector('#orderMsg').textContent || '').trim(),
}));
console.log('(C) after quote-submit fields:', JSON.stringify(afterSubmit));
await p.locator('#payBtn').click().catch(() => {});
await sleep(900);
const msgC = await p.locator('#orderMsg').textContent().catch(() => '');
console.log('(C) PAY after submit -> checkoutCalls=' + JSON.stringify(checkoutCalls) + ' msg="' + (msgC || '').trim() + '"');

await b.close();