# Instructions - Following Playwright test failed. - Explain why, be concise, respect Playwright best practices. - Provide a snippet of code with the fix, if possible. # Test info - Name: loan-administration/documents/system-documents/delete_document.spec.ts >> Documents > System Documents >> delete document >> deletes a document - Location: tests/loan-administration/documents/system-documents/delete_document.spec.ts:21:9 # Error details ``` Error: Document creation failed — response URL: https://10.213.120.16/admin.php?edit=775%3Aadmin-credits-documents&customerId=1&templateId=1 ``` # Test source ```ts 1 | import { APIRequestContext } from "@playwright/test"; 2 | 3 | export type CreateDocumentApiOptions = { 4 | customerId: string; 5 | templateId: string; 6 | }; 7 | 8 | export class SystemDocumentsApi { 9 | constructor(private readonly request: APIRequestContext) {} 10 | 11 | async create(options: CreateDocumentApiOptions): Promise { 12 | const response = await this.request.get("admin.php", { 13 | params: { 14 | edit: "775:admin-credits-documents", 15 | customerId: options.customerId, 16 | templateId: options.templateId, 17 | }, 18 | }); 19 | 20 | const match = response.url().match(/nid=(\d+)/); 21 | 22 | if (!match || match[1] === "0") { > 23 | throw new Error( | ^ Error: Document creation failed — response URL: https://10.213.120.16/admin.php?edit=775%3Aadmin-credits-documents&customerId=1&templateId=1 24 | `Document creation failed — response URL: ${response.url()}`, 25 | ); 26 | } 27 | return match[1]; 28 | } 29 | 30 | async delete(id: string | number): Promise { 31 | await this.request.get("admin.php", { 32 | params: { 33 | edit: "775:admin-credits-documents", 34 | nid: String(id), 35 | delete: String(id), 36 | }, 37 | }); 38 | } 39 | } 40 | ```