Skip to content

Commit 64e9dbc

Browse files
committed
test(plugin-grid): read the bulk confirm sentence's exact bytes
findByText normalises the no-break space Intl writes before a de-DE currency sign in the node text but not in the matcher string, so the right German sentence did not match. Read the dialog description's textContent instead. Claude-Session: https://claude.ai/code/session_01SMps7wq7rBTk53e8KTSEup Co-authored-by: Claude <noreply@anthropic.com>
1 parent 9207142 commit 64e9dbc

1 file changed

Lines changed: 20 additions & 5 deletions

File tree

‎ui/packages/plugin-grid/src/__tests__/bulkConfirmLocale-26307.test.tsx‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*/
2424
import { describe, it, expect, vi, beforeAll, afterEach } from 'vitest';
2525
import React from 'react';
26-
import { render, screen, cleanup, fireEvent } from '@testing-library/react';
26+
import { render, screen, cleanup, fireEvent, waitFor } from '@testing-library/react';
2727
import '@testing-library/jest-dom';
2828
import { I18nProvider, LocalizationProvider } from '@object-ui/i18n';
2929
import type { BulkActionDef, BulkActionParam } from '@object-ui/types';
@@ -100,16 +100,31 @@ function openDialog(tenantLocale: string | undefined) {
100100
);
101101
}
102102

103+
/**
104+
* The confirm step's sentence, read as the dialog's description `textContent`.
105+
* Not `findByText`: its default normalizer turns the no-break space `Intl`
106+
* writes before a de-DE `€` into a plain space in the node text, while the
107+
* matcher string keeps it, so the right sentence would not match.
108+
*/
109+
async function confirmSentence(): Promise<string | null> {
110+
fireEvent.click(await screen.findByRole('button', { name: 'Next' }));
111+
const dialog = await screen.findByRole('dialog');
112+
const description = await waitFor(() => {
113+
const el = document.getElementById(dialog.getAttribute('aria-describedby') ?? '');
114+
expect(el?.textContent).toMatch(/^Set the amount to /);
115+
return el;
116+
});
117+
return description?.textContent ?? null;
118+
}
119+
103120
describe('BulkActionDialog formats its confirm sentence in the display locale (objectstack#26307)', () => {
104121
it('formats a currency hole in the tenant display locale', async () => {
105122
openDialog('de-DE');
106-
fireEvent.click(await screen.findByRole('button', { name: 'Next' }));
107-
expect(await screen.findByText(`Set the amount to ${money('de-DE')} on 2 records?`)).toBeInTheDocument();
123+
expect(await confirmSentence()).toBe(`Set the amount to ${money('de-DE')} on 2 records?`);
108124
});
109125

110126
it('formats in the UI language when no tenant locale is set', async () => {
111127
openDialog(undefined);
112-
fireEvent.click(await screen.findByRole('button', { name: 'Next' }));
113-
expect(await screen.findByText(`Set the amount to ${money('en')} on 2 records?`)).toBeInTheDocument();
128+
expect(await confirmSentence()).toBe(`Set the amount to ${money('en')} on 2 records?`);
114129
});
115130
});

0 commit comments

Comments
 (0)