-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25537 from storybookjs/shilman/add-indexer-metatags
Indexer: Add metaTags and make autodocs inherit them
- Loading branch information
Showing
11 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { SbPage } from './util'; | ||
|
||
const storybookUrl = process.env.STORYBOOK_URL || 'http://localhost:8001'; | ||
|
||
test.describe('tags', () => { | ||
test.beforeEach(async ({ page }) => { | ||
await page.goto(storybookUrl); | ||
await new SbPage(page).waitUntilLoaded(); | ||
}); | ||
|
||
test('should correctly filter dev-only, docs-only, test-only stories', async ({ page }) => { | ||
const sbPage = new SbPage(page); | ||
|
||
await sbPage.navigateToStory('lib/preview-api/tags', 'docs'); | ||
|
||
// Sidebar should include dev-only and exclude docs-only and test-only | ||
const devOnlyEntry = await page.locator('#lib-preview-api-tags--dev-only').all(); | ||
expect(devOnlyEntry.length).toBe(1); | ||
|
||
const docsOnlyEntry = await page.locator('#lib-preview-api-tags--docs-only').all(); | ||
expect(docsOnlyEntry.length).toBe(0); | ||
|
||
const testOnlyEntry = await page.locator('#lib-preview-api-tags--test-only').all(); | ||
expect(testOnlyEntry.length).toBe(0); | ||
|
||
// Autodocs should include docs-only and exclude dev-only and test-only | ||
const root = sbPage.previewRoot(); | ||
|
||
const devOnlyAnchor = await root.locator('#anchor--lib-preview-api-tags--dev-only').all(); | ||
expect(devOnlyAnchor.length).toBe(0); | ||
|
||
const docsOnlyAnchor = await root.locator('#anchor--lib-preview-api-tags--docs-only').all(); | ||
expect(docsOnlyAnchor.length).toBe(1); | ||
|
||
const testOnlyAnchor = await root.locator('#anchor--lib-preview-api-tags--test-only').all(); | ||
expect(testOnlyAnchor.length).toBe(0); | ||
}); | ||
|
||
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 | ||
const componentEntry = await page.locator('#lib-preview-api-test-only-tag').all(); | ||
expect(componentEntry.length).toBe(0); | ||
|
||
// Even though test-only autodocs not sidebar, it is still in the preview | ||
// 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(); | ||
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(); | ||
const storyButton = await sbPage.previewRoot().locator('button', { hasText: 'Button' }); | ||
await expect(storyButton).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
code/lib/preview-api/template/stories/test-only-tag.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { global as globalThis } from '@storybook/global'; | ||
|
||
export default { | ||
component: globalThis.Components.Button, | ||
tags: ['autodocs', 'test-only'], | ||
parameters: { chromatic: { disable: true } }, | ||
}; | ||
|
||
export const Default = { | ||
args: { label: 'Button' }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters