Skip to content

Commit

Permalink
fix cigroup1
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <abigailhu2000@gmail.com>
  • Loading branch information
abbyhu2000 committed Sep 25, 2023
1 parent ff24567 commit 410ea77
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 48 deletions.
30 changes: 15 additions & 15 deletions test/functional/apps/context/_date_nanos.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const TEST_STEP_SIZE = 3;

export default function ({ getService, getPageObjects }) {
const opensearchDashboardsServer = getService('opensearchDashboardsServer');
const docTable = getService('docTable');
const dataGrid = getService('dataGrid');
const security = getService('security');
const PageObjects = getPageObjects(['common', 'context', 'timePicker', 'discover']);
const opensearchArchiver = getService('opensearchArchiver');
Expand All @@ -62,11 +62,11 @@ export default function ({ getService, getPageObjects }) {

it('displays predessors - anchor - successors in right order ', async function () {
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, 'AU_x3-TaGFA8no6Qj999Z');
const actualRowsText = await docTable.getRowsText();
const actualRowsText = await dataGrid.getDataGridTableTimestamp();
const expectedRowsText = [
'Sep 18, 2019 @ 06:50:13.000000000-2',
'Sep 18, 2019 @ 06:50:12.999999999-3',
'Sep 19, 2015 @ 06:50:13.0001000011',
'Sep 18, 2019 @ 06:50:13.000000000',
'Sep 18, 2019 @ 06:50:12.999999999',
'Sep 19, 2015 @ 06:50:13.000100001',
];
expect(actualRowsText).to.eql(expectedRowsText);
});
Expand All @@ -75,17 +75,17 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.context.navigateTo(TEST_INDEX_PATTERN, 'AU_x3-TaGFA8no6Qjisd');
await PageObjects.context.clickPredecessorLoadMoreButton();
await PageObjects.context.clickSuccessorLoadMoreButton();
const actualRowsText = await docTable.getRowsText();
const actualRowsText = await dataGrid.getDataGridTableTimestamp();
const expectedRowsText = [
'Sep 22, 2019 @ 23:50:13.2531233455',
'Sep 18, 2019 @ 06:50:13.0000001044',
'Sep 18, 2019 @ 06:50:13.0000001032',
'Sep 18, 2019 @ 06:50:13.0000001021',
'Sep 18, 2019 @ 06:50:13.0000001010',
'Sep 18, 2019 @ 06:50:13.000000001-1',
'Sep 18, 2019 @ 06:50:13.000000000-2',
'Sep 18, 2019 @ 06:50:12.999999999-3',
'Sep 19, 2015 @ 06:50:13.0001000011',
'Sep 22, 2019 @ 23:50:13.253123345',
'Sep 18, 2019 @ 06:50:13.000000104',
'Sep 18, 2019 @ 06:50:13.000000103',
'Sep 18, 2019 @ 06:50:13.000000102',
'Sep 18, 2019 @ 06:50:13.000000101',
'Sep 18, 2019 @ 06:50:13.000000001',
'Sep 18, 2019 @ 06:50:13.000000000',
'Sep 18, 2019 @ 06:50:12.999999999',
'Sep 19, 2015 @ 06:50:13.000100001',
];
expect(actualRowsText).to.eql(expectedRowsText);
});
Expand Down
15 changes: 8 additions & 7 deletions test/functional/apps/context/_discover_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,13 @@ export default function ({ getService, getPageObjects }) {
await browser.switchTab(1);
const surroundingTableTimeStamps = await dataGrid.getDataGridTableTimestamp();

//close the new tab and get back to the old tab
await browser.closeCurrentWindow();
await browser.switchTab(0);

await testSubjects.click('euiFlyoutCloseButton');
return dataGridTableTimeStamps[10] === surroundingTableTimeStamps[5];
});

it('should open the context view with the same columns', async () => {
const columnNames = await docTable.getHeaderFields();
expect(columnNames).to.eql(['Time', ...TEST_COLUMN_NAMES]);
const data = await dataGrid.getDataGridTableData();

expect(data.columns).to.eql(['', 'Time (@timestamp)', ...TEST_COLUMN_NAMES]);
});

it('should open the context view with the filters disabled', async () => {
Expand All @@ -97,6 +93,11 @@ export default function ({ getService, getPageObjects }) {
}
}
expect(disabledFilterCounter).to.be(TEST_FILTER_COLUMN_NAMES.length);
//close the new tab and get back to the old tab
await browser.closeCurrentWindow();
await browser.switchTab(0);

await testSubjects.click('euiFlyoutCloseButton');
});
});
}
38 changes: 21 additions & 17 deletions test/functional/apps/context/_filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ const TEST_ANCHOR_FILTER_VALUE = 'IN';
const TEST_COLUMN_NAMES = ['extension', 'geo.src'];

export default function ({ getService, getPageObjects }) {
const docTable = getService('docTable');
const dataGrid = getService('dataGrid');
const filterBar = getService('filterBar');
const retry = getService('retry');
const browser = getService('browser');
const testSubjects = getService('testSubjects');

const PageObjects = getPageObjects(['common', 'context']);

Expand All @@ -52,18 +53,19 @@ export default function ({ getService, getPageObjects }) {

it('inclusive filter should be addable via expanded doc table rows', async function () {
await retry.waitFor(`filter ${TEST_ANCHOR_FILTER_FIELD} in filterbar`, async () => {
await docTable.toggleRowExpanded({ isAnchorRow: true });
const anchorDetailsRow = await docTable.getAnchorDetailsRow();
await docTable.addInclusiveFilter(anchorDetailsRow, TEST_ANCHOR_FILTER_FIELD);
await PageObjects.context.waitUntilContextLoadingHasFinished();
// expand anchor row
await testSubjects.click('docTableExpandToggleColumn-5');

// add inclusive filter
await testSubjects.click(
`tableDocViewRow-${TEST_ANCHOR_FILTER_FIELD} > addInclusiveFilterButton`
);

return await filterBar.hasFilter(TEST_ANCHOR_FILTER_FIELD, TEST_ANCHOR_FILTER_VALUE, true);
});
await retry.waitFor(`filter matching docs in docTable`, async () => {
const fields = await docTable.getFields();
return fields
.map((row) => row[2])
.every((fieldContent) => fieldContent === TEST_ANCHOR_FILTER_VALUE);
const fields = await dataGrid.getLastColumns();
return fields.every((fieldContent) => fieldContent === TEST_ANCHOR_FILTER_VALUE);
});
});

Expand All @@ -79,21 +81,23 @@ export default function ({ getService, getPageObjects }) {
});

await retry.waitFor('filters are disabled', async () => {
const fields = await docTable.getFields();
const hasOnlyFilteredRows = fields
.map((row) => row[2])
.every((fieldContent) => fieldContent === TEST_ANCHOR_FILTER_VALUE);
const fields = await dataGrid.getLastColumns();
const hasOnlyFilteredRows = fields.every(
(fieldContent) => fieldContent === TEST_ANCHOR_FILTER_VALUE
);
return hasOnlyFilteredRows === false;
});
});

it('filter for presence should be addable via expanded doc table rows', async function () {
await docTable.toggleRowExpanded({ isAnchorRow: true });
// expand anchor row
await testSubjects.click('docTableExpandToggleColumn-5');

await retry.waitFor('an exists filter in the filterbar', async () => {
const anchorDetailsRow = await docTable.getAnchorDetailsRow();
await docTable.addExistsFilter(anchorDetailsRow, TEST_ANCHOR_FILTER_FIELD);
await PageObjects.context.waitUntilContextLoadingHasFinished();
// add inclusive filter
await testSubjects.click(
`tableDocViewRow-${TEST_ANCHOR_FILTER_FIELD} > addExistsFilterButton`
);
return await filterBar.hasFilter(TEST_ANCHOR_FILTER_FIELD, 'exists', true);
});
});
Expand Down
12 changes: 6 additions & 6 deletions test/functional/apps/context/_size.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const TEST_STEP_SIZE = 2;
export default function ({ getService, getPageObjects }) {
const opensearchDashboardsServer = getService('opensearchDashboardsServer');
const retry = getService('retry');
const docTable = getService('docTable');
const dataGrid = getService('dataGrid');
const PageObjects = getPageObjects(['context']);
let expectedRowLength = 2 * TEST_DEFAULT_CONTEXT_SIZE + 1;

Expand All @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }) {
await retry.waitFor(
`number of rows displayed initially is ${expectedRowLength}`,
async function () {
const rows = await docTable.getRowsText();
const rows = await dataGrid.getDataGridTableTimestamp();
return rows.length === expectedRowLength;
}
);
Expand All @@ -74,8 +74,8 @@ export default function ({ getService, getPageObjects }) {
await retry.waitFor(
`number of rows displayed after clicking load more predecessors is ${expectedRowLength}`,
async function () {
const rows = await docTable.getRowsText();
return rows.length === expectedRowLength;
const data = await dataGrid.getDataGridTableTimestamp();
return data.length === expectedRowLength;
}
);
});
Expand All @@ -87,8 +87,8 @@ export default function ({ getService, getPageObjects }) {
await retry.waitFor(
`number of rows displayed after clicking load more successors is ${expectedRowLength}`,
async function () {
const rows = await docTable.getRowsText();
return rows.length === expectedRowLength;
const data = await dataGrid.getDataGridTableTimestamp();
return data.length === expectedRowLength;
}
);
});
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/context/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ export default function ({ getService, getPageObjects, loadTestFile }) {
});

//loadTestFile(require.resolve('./_context_navigation'));
loadTestFile(require.resolve('./_discover_navigation'));
// loadTestFile(require.resolve('./_discover_navigation'));
// loadTestFile(require.resolve('./_filters'));
// loadTestFile(require.resolve('./_size'));
loadTestFile(require.resolve('./_size'));
// loadTestFile(require.resolve('./_date_nanos'));
});
}
20 changes: 19 additions & 1 deletion test/functional/services/data_grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,25 @@ export function DataGridProvider({ getService }: FtrProviderContext) {
});

return timestamps;
}
}

async getLastColumns(): Promise<string[]> {
const table = await find.byCssSelector('.euiDataGrid');
const $ = await table.parseDomContent();

const columnValues: string[] = [];
$.findTestSubjects('dataGridRowCell')
.toArray()
.forEach((cell) => {
const cCell = $(cell);
if (cCell.hasClass('euiDataGridRowCell--lastColumn')) {
// The timestamp column structure is very nested to get the actual text
columnValues.push(cCell.children().children().children().children().text());
}
});

return columnValues;
}
}

return new DataGrid();
Expand Down

0 comments on commit 410ea77

Please sign in to comment.