Skip to content

Commit

Permalink
Fix e2e tests for navigating to filtered pages
Browse files Browse the repository at this point in the history
  • Loading branch information
shilman committed Jan 12, 2024
1 parent 7c1fae9 commit 185e342
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 5 additions & 6 deletions code/e2e-tests/tags.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ test.describe('tags', () => {

test('should correctly filter out test-only autodocs pages', async ({ page }) => {
const sbPage = new SbPage(page);

await sbPage.selectToolbar('#lib-preview-api');

// Sidebar should exclude test-only stories and their docs
Expand All @@ -49,15 +50,13 @@ test.describe('tags', () => {
// Even though the test-only story is filtered out of the stories, it is still the primary story (should it be?)
await sbPage.deepLinkToStory(storybookUrl, 'lib/preview-api/test-only-tag', 'docs');
await sbPage.waitUntilLoaded();
let root = sbPage.previewRoot();
let button = await root.locator('button', { hasText: 'button' });
expect(button).toBeVisible();
const docsButton = await sbPage.previewRoot().locator('button', { hasText: 'Button' });
await expect(docsButton).toBeVisible();

// Even though test-only story not sidebar, it is still in the preview
await sbPage.deepLinkToStory(storybookUrl, 'lib/preview-api/test-only-tag', 'default');
await sbPage.waitUntilLoaded();
root = sbPage.previewRoot();
button = await root.locator('button', { hasText: 'button' });
expect(button).toBeVisible();
const storyButton = await sbPage.previewRoot().locator('button', { hasText: 'Button' });
await expect(storyButton).toBeVisible();
});
});
3 changes: 3 additions & 0 deletions code/e2e-tests/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ export class SbPage {
const storyLinkId = `${titleId}--${storyId}`;
const viewMode = name === 'docs' ? 'docs' : 'story';
await this.page.goto(`${baseURL}/?path=/${viewMode}/${storyLinkId}`);

await this.page.waitForURL((url) => url.search.includes(`path=/${viewMode}/${storyLinkId}`));
await this.previewRoot();
}

/**
Expand Down

0 comments on commit 185e342

Please sign in to comment.