← back to Dw Signup Fulfillment

verification/tk11283/live-smoke.cjs

55 lines

'use strict';
const fs=require('node:fs'),path=require('node:path'),assert=require('node:assert/strict');
const {chromium}=require('/Users/macstudio3/Projects/Designer-Wallcoverings/node_modules/playwright');
async function main(){
  const browser=await chromium.launch({headless:true});
  const context=await browser.newContext({viewport:{width:1280,height:900},recordVideo:{dir:path.join(__dirname,'recordings/live')}});
  let reply='rate',applications=0;
  await context.route('**/*',route=>{
    const request=route.request();
    if(request.url()==='https://signup.designerwallcoverings.com/trade/apply'){
      applications++;
      return route.fulfill({status:reply==='rate'?429:200,contentType:'application/json',body:JSON.stringify(reply==='rate'?{ok:false,error:'rate_limited'}:{ok:true,id:'TRADE-AUDIT-INTERCEPTED',status:'pending',linked:true})});
    }
    if(!['GET','HEAD'].includes(request.method()))return route.abort();
    return route.continue();
  });
  const page=await context.newPage();
  const checks=[];
  function pass(name,detail){checks.push({name,verdict:'PASS',detail});console.log('PASS '+name);}
  try{
    await page.goto('https://www.designerwallcoverings.com/pages/trade-only-benefits?signin_review=TK11283',{waitUntil:'domcontentloaded',timeout:60000});
    const account=page.locator('a[title="Account"]').first();await account.click();
    await page.locator('#dw-signin.dwsm-open').waitFor();
    assert.equal(await page.locator('#dw-signin form').count(),0);
    assert.equal(await page.locator('[data-dwsm-designer]').getAttribute('href'),'/pages/trade-only-benefits#dwTradeApplication');
    await page.screenshot({path:path.join(__dirname,'live-account-modal.png')});
    pass('live account entry','Actual header opens new modal; designer action points to the complete form.');
    await page.locator('[data-dwsm-designer]').click();
    const submit=page.locator('#dwTradeForm button[type=submit]');await submit.click();assert.equal(applications,0);
    await page.locator('#dwTaName').fill('DW Test - intercepted only');
    await page.locator('#dwTaEmail').fill('audit@example.invalid');
    await page.locator('#dwTaPhone').fill('202-555-0100');
    await page.locator('#dwTaBusiness').fill('Intercepted Test Studio');
    await page.locator('#dwTaRole').selectOption({label:'Interior designer'});
    await page.locator('#dwTaLocation').fill('Los Angeles, CA');
    await page.locator('[name=terms_acknowledged]').check();
    await submit.click();await page.waitForFunction(()=>document.querySelector('#dwTradeStatus').dataset.state==='error');
    assert.equal(await page.locator('#dwTaEmail').inputValue(),'audit@example.invalid');
    assert(await page.locator('#dwTradeNext').isHidden());pass('live failure handling','Intercepted HTTP 429 keeps form values and shows error, not account success.');
    reply='linked';await submit.click();await page.locator('#dwTradeNext').waitFor({state:'visible'});
    assert.match(await page.locator('#dwTradeNext').innerText(),/approval is still pending/);
    await page.setViewportSize({width:390,height:844});await page.locator('#dwTradeNext').scrollIntoViewIfNeeded();
    await page.screenshot({path:path.join(__dirname,'live-mobile-account-ready.png')});
    pass('live success UI','Intercepted linked/pending result renders account-ready and sign-in next step on live markup.');
    await page.locator('#dwTradeLogin').click();
    await page.waitForURL(/shopify\.com\/authentication\/1541177456\/login/,{timeout:60000});
    const email=page.locator('input[type=email]').first();await email.waitFor();assert.equal(await email.inputValue(),'audit@example.invalid');
    await page.screenshot({path:path.join(__dirname,'live-shopify-handoff.png')});
    pass('live Shopify handoff','Clicked live completion CTA; Shopify email input prefills application email. No OTP requested.');
    const proof={timestamp:new Date().toISOString(),environment:'Live published theme; application responses intercepted; no authentication submit',checks,interceptedApplications:applications,realApplications:0,emailsSent:0,orders:0,verdict:'PASS for published UI and hosted login entry',skipped:['Real account creation, OTP completion, persisted account/session and checkout benefit verification.']};
    fs.writeFileSync(path.join(__dirname,'live-smoke.json'),JSON.stringify(proof,null,2)+'\n');
  }finally{await context.close();await browser.close();}
}
main().catch(e=>{console.error(e.stack);process.exitCode=1;});