Skip to content

Commit

Permalink
Make redirect tests more stable
Browse files Browse the repository at this point in the history
  • Loading branch information
weltenwort committed Apr 21, 2020
1 parent 3cb1126 commit bac844b
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions x-pack/test/functional/apps/infra/link_to.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import expect from '@kbn/expect';
import { URL } from 'url';
import { FtrProviderContext } from '../../ftr_provider_context';

const ONE_HOUR = 60 * 60 * 1000;
Expand All @@ -29,8 +30,6 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
search: `time=${timestamp}&filter=trace.id:${traceId}`,
state: undefined,
};
const expectedSearchString = `logFilter=(expression:'trace.id:${traceId}',kind:kuery)&logPosition=(end:'${endDate}',position:(tiebreaker:0,time:${timestamp}),start:'${startDate}',streamLive:!f)&sourceId=default`;
const expectedRedirectPath = '/logs/stream?';

await pageObjects.common.navigateToUrlWithBrowserHistory(
'infraLogs',
Expand All @@ -42,9 +41,16 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => {
);
await retry.tryForTime(5000, async () => {
const currentUrl = await browser.getCurrentUrl();
const decodedUrl = decodeURIComponent(currentUrl);
expect(decodedUrl).to.contain(expectedRedirectPath);
expect(decodedUrl).to.contain(expectedSearchString);
const parsedUrl = new URL(currentUrl);

expect(parsedUrl.pathname).to.be('/app/logs/stream');
expect(parsedUrl.searchParams.get('logFilter')).to.be(
`(expression:'trace.id:${traceId}',kind:kuery)`
);
expect(parsedUrl.searchParams.get('logPosition')).to.be(
`(end:'${endDate}',position:(tiebreaker:0,time:${timestamp}),start:'${startDate}',streamLive:!f)`
);
expect(parsedUrl.searchParams.get('sourceId')).to.be('default');
});
});
});
Expand Down

0 comments on commit bac844b

Please sign in to comment.