test(cli): refactor tests for async render utilities (#23252)

This commit is contained in:
Tommaso Sciortino
2026-03-20 20:08:29 +00:00
committed by GitHub
parent 86a3a913b5
commit 6c78eb7a39
198 changed files with 3592 additions and 4802 deletions

View File

@@ -82,10 +82,9 @@ describe('CloudFreePrivacyNotice', () => {
updateDataCollectionOptIn,
});
const { lastFrame, waitUntilReady, unmount } = render(
const { lastFrame, unmount } = await render(
<CloudFreePrivacyNotice config={mockConfig} onExit={onExit} />,
);
await waitUntilReady();
expect(lastFrame()).toContain(expectedText);
unmount();
@@ -115,10 +114,9 @@ describe('CloudFreePrivacyNotice', () => {
updateDataCollectionOptIn,
});
const { waitUntilReady, unmount } = render(
const { waitUntilReady, unmount } = await render(
<CloudFreePrivacyNotice config={mockConfig} onExit={onExit} />,
);
await waitUntilReady();
const keypressHandler = mockedUseKeypress.mock.calls[0][0];
await act(async () => {
@@ -145,10 +143,9 @@ describe('CloudFreePrivacyNotice', () => {
])(
'calls correct functions on selecting "$label"',
async ({ selection }) => {
const { waitUntilReady, unmount } = render(
const { waitUntilReady, unmount } = await render(
<CloudFreePrivacyNotice config={mockConfig} onExit={onExit} />,
);
await waitUntilReady();
const onSelectHandler =
mockedRadioButtonSelect.mock.calls[0][0].onSelect;

View File

@@ -25,10 +25,9 @@ describe('CloudPaidPrivacyNotice', () => {
});
it('renders correctly', async () => {
const { lastFrame, waitUntilReady, unmount } = render(
const { lastFrame, unmount } = await render(
<CloudPaidPrivacyNotice onExit={onExit} />,
);
await waitUntilReady();
expect(lastFrame()).toContain('Vertex AI Notice');
expect(lastFrame()).toContain('Service Specific Terms');
@@ -37,10 +36,9 @@ describe('CloudPaidPrivacyNotice', () => {
});
it('exits on Escape', async () => {
const { waitUntilReady, unmount } = render(
const { waitUntilReady, unmount } = await render(
<CloudPaidPrivacyNotice onExit={onExit} />,
);
await waitUntilReady();
const keypressHandler = mockedUseKeypress.mock.calls[0][0];
await act(async () => {

View File

@@ -25,10 +25,9 @@ describe('GeminiPrivacyNotice', () => {
});
it('renders correctly', async () => {
const { lastFrame, waitUntilReady, unmount } = render(
const { lastFrame, unmount } = await render(
<GeminiPrivacyNotice onExit={onExit} />,
);
await waitUntilReady();
expect(lastFrame()).toContain('Gemini API Key Notice');
expect(lastFrame()).toContain('By using the Gemini API');
@@ -37,10 +36,9 @@ describe('GeminiPrivacyNotice', () => {
});
it('exits on Escape', async () => {
const { waitUntilReady, unmount } = render(
const { waitUntilReady, unmount } = await render(
<GeminiPrivacyNotice onExit={onExit} />,
);
await waitUntilReady();
const keypressHandler = mockedUseKeypress.mock.calls[0][0];
await act(async () => {

View File

@@ -69,10 +69,9 @@ describe('PrivacyNotice', () => {
authType,
} as unknown as ContentGeneratorConfig);
const { lastFrame, waitUntilReady, unmount } = render(
const { lastFrame, unmount } = await render(
<PrivacyNotice config={mockConfig} onExit={onExit} />,
);
await waitUntilReady();
expect(lastFrame()).toContain(expectedComponent);
unmount();