scaffolder: fix test

Signed-off-by: Vincenzo Scamporlino <vincenzos@spotify.com>
This commit is contained in:
Vincenzo Scamporlino
2025-06-13 10:47:13 +02:00
parent 2c77bd52d7
commit 2977da8602
@@ -21,7 +21,7 @@ import {
renderInTestApp,
TestApiRegistry,
} from '@backstage/test-utils';
import { act, fireEvent } from '@testing-library/react';
import { fireEvent, waitFor } from '@testing-library/react';
import {
ScaffolderApi,
scaffolderApiRef,
@@ -127,14 +127,10 @@ describe('TemplateWizardPage', () => {
});
// Go to the final page
await act(async () => {
fireEvent.click(await findByRole('button', { name: 'Review' }));
});
fireEvent.click(await findByRole('button', { name: 'Review' }));
// Create the software
await act(async () => {
fireEvent.click(await findByRole('button', { name: 'Create' }));
});
fireEvent.click(await findByRole('button', { name: 'Create' }));
// The "Next Step" button should have fired an event
expect(analyticsApi.captureEvent).toHaveBeenCalledWith(
@@ -148,15 +144,20 @@ describe('TemplateWizardPage', () => {
);
// And the "Create" button should have fired an event
expect(analyticsApi.captureEvent).toHaveBeenCalledWith(
expect.objectContaining({
action: 'create',
subject: 'expected-name',
context: expect.objectContaining({
entityRef: 'template:default/test',
await waitFor(() =>
expect(analyticsApi.captureEvent).toHaveBeenCalledWith(
expect.objectContaining({
action: 'create',
subject: 'Task has been created',
attributes: {
templateSteps: 1,
},
context: expect.objectContaining({
entityRef: 'template:default/test',
}),
value: 120,
}),
value: 120,
}),
),
);
});