# 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: src/manager/tests/e2e/invoice/invoice-issue-credit-note.spec.ts >> issues a partial credit note for an open invoice with multiple items by unselecting items - Location: src/manager/tests/e2e/invoice/invoice-issue-credit-note.spec.ts:29:7 # Error details ``` Error: expect(locator).toHaveText(expected) failed Locator: locator('.v-dialog:has([data-test-id="invoice-issue-credit-note-dialog"]):has(.v-overlay__content:not(.dialog-bottom-transition-enter-active))').locator('fieldset:has(legend:has-text("Items to credit"))').getByTestId('totals-summary-section').getByTestId('total-excl-vat-value') Expected: "€100.00" Received: "€700.00" Timeout: 30000ms Call log: - Expect "toHaveText" with timeout 30000ms - waiting for locator('.v-dialog:has([data-test-id="invoice-issue-credit-note-dialog"]):has(.v-overlay__content:not(.dialog-bottom-transition-enter-active))').locator('fieldset:has(legend:has-text("Items to credit"))').getByTestId('totals-summary-section').getByTestId('total-excl-vat-value') 64 × locator resolved to
€700.00
- unexpected value "€700.00" ``` ```yaml - text: €700.00 ``` # Test source ```ts 1 | import { expect, Locator } from '@playwright/test'; 2 | 3 | export async function expectMultiLocatorToHaveText(locator: Locator, text: string[] | undefined): Promise { 4 | if (!text) { 5 | await expectLocatorToBeEmpty(locator); 6 | return; 7 | } 8 | 9 | const expectedValue = RegExp(text.map((t) => t.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('|')); 10 | 11 | for (const element of await locator.all()) { 12 | await expectSingleLocatorToHaveText(element, expectedValue); 13 | } 14 | } 15 | 16 | export async function expectSingleLocatorToHaveText( 17 | locator: Locator, 18 | text: string | RegExp | undefined 19 | ): Promise { 20 | text > 21 | ? await expect(locator).toHaveText(text, { ignoreCase: true, useInnerText: true }) | ^ Error: expect(locator).toHaveText(expected) failed 22 | : await expectLocatorToBeEmpty(locator); 23 | } 24 | 25 | export async function expectLocatorToBeEmpty(locator: Locator): Promise { 26 | await expect(locator).toHaveText(/^(\s*-?\s*)$/); 27 | } 28 | ```