Skip to content

Commit

Permalink
Fix retry
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasolson committed Sep 24, 2024
1 parent 1384506 commit 64b9041
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions test/plugin_functional/test_suites/data_plugin/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,25 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
await sessionsBtn.click();
const toast = await toasts.getElementByIndex(1);
const sessionIds = await toast.getVisibleText();
await toasts.dismissAll();
return sessionIds.split(',');
};

const clearSessionIds = async () => {
await testSubjects.click('clearSessionsButton');
await toasts.dismissAll();
};

describe('Session management', function describeSessionManagementTests() {
describe('Discover', () => {
before(async () => {
await common.navigateToApp('discover');
await testSubjects.click('clearSessionsButton');
await clearSessionIds();
await header.waitUntilLoadingHasFinished();
});

afterEach(async () => {
await testSubjects.click('clearSessionsButton');
await toasts.dismissAll();
await clearSessionIds();
});

it('Starts on index pattern select', async () => {
Expand Down Expand Up @@ -93,8 +98,7 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
});

afterEach(async () => {
await testSubjects.click('clearSessionsButton');
await toasts.dismissAll();
await clearSessionIds();
});

after(async () => {
Expand All @@ -117,11 +121,17 @@ export default function ({ getService, getPageObjects }: PluginFunctionalProvide
it('starts a session on filter change', async () => {
// For some reason, when loading the dashboard, sometimes the filter doesn't show up, so we
// refresh until it shows up
await retry.waitFor('make sure filter is loaded', async () => {
const hasFilter = await filterBar.hasFilter('animal', 'dog');
if (!hasFilter) await browser.refresh();
return hasFilter;
});
await retry.try(
async () => {
const hasFilter = await filterBar.hasFilter('animal', 'dog');
if (!hasFilter) throw new Error('filter not found');
},
async () => {
await browser.refresh();
await header.waitUntilLoadingHasFinished();
await clearSessionIds();
}
);
await filterBar.removeFilter('animal');
const sessionIds = await getSessionIds();
expect(sessionIds.length).to.be(1);
Expand Down

0 comments on commit 64b9041

Please sign in to comment.