Alerting: use "find" to wait for expression editor to load (#50602)

This commit is contained in:
Gilles De Mey 2022-06-10 14:58:15 +02:00 committed by GitHub
parent 99db588919
commit 5539bb4578
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,19 +148,21 @@ describe('RuleEditor', () => {
await renderRuleEditor();
await waitFor(() => expect(mocks.searchFolders).toHaveBeenCalled());
await waitFor(() => expect(mocks.api.discoverFeatures).toHaveBeenCalled());
await userEvent.type(await ui.inputs.name.find(), 'my great new rule');
await userEvent.click(await ui.buttons.lotexAlert.get());
await userEvent.click(await ui.buttons.lotexAlert.find());
const dataSourceSelect = ui.inputs.dataSource.get();
await userEvent.click(byRole('combobox').get(dataSourceSelect));
await clickSelectOption(dataSourceSelect, 'Prom (default)');
await waitFor(() => expect(mocks.api.fetchRulerRules).toHaveBeenCalled());
await userEvent.type(await ui.inputs.expr.find(), 'up == 1');
await userEvent.type(ui.inputs.name.get(), 'my great new rule');
await clickSelectOption(ui.inputs.namespace.get(), 'namespace2');
await clickSelectOption(ui.inputs.group.get(), 'group2');
await userEvent.type(ui.inputs.expr.get(), 'up == 1');
await userEvent.type(ui.inputs.annotationValue(0).get(), 'some summary');
await userEvent.type(ui.inputs.annotationValue(1).get(), 'some description');
@ -353,7 +355,7 @@ describe('RuleEditor', () => {
await clickSelectOption(ui.inputs.namespace.get(), 'namespace2');
await clickSelectOption(ui.inputs.group.get(), 'group2');
await userEvent.type(ui.inputs.expr.get(), 'up == 1');
await userEvent.type(await ui.inputs.expr.find(), 'up == 1');
// TODO remove skipPointerEventsCheck once https://github.com/jsdom/jsdom/issues/3232 is fixed
await userEvent.click(ui.buttons.addLabel.get(), { pointerEventsCheck: PointerEventsCheckLevel.Never });