mirror of
https://github.com/grafana/grafana.git
synced 2025-01-06 22:23:19 -06:00
b8e7ef48d0
* Keybindings: No global keybindings on chromeless pages * simplify condition * Refactoring * Align name and file * Move logic into AppChrome * minor fix * Update Page.tsx * Fixing test * Fixed tests * More fixes * Fixed more tests * Fixing final test * Fixed search in old nav
47 lines
1.8 KiB
TypeScript
47 lines
1.8 KiB
TypeScript
import { render } from '@testing-library/react';
|
|
import React from 'react';
|
|
import { Route } from 'react-router-dom';
|
|
import { byRole, byTestId } from 'testing-library-selector';
|
|
|
|
import { selectors } from '@grafana/e2e-selectors';
|
|
import { locationService } from '@grafana/runtime';
|
|
import RuleEditor from 'app/features/alerting/unified/RuleEditor';
|
|
|
|
import { TestProvider } from './TestProvider';
|
|
|
|
export const ui = {
|
|
inputs: {
|
|
name: byRole('textbox', { name: /rule name name for the alert rule\./i }),
|
|
alertType: byTestId('alert-type-picker'),
|
|
dataSource: byTestId('datasource-picker'),
|
|
folder: byTestId('folder-picker'),
|
|
folderContainer: byTestId(selectors.components.FolderPicker.containerV2),
|
|
namespace: byTestId('namespace-picker'),
|
|
group: byTestId('group-picker'),
|
|
annotationKey: (idx: number) => byTestId(`annotation-key-${idx}`),
|
|
annotationValue: (idx: number) => byTestId(`annotation-value-${idx}`),
|
|
labelKey: (idx: number) => byTestId(`label-key-${idx}`),
|
|
labelValue: (idx: number) => byTestId(`label-value-${idx}`),
|
|
expr: byTestId('expr'),
|
|
},
|
|
buttons: {
|
|
save: byRole('button', { name: 'Save' }),
|
|
addAnnotation: byRole('button', { name: /Add info/ }),
|
|
addLabel: byRole('button', { name: /Add label/ }),
|
|
// alert type buttons
|
|
grafanaManagedAlert: byRole('button', { name: /Grafana managed/ }),
|
|
lotexAlert: byRole('button', { name: /Mimir or Loki alert/ }),
|
|
lotexRecordingRule: byRole('button', { name: /Mimir or Loki recording rule/ }),
|
|
},
|
|
};
|
|
|
|
export function renderRuleEditor(identifier?: string) {
|
|
locationService.push(identifier ? `/alerting/${identifier}/edit` : `/alerting/new`);
|
|
|
|
return render(
|
|
<TestProvider>
|
|
<Route path={['/alerting/new', '/alerting/:id/edit']} component={RuleEditor} />
|
|
</TestProvider>
|
|
);
|
|
}
|