const test = require('node:test'); const assert = require('node:assert/strict'); const fs = require('node:fs'); test('background imports node registry and shared workflow definitions', () => { const source = fs.readFileSync('background.js', 'utf8'); assert.match(source, /background\/steps\/registry\.js/); assert.match(source, /data\/step-definitions\.js/); assert.match(source, /background\/workflow-engine\.js/); assert.match(source, /MultiPageStepDefinitions\?\.getNodes/); assert.match(source, /getStepRegistryForState\(state\)/); assert.match(source, /buildNodeRegistry\(definitions/); assert.match(source, /PLUS_PAYPAL_STEP_DEFINITIONS/); assert.match(source, /PLUS_GOPAY_STEP_DEFINITIONS/); assert.match(source, /NORMAL_PHONE_STEP_DEFINITIONS/); assert.match(source, /NORMAL_PHONE_BOUND_EMAIL_RELOGIN_STEP_DEFINITIONS/); assert.match(source, /PLUS_PAYPAL_PHONE_STEP_DEFINITIONS/); assert.match(source, /PLUS_PAYPAL_PHONE_BOUND_EMAIL_RELOGIN_STEP_DEFINITIONS/); assert.match(source, /PLUS_GOPAY_PHONE_STEP_DEFINITIONS/); assert.match(source, /PLUS_GOPAY_PHONE_BOUND_EMAIL_RELOGIN_STEP_DEFINITIONS/); assert.match(source, /PLUS_GPC_PHONE_STEP_DEFINITIONS/); assert.match(source, /PLUS_GPC_PHONE_BOUND_EMAIL_RELOGIN_STEP_DEFINITIONS/); assert.match(source, /plusPayPalStepRegistry/); assert.match(source, /plusGoPayStepRegistry/); assert.match(source, /normalPhoneStepRegistry/); assert.match(source, /normalPhoneBoundEmailReloginStepRegistry/); assert.match(source, /plusPayPalPhoneStepRegistry/); assert.match(source, /plusPayPalPhoneBoundEmailReloginStepRegistry/); assert.match(source, /plusGoPayPhoneStepRegistry/); assert.match(source, /plusGoPayPhoneBoundEmailReloginStepRegistry/); assert.match(source, /plusGpcPhoneStepRegistry/); assert.match(source, /plusGpcPhoneBoundEmailReloginStepRegistry/); assert.match(source, /const signupMethod = getSignupMethodForStepDefinitions\(state\);/); assert.match(source, /const useBoundEmailRelogin = signupMethod === SIGNUP_METHOD_PHONE/); assert.match(source, /useBoundEmailRelogin \? normalPhoneBoundEmailReloginStepRegistry : normalPhoneStepRegistry/); assert.match(source, /const paymentMethod = normalizePlusPaymentMethod\(state\?\.plusPaymentMethod\);/); assert.match(source, /paymentMethod === PLUS_PAYMENT_METHOD_GOPAY/); assert.match(source, /useBoundEmailRelogin \? plusGoPayPhoneBoundEmailReloginStepRegistry : plusGoPayPhoneStepRegistry/); assert.match(source, /useBoundEmailRelogin \? plusPayPalPhoneBoundEmailReloginStepRegistry : plusPayPalPhoneStepRegistry/); assert.match(source, /useBoundEmailRelogin \? plusGpcPhoneBoundEmailReloginStepRegistry : plusGpcPhoneStepRegistry/); assert.match(source, /activeStepRegistry\.executeNode\(normalizedNodeId,\s*\{/); assert.match(source, /'bind-email': \(state\) => step8Executor\.executeBindEmail\(state\)/); assert.match(source, /'fetch-bind-email-code': \(state\) => step8Executor\.executeFetchBindEmailCode\(state\)/); assert.match(source, /'relogin-bound-email': \(state\) => executeReloginBoundEmail\(state\)/); assert.match(source, /'fetch-bound-email-login-code': \(state\) => step8Executor\.executeBoundEmailLoginCode\(state\)/); assert.match(source, /'post-bound-email-phone-verification': \(state\) => step8Executor\.executeBoundEmailPostLoginPhoneVerification\(state\)/); assert.match(source, /background\/steps\/create-plus-checkout\.js/); assert.match(source, /background\/steps\/fill-plus-checkout\.js/); assert.match(source, /background\/steps\/gopay-manual-confirm\.js/); assert.match(source, /'gopay-subscription-confirm': \(state\) => goPayManualConfirmExecutor\.executeGoPayManualConfirm\(state\)/); assert.match(source, /background\/steps\/paypal-approve\.js/); assert.match(source, /background\/steps\/gopay-approve\.js/); assert.match(source, /background\/steps\/plus-return-confirm\.js/); }); test('GoPay approve executor receives debugger click and manual OTP helpers', () => { const source = fs.readFileSync('background.js', 'utf8'); assert.match(source, /createGoPayApproveExecutor\(\{[\s\S]*clickWithDebugger[\s\S]*requestGoPayOtpInput[\s\S]*\}\)/); assert.match(source, /REQUEST_GOPAY_OTP_INPUT/); });