[v9.0.x] Alerting: use "find" to wait for expression editor to load (#50603)

Co-authored-by: Gilles De Mey <gilles.de.mey@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2022-06-10 15:21:32 +02:00
committed by GitHub
co-authored by Gilles De Mey
parent 83956baf2b
commit d00ba7d49b
@@ -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 });