File size: 1,527 Bytes
af1bee9 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | import { expect } from '@playwright/test';
import { MockApi, MOCK, Persona } from '../../api';
/** CX REST helpers (SCRIPT ONLY; never run: execution_hold, no CX mock pack). */
export class CXApi {
constructor(public api: MockApi) {}
rest(as: Persona, method: string, path: string, data?: unknown) { return this.api.call(as, method, path, data, MOCK.restBase); }
async restQ<T = any>(as: Persona, resource: string, q: string, extra = '') { const r = await this.rest(as, 'GET', `/${resource}?q=${encodeURIComponent(q)}${extra}`); expect(r.status, `GET ${resource}`).toBe(200); return (r.body as { items: T[] }).items; }
/** DR-CX-ACT-001: synthetic account + contact (fictitious address, example.invalid mail). */
async account(suffix: string) { return this.api.ok('sales_rep', 'POST', '/cx/accounts', { name: `ZZ Testco ${suffix}`, address: '1 Test Way, Testville (fictitious)', postalCode: '99999 (MOCK)' }); }
async contact(suffix: string, account: string) { return this.api.ok('sales_rep', 'POST', '/cx/contacts', { account, last: 'Testcontact', first: 'Beta', email: `beta.${suffix}@example.invalid`, phone: '+1 555 0100' }); }
/** DR-CX-OPP-001: opportunity with 2 revenue lines (10 x 100.00, 5 x 200.00). */
async opportunity(suffix: string) { return this.api.ok('sales_rep', 'POST', '/cx/opportunities', { name: `ZZ Opp ${suffix}`, account: `ZZ Testco ${suffix}`, lines: [{ product: 'ZZ-CX-ITEM-1', quantity: 10, price: 100 }, { product: 'ZZ-CX-ITEM-2', quantity: 5, price: 200 }] }); }
}
|