Skip to content

Commit

Permalink
Fix tests that weren't fully testing the navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
wylieconlon committed Mar 1, 2021
1 parent 9f0e123 commit b8c8a55
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function DocViewer(renderProps: DocViewRenderProps) {
}

return (
<div className="kbnDocViewer">
<div className="kbnDocViewer" data-test-subj="kbnDocViewer">
<EuiTabbedContent size="s" tabs={tabs} />
</div>
);
Expand Down
10 changes: 7 additions & 3 deletions test/functional/apps/context/_discover_navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default function ({ getService, getPageObjects }) {
]);
const testSubjects = getService('testSubjects');
const dashboardAddPanel = getService('dashboardAddPanel');
const browser = getService('browser');

describe('context link in discover', () => {
before(async () => {
Expand Down Expand Up @@ -119,9 +120,12 @@ export default function ({ getService, getPageObjects }) {
await docTable.clickRowToggle({ rowIndex: 0 });
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
await rowActions[1].click();
await PageObjects.header.waitUntilLoadingHasFinished();
const contextFields = await docTable.getFields();
expect(contextFields.length).to.be.greaterThan(0);
await PageObjects.common.sleep(250);
// accept alert if it pops up
const alert = await browser.getAlert();
await alert?.accept();
expect(await browser.getCurrentUrl()).to.contain('#/doc');
expect(await PageObjects.discover.isShowingDocViewer()).to.be(true);
});
});
}
11 changes: 8 additions & 3 deletions test/functional/apps/discover/_data_grid_context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
const kibanaServer = getService('kibanaServer');
const esArchiver = getService('esArchiver');
const dashboardAddPanel = getService('dashboardAddPanel');
const browser = getService('browser');

describe('discover data grid context tests', () => {
before(async () => {
Expand Down Expand Up @@ -100,12 +101,16 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await dashboardAddPanel.addSavedSearch('my search');
await PageObjects.header.waitUntilLoadingHasFinished();

await dataGrid.clickRowToggle({ rowIndex: 0 });
await docTable.clickRowToggle({ rowIndex: 0 });
const rowActions = await docTable.getRowActions({ rowIndex: 0 });
await rowActions[1].click();
await PageObjects.common.sleep(250);
// accept alert if it pops up
const alert = await browser.getAlert();
await alert?.accept();
expect(await browser.getCurrentUrl()).to.contain('#/doc');
await PageObjects.header.waitUntilLoadingHasFinished();
const contextFields = await docTable.getFields();
expect(contextFields.length).to.be.greaterThan(0);
expect(await PageObjects.discover.isShowingDocViewer()).to.be(true);
});
});
}
17 changes: 7 additions & 10 deletions test/functional/page_objects/context_page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@
*/

import rison from 'rison-node';
import { getUrl } from '@kbn/test';
import { FtrProviderContext } from '../ftr_provider_context';

const DEFAULT_INITIAL_STATE = {
columns: ['@message'],
};

export function ContextPageProvider({ getService, getPageObjects }: FtrProviderContext) {
const browser = getService('browser');
const config = getService('config');
const retry = getService('retry');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['header', 'common']);
Expand All @@ -28,14 +25,14 @@ export function ContextPageProvider({ getService, getPageObjects }: FtrProviderC
...DEFAULT_INITIAL_STATE,
...overrideInitialState,
});
const appUrl = getUrl.noAuth(config.get('servers.kibana'), {
...config.get('apps.context'),
hash: `${config.get('apps.context.hash')}/${indexPattern}/${anchorId}?_a=${initialState}`,
});

log.debug(`browser.get(${appUrl})`);

await browser.get(appUrl);
await PageObjects.common.navigateToUrl(
'discover',
`#/context/${indexPattern}/${anchorId}?_a=${initialState}`,
{
useActualUrl: true,
}
);
await PageObjects.header.awaitGlobalLoadingIndicatorHidden();
await this.waitUntilContextLoadingHasFinished();
// For lack of a better way, using a sleep to ensure page is loaded before proceeding
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 @@ -222,6 +222,10 @@ export function DiscoverPageProvider({ getService, getPageObjects }: FtrProvider
await find.clickByCssSelector('.fa-sort-up');
}

public async isShowingDocViewer() {
return await testSubjects.exists('kbnDocViewer');
}

public async getMarks() {
const table = await docTable.getTable();
const $ = await table.parseDomContent();
Expand Down

0 comments on commit b8c8a55

Please sign in to comment.