Skip to content

Commit

Permalink
add type for api integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
tsullivan committed May 4, 2020
1 parent 20b9dea commit 7b40fef
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
11 changes: 8 additions & 3 deletions x-pack/test/reporting/api/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
*/

import expect from '@kbn/expect';
import * as GenerationUrls from './generation_urls';
import { FtrProviderContext } from '../ftr_provider_context';
import { ReportingUsageStats } from '../services/reporting_api';
import * as GenerationUrls from './generation_urls';

interface UsageStats {
reporting: ReportingUsageStats;
}

// eslint-disable-next-line import/no-default-export
export default function({ getService }: FtrProviderContext) {
Expand All @@ -19,10 +24,10 @@ export default function({ getService }: FtrProviderContext) {
afterEach(() => reportingAPI.deleteAllReportingIndexes());

describe('initial state', () => {
let usage: any; // FIXME after https://github.com/elastic/kibana/pull/64841 is merged use ReportingUsageType
let usage: UsageStats;

before(async () => {
usage = await usageAPI.getUsageStats();
usage = (await usageAPI.getUsageStats()) as UsageStats;
});

it('shows reporting as available and enabled', async () => {
Expand Down
30 changes: 26 additions & 4 deletions x-pack/test/reporting/services/reporting_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,37 @@
import expect from '@kbn/expect';
// @ts-ignore no module definition
import { indexTimestamp } from '../../../legacy/plugins/reporting/server/lib/esqueue/helpers/index_timestamp';
import { ReportingUsageType } from '../../../legacy/plugins/reporting/server/usage/types';
import { FtrProviderContext } from '../ftr_provider_context';

function removeWhitespace(str: string) {
return str.replace(/\s/g, '');
interface PDFAppCounts {
app: {
[appName: string]: number;
};
layout: {
[layoutType: string]: number;
};
}

export interface ReportingUsageStats {
available: boolean;
enabled: boolean;
total: number;
last_7_days: {
total: number;
printable_pdf: PDFAppCounts;
[jobType: string]: any;
};
printable_pdf: PDFAppCounts;
status: any;
[jobType: string]: any;
}

interface UsageStats {
reporting: ReportingUsageType;
reporting: ReportingUsageStats;
}

function removeWhitespace(str: string) {
return str.replace(/\s/g, '');
}

export function ReportingAPIProvider({ getService }: FtrProviderContext) {
Expand Down

0 comments on commit 7b40fef

Please sign in to comment.