Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit Tests for new o11y rules page #128576

Merged
merged 23 commits into from
Apr 20, 2022
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions x-pack/plugins/observability/public/hooks/use_fetch_rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,12 @@

import { useEffect, useState, useCallback } from 'react';
import { isEmpty } from 'lodash';
import { loadRules, Rule } from '@kbn/triggers-actions-ui-plugin/public';
import { loadRules } from '@kbn/triggers-actions-ui-plugin/public';
import { RULES_LOAD_ERROR } from '../pages/rules/translations';
import { FetchRulesProps } from '../pages/rules/types';
import { FetchRulesProps, RuleState } from '../pages/rules/types';
import { OBSERVABILITY_RULE_TYPES } from '../pages/rules/config';
import { useKibana } from '../utils/kibana_react';

interface RuleState {
isLoading: boolean;
data: Rule[];
error: string | null;
totalItemCount: number;
}

export function useFetchRules({
searchText,
ruleLastResponseFilter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,26 @@ const embeddableStartMock = {
},
};

const triggersActionsUiStartMock = {
createStart() {
return {
getAddAlertFlyout: jest.fn(),
ruleTypeRegistry: {
has: jest.fn(),
register: jest.fn(),
get: jest.fn(),
list: jest.fn(),
},
};
},
};

export const observabilityPublicPluginsStartMock = {
createStart() {
return {
cases: casesUiStartMock.createStart(),
embeddable: embeddableStartMock.createStart(),
triggersActionsUi: null,
triggersActionsUi: triggersActionsUiStartMock.createStart(),
data: null,
lens: null,
discover: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export function NoDataPrompt({
/>
</EuiButton>,
<EuiButtonEmpty color="primary">
<EuiLink href={documentationLink} target="_blank">
<EuiLink data-test-subj="documentationLink" href={documentationLink} target="_blank">
Documentation
</EuiLink>
</EuiButtonEmpty>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export function NoPermissionPrompt() {
}}
>
<EuiEmptyPrompt
data-test-subj="noPermissionPrompt"
color="plain"
hasBorder={true}
iconType="securityApp"
Expand Down
Loading