Test: TS-07 returning user with existing display_name skips set-name
Inverse coverage for the auth path: TS-01..TS-06 all wipe the customer row (drop_customer=true) so every OTP path lands on the new-user set-name branch. TS-07 instead seeds an existing identified customer (phone + display_name + is_anonymous=false) and verifies the OTP sign-in returns the existing row unchanged via resolveCustomerForIdentity branch 1, so /auth/set-name is never shown. Adds: * /internal/_test/seed-customer endpoint — upserts a customer with phone + display_name + is_anonymous=false. * client_app/.maestro/scripts/seed_customer.js helper. * client_app/.maestro/flows/ts-07_returning_existing_name_skips_setname.yaml. * TS-07 scenario doc + coverage-map row in requirement/phase4-customer-flow.md. The flow asserts the "halo, <name>" greeting on the returning-user home variant (identified users always land on _SHomeReturningView regardless of chat history) plus an explicit notVisible on "Siapa namamu" as a belt-and-braces check. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -306,6 +306,29 @@ export const internalTestRoutes = async (fastify) => {
|
||||
return { ok: true, payment_id: row.id, ...row }
|
||||
})
|
||||
|
||||
// Upsert a customer row with phone + display_name (is_anonymous=false).
|
||||
// Used by Maestro TS-07 to set up the "returning user already has a name"
|
||||
// precondition: a real returning OTP sign-in must skip the set-name screen
|
||||
// because resolveCustomerForIdentity returns the existing row unchanged.
|
||||
//
|
||||
// Body: { phone, display_name }
|
||||
fastify.post('/seed-customer', async (request, reply) => {
|
||||
const phone = request.body?.phone
|
||||
const display_name = request.body?.display_name
|
||||
if (!phone || !display_name) {
|
||||
return reply.code(400).send({ error: 'phone and display_name required in body' })
|
||||
}
|
||||
const [row] = await sql`
|
||||
INSERT INTO customers (phone, display_name, is_anonymous)
|
||||
VALUES (${phone}, ${display_name}, false)
|
||||
ON CONFLICT (phone) DO UPDATE
|
||||
SET display_name = EXCLUDED.display_name,
|
||||
is_anonymous = false
|
||||
RETURNING id, phone, display_name, is_anonymous
|
||||
`
|
||||
return { ok: true, ...row }
|
||||
})
|
||||
|
||||
// Mark EVERY mitra row online. Used by Maestro flows as a setup step to
|
||||
// ensure a clean known-good state regardless of what previous tests did
|
||||
// (e.g. force-mitra-offline leaving the dev DB with no online mitras).
|
||||
|
||||
Reference in New Issue
Block a user