Skip to content

Commit

Permalink
Fix cigroup 1 with dataGridTable helper functions (#5105)
Browse files Browse the repository at this point in the history
* fix1

Signed-off-by: abbyhu2000 <[email protected]>

* fix 1

Signed-off-by: abbyhu2000 <[email protected]>

* fix anchor test

Signed-off-by: abbyhu2000 <[email protected]>

* fix cigroup1

Signed-off-by: abbyhu2000 <[email protected]>

* address comments

Signed-off-by: abbyhu2000 <[email protected]>

---------

Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 authored Sep 25, 2023
1 parent f45e662 commit 64f6746
Show file tree
Hide file tree
Showing 10 changed files with 120 additions and 80 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function DocViewerLinks(renderProps: DocViewLinkRenderProps) {
.map((item) => {
const { generateCb, href, ...props } = item;
const listItem: EuiListGroupItemProps = {
'data-test-subj': 'docTableRowAction',
'data-test-subj': `docTableRowAction`,
...props,
href: generateCb ? generateCb(renderProps).url : href,
};
Expand All @@ -31,7 +31,7 @@ export function DocViewerLinks(renderProps: DocViewLinkRenderProps) {
href={item.href}
target="_blank"
style={{ fontWeight: 'normal' }}
data-test-subj={item['data-test-subj']}
data-test-subj={`${item['data-test-subj']}-${index}`}
>
{item.label}
</EuiLink>
Expand Down
34 changes: 19 additions & 15 deletions test/functional/apps/context/_context_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,33 +39,37 @@ const TEST_FILTER_COLUMN_NAMES = [
export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const browser = getService('browser');
const docTable = getService('docTable');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'context', 'discover', 'timePicker']);

describe('discover - context - back navigation', function contextSize() {
before(async function () {
await PageObjects.timePicker.setDefaultAbsoluteRangeViaUiSettings();
await PageObjects.common.navigateToApp('discover');
for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) {
await PageObjects.discover.clickFieldListItem(columnName);
await PageObjects.discover.clickFieldListItemDetails(columnName);
await PageObjects.discover.clickFieldListPlusFilter(columnName, value);
}
});

it('should go back after loading', async function () {
await retry.waitFor('user navigating to context and returning to discover', async () => {
// navigate to the context view
it('should open a new tab after loading surrounding documents', async function () {
await retry.waitFor('user navigating to context', async () => {
const initialHitCount = await PageObjects.discover.getHitCount();
await docTable.clickRowToggle({ rowIndex: 0 });
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
await rowActions[0].click();
await PageObjects.context.waitUntilContextLoadingHasFinished();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.clickSuccessorLoadMoreButton();
await PageObjects.context.waitUntilContextLoadingHasFinished();
await browser.goBack();
await PageObjects.discover.waitForDocTableLoadingComplete();

// click inspect row
await testSubjects.click('docTableExpandToggleColumn-0');
// click view surrounding documents
await testSubjects.click('docTableRowAction-0');

//navigate to the new window
await testSubjects.exists('docTable');
await browser.switchTab(1);

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

await testSubjects.click('euiFlyoutCloseButton');
const hitCount = await PageObjects.discover.getHitCount();
return initialHitCount === hitCount;
});
Expand Down
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.getDataGridTableColumn('date');
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.getDataGridTableColumn('date');
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
46 changes: 27 additions & 19 deletions test/functional/apps/context/_discover_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ const TEST_FILTER_COLUMN_NAMES = [
];

export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const docTable = getService('docTable');
const browser = getService('browser');
const dataGrid = getService('dataGrid');
const filterBar = getService('filterBar');
const PageObjects = getPageObjects(['common', 'discover', 'timePicker']);
const testSubjects = getService('testSubjects');

describe('context link in discover', () => {
before(async () => {
Expand All @@ -52,7 +53,7 @@ export default function ({ getService, getPageObjects }) {
}

for (const [columnName, value] of TEST_FILTER_COLUMN_NAMES) {
await PageObjects.discover.clickFieldListItem(columnName);
await PageObjects.discover.clickFieldListItemDetails(columnName);
await PageObjects.discover.clickFieldListPlusFilter(columnName, value);
}
});
Expand All @@ -61,25 +62,27 @@ export default function ({ getService, getPageObjects }) {
});

it('should open the context view with the selected document as anchor', async () => {
// check the anchor timestamp in the context view
await retry.waitFor('selected document timestamp matches anchor timestamp ', async () => {
// get the timestamp of the first row
const discoverFields = await docTable.getFields();
const firstTimestamp = discoverFields[0][0];

// navigate to the context view
await docTable.clickRowToggle({ rowIndex: 0 });
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
await rowActions[0].click();
const contextFields = await docTable.getFields({ isAnchorRow: true });
const anchorTimestamp = contextFields[0][0];
return anchorTimestamp === firstTimestamp;
});
// get the timestamps
const dataGridTableTimeStamps = await dataGrid.getDataGridTableColumn('date');

// click inspect row
await testSubjects.click('docTableExpandToggleColumn-10');

// click view surrounding documents
await testSubjects.click('docTableRowAction-0');

//navigate to the new window and get the new timestamp
await testSubjects.exists('docTable');
await browser.switchTab(1);
const surroundingTableTimeStamps = await dataGrid.getDataGridTableColumn('date');

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 @@ -90,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.getDataGridTableColumn('lastColumn');
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.getDataGridTableColumn('lastColumn');
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.getDataGridTableColumn('date');
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.getDataGridTableColumn('date');
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.getDataGridTableColumn('date');
return data.length === expectedRowLength;
}
);
});
Expand Down
8 changes: 4 additions & 4 deletions test/functional/apps/management/_scripted_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName);
await PageObjects.discover.clickFieldListItemDetails(scriptedPainlessFieldName);
await log.debug('filter by the first value (14) in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(scriptedPainlessFieldName, '14');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -314,7 +314,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
await PageObjects.discover.clickFieldListItemDetails(scriptedPainlessFieldName2);
await log.debug('filter by "bad" in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(scriptedPainlessFieldName2, 'bad');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -388,7 +388,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
await PageObjects.discover.clickFieldListItemDetails(scriptedPainlessFieldName2);
await log.debug('filter by "true" in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(scriptedPainlessFieldName2, 'true');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -506,7 +506,7 @@ export default function ({ getService, getPageObjects }) {
});

it('should filter by scripted field value in Discover', async function () {
await PageObjects.discover.clickFieldListItem(scriptedPainlessFieldName2);
await PageObjects.discover.clickFieldListItemDetails(scriptedPainlessFieldName2);
await log.debug('filter by "Sep 18, 2015 @ 7:52" in the expanded scripted field list');
await PageObjects.discover.clickFieldListPlusFilter(
scriptedPainlessFieldName2,
Expand Down
4 changes: 4 additions & 0 deletions test/functional/page_objects/discover_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,10 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
return await testSubjects.click(`field-${field}`);
}

public async clickFieldListItemDetails(field: string) {
return await testSubjects.click(`field-${field}-showDetails`);
}

public async clickFieldSort(field: string) {
return await testSubjects.click(`docTableHeaderFieldSort_${field}`);
}
Expand Down
Loading

0 comments on commit 64f6746

Please sign in to comment.