Skip to content

Commit

Permalink
fix functional test and remove commented code
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarezmelissa87 committed Sep 15, 2022
1 parent ca680ce commit 06de36d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
),
},
{
'data-test-subj': 'aiopsSpikeAnalysisTableColumnGroup',
'data-test-subj': 'aiopsSpikeAnalysisGroupsTableColumnGroup',
field: 'group',
name: i18n.translate(
'xpack.aiops.correlations.failedTransactions.correlationsTable.groupLabel',
Expand Down Expand Up @@ -155,7 +155,7 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
<>
<EuiBadge
key={`$more-id`}
data-test-subj="aiopsSpikeAnalysisTableColumnGroupBadge"
data-test-subj="aiopsSpikeAnalysisGroupsTableColumnGroupBadge"
color="hollow"
>
+{Object.keys(repeatedValues).length} more
Expand All @@ -166,26 +166,11 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
}
return valuesBadges;
},
// render: (_, { group }) => (
// <EuiCodeBlock
// aria-label={i18n.translate('xpack.aiops.correlations.correlationsTable.groupJsonPane', {
// defaultMessage: 'JSON of groups',
// })}
// style={{ width: '100%' }}
// language="json"
// fontSize="s"
// paddingSize="s"
// isCopyable
// data-test-subj={`aiopsSpikeAnalysisTableColumnGroupJSON`}
// >
// {JSON.stringify(group, null, 2)}
// </EuiCodeBlock>
// ),
sortable: false,
textOnly: true,
},
{
'data-test-subj': 'aiopsSpikeAnalysisTableColumnDocCount',
'data-test-subj': 'aiopsSpikeAnalysisGroupsTableColumnDocCount',
field: 'docCount',
name: i18n.translate('xpack.aiops.correlations.correlationsTable.docCountLabel', {
defaultMessage: 'Doc count',
Expand Down Expand Up @@ -238,7 +223,7 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({

return (
<EuiBasicTable
data-test-subj="aiopsSpikeAnalysisTable"
data-test-subj="aiopsSpikeAnalysisGroupsTable"
compressed
columns={columns}
items={pageOfItems}
Expand All @@ -247,6 +232,11 @@ export const SpikeAnalysisGroupsTable: FC<SpikeAnalysisTableProps> = ({
pagination={pagination}
loading={false}
sorting={sorting as EuiTableSortingType<GroupTableItem>}
rowProps={(group) => {
return {
'data-test-subj': `aiopsSpikeAnalysisGroupsTableRow row-${group.id}`,
};
}}
/>
);
};
7 changes: 4 additions & 3 deletions x-pack/test/functional/apps/aiops/explain_log_rate_spikes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,12 @@ export default function ({ getPageObject, getService }: FtrProviderContext) {
await aiops.explainLogRateSpikes.clickRerunAnalysisButton(true);
await aiops.explainLogRateSpikes.assertProgressTitle('Progress: 100% — Done.');

await aiops.explainLogRateSpikesAnalysisTable.assertSpikeAnalysisTableExists();
await aiops.explainLogRateSpikesAnalysisGroupsTable.assertSpikeAnalysisTableExists();

const analysisTable = await aiops.explainLogRateSpikesAnalysisTable.parseAnalysisTable();
const analysisGroupsTable =
await aiops.explainLogRateSpikesAnalysisGroupsTable.parseAnalysisTable();

expect(analysisTable).to.be.eql(testData.expected.analysisTable);
expect(analysisGroupsTable).to.be.eql(testData.expected.analysisGroupsTable);
});
}

Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/aiops/test_data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const farequoteDataViewTestData: TestData = {
brushTargetTimestamp: 1455033600000,
expected: {
totalDocCountFormatted: '86,274',
analysisGroupsTable: [{ group: 'airline: AAL', docCount: '297' }],
analysisTable: [
{
fieldName: 'airline',
Expand Down
1 change: 1 addition & 0 deletions x-pack/test/functional/apps/aiops/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export interface TestData {
brushTargetTimestamp: number;
expected: {
totalDocCountFormatted: string;
analysisGroupsTable: Array<{ group: string; docCount: string }>;
analysisTable: Array<{
fieldName: string;
fieldValue: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import { FtrProviderContext } from '../../ftr_provider_context';

export function ExplainLogRateSpikesAnalysisGroupsTableProvider({
getService,
}: FtrProviderContext) {
const testSubjects = getService('testSubjects');

return new (class AnalysisTable {
public async assertSpikeAnalysisTableExists() {
await testSubjects.existOrFail(`aiopsSpikeAnalysisGroupsTable`);
}

public async parseAnalysisTable() {
const table = await testSubjects.find('~aiopsSpikeAnalysisGroupsTable');
const $ = await table.parseDomContent();
const rows = [];

for (const tr of $.findTestSubjects('~aiopsSpikeAnalysisGroupsTableRow').toArray()) {
const $tr = $(tr);

const rowObject: {
group: any;
docCount: number;
} = {
group: $tr
.findTestSubject('aiopsSpikeAnalysisGroupsTableColumnGroup')
.find('.euiTableCellContent')
.text()
.trim(),
docCount: $tr
.findTestSubject('aiopsSpikeAnalysisGroupsTableColumnDocCount')
.find('.euiTableCellContent')
.text()
.trim(),
};

rows.push(rowObject);
}

return rows;
}
})();
}
4 changes: 4 additions & 0 deletions x-pack/test/functional/services/aiops/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ import type { FtrProviderContext } from '../../ftr_provider_context';

import { ExplainLogRateSpikesProvider } from './explain_log_rate_spikes';
import { ExplainLogRateSpikesAnalysisTableProvider } from './explain_log_rate_spikes_analysis_table';
import { ExplainLogRateSpikesAnalysisGroupsTableProvider } from './explain_log_rate_spikes_analysis_groups_table';

export function AiopsProvider(context: FtrProviderContext) {
const explainLogRateSpikes = ExplainLogRateSpikesProvider(context);
const explainLogRateSpikesAnalysisTable = ExplainLogRateSpikesAnalysisTableProvider(context);
const explainLogRateSpikesAnalysisGroupsTable =
ExplainLogRateSpikesAnalysisGroupsTableProvider(context);

return {
explainLogRateSpikes,
explainLogRateSpikesAnalysisTable,
explainLogRateSpikesAnalysisGroupsTable,
};
}

0 comments on commit 06de36d

Please sign in to comment.