Skip to content

Commit

Permalink
fix type issues and fix jest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurley14 committed Jun 22, 2021
1 parent b8af9f9 commit b18d076
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export const getUpdateRequest = () =>
body: {
status: 'closed',
ids: ['alert-1'],
indexName: '.alerts-observability-apm*',
index: '.alerts-observability-apm*',
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('updateAlertByIdRoute', () => {
body: {
status: 'closed',
ids: 'alert-1',
indexName: '.alerts-observability-apm*',
index: '.alerts-observability-apm*',
},
}),
context
Expand All @@ -76,7 +76,7 @@ describe('updateAlertByIdRoute', () => {
body: {
notStatus: 'closed',
ids: ['alert-1'],
indexName: '.alerts-observability-apm*',
index: '.alerts-observability-apm*',
},
}),
context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
superUser,
noKibanaPrivileges,
} from '../../../common/lib/authentication/users';
import type { User } from '../../../common/lib/authentication/types';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { getSpaceUrlPrefix } from '../../../common/lib/authentication/spaces';

Expand All @@ -34,13 +35,15 @@ export default ({ getService }: FtrProviderContext) => {
const SPACE1 = 'space1';
const SPACE2 = 'space2';

const getAPMIndexName = async (user) => {
const { body: indexNames } = await supertestWithoutAuth
const getAPMIndexName = async (user: User) => {
const {
body: indexNames,
}: { body: { index_name: string[] | undefined } } = await supertestWithoutAuth
.get(`${getSpaceUrlPrefix(SPACE1)}${ALERTS_INDEX_URL}`)
.auth(user.username, user.password)
.set('kbn-xsrf', 'true')
.expect(200);
const observabilityIndex = indexNames.index_name.find(
const observabilityIndex = indexNames?.index_name?.find(
(indexName) => indexName === '.alerts-observability-apm'
);
expect(observabilityIndex).to.eql('.alerts-observability-apm');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
superUser,
noKibanaPrivileges,
} from '../../../common/lib/authentication/users';
import type { User } from '../../../common/lib/authentication/types';
import { FtrProviderContext } from '../../../common/ftr_provider_context';
import { getSpaceUrlPrefix } from '../../../common/lib/authentication/spaces';

Expand All @@ -26,13 +27,15 @@ export default ({ getService }: FtrProviderContext) => {
const ALERTS_INDEX_URL = `${TEST_URL}/index`;
const SPACE1 = 'space1';

const getAPMIndexName = async (user) => {
const { body: indexNames } = await supertestWithoutAuth
const getAPMIndexName = async (user: User) => {
const {
body: indexNames,
}: { body: { index_name: string[] | undefined } } = await supertestWithoutAuth
.get(`${getSpaceUrlPrefix(SPACE1)}${ALERTS_INDEX_URL}`)
.auth(user.username, user.password)
.set('kbn-xsrf', 'true')
.expect(200);
const observabilityIndex = indexNames.index_name.find(
const observabilityIndex = indexNames?.index_name?.find(
(indexName) => indexName === '.alerts-observability-apm'
);
expect(observabilityIndex).to.eql('.alerts-observability-apm');
Expand Down

0 comments on commit b18d076

Please sign in to comment.