Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion code/core/src/core-server/utils/StoryIndexGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ export class StoryIndexGenerator {
importPath,
componentPath,
tags,
...(input.type === 'story' && input.parent ? { parent: input.parent } : {}),
...(input.type === 'story' && input.subtype === 'test'
? { parent: input.parent, parentName: input.parentName }
: {}),
};
}
);
Expand Down
3 changes: 2 additions & 1 deletion code/core/src/csf-tools/CsfFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,9 @@ export class CsfFile {
// title: `${storyInput.title}/${story.name}`,
type: 'story',
subtype: 'test',
parent: story.id,
name: test.name,
parent: story.id,
parentName: story.name,
tags: [
...storyInput.tags,
// this tag comes before test tags so users can invert if they like
Expand Down
4 changes: 4 additions & 0 deletions code/core/src/preview-api/modules/store/StoryStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ describe('StoryStore', () => {
"renderToCanvas": undefined,
"story": "A",
"storyGlobals": {},
"storyId": "component-one--a",
"subcomponents": undefined,
"tags": [
"dev",
Expand Down Expand Up @@ -535,6 +536,7 @@ describe('StoryStore', () => {
"renderToCanvas": undefined,
"story": "A",
"storyGlobals": {},
"storyId": "component-one--a",
"subcomponents": undefined,
"tags": [
"dev",
Expand Down Expand Up @@ -600,6 +602,7 @@ describe('StoryStore', () => {
"renderToCanvas": undefined,
"story": "B",
"storyGlobals": {},
"storyId": "component-one--b",
"subcomponents": undefined,
"tags": [
"dev",
Expand Down Expand Up @@ -665,6 +668,7 @@ describe('StoryStore', () => {
"renderToCanvas": undefined,
"story": "C",
"storyGlobals": {},
"storyId": "component-two--c",
"subcomponents": undefined,
"tags": [
"dev",
Expand Down
11 changes: 7 additions & 4 deletions code/core/src/preview-api/modules/store/StoryStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,12 +292,12 @@ export class StoryStore<TRenderer extends Renderer> {
}

const stories = Object.entries(this.storyIndex.entries).reduce(
(acc, [storyId, { type, importPath }]) => {
if (type === 'docs') {
(acc, [storyId, entry]) => {
if (entry.type === 'docs') {
return acc;
}

const csfFile = cachedCSFFiles[importPath];
const csfFile = cachedCSFFiles[entry.importPath];
const story = this.storyFromCSFFile({ storyId, csfFile });

if (!options.includeDocsOnly && story.parameters.docsOnly) {
Expand All @@ -306,6 +306,9 @@ export class StoryStore<TRenderer extends Renderer> {

acc[storyId] = Object.entries(story).reduce(
(storyAcc, [key, value]) => {
if (key === 'story' && entry.subtype === 'test') {
return { ...storyAcc, story: entry.parentName };
}
if (key === 'moduleExport') {
return storyAcc;
}
Expand All @@ -318,13 +321,13 @@ export class StoryStore<TRenderer extends Renderer> {
return Object.assign(storyAcc, { [key]: value });
},
{
//
args: story.initialArgs,
globals: {
...this.userGlobals.initialGlobals,
...this.userGlobals.globals,
...story.storyGlobals,
},
storyId: entry.parent ? entry.parent : storyId,
}
);
return acc;
Expand Down
2 changes: 2 additions & 0 deletions code/core/src/types/modules/indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export type StoryIndexEntry = BaseIndexEntry & {
type: 'story';
subtype: 'story' | 'test';
parent?: StoryId; // exists only on tests
parentName?: StoryName; // exists only on tests
};

export type DocsIndexEntry = BaseIndexEntry & {
Expand Down Expand Up @@ -135,6 +136,7 @@ export type StoryIndexInput = BaseIndexInput & {
type: 'story';
subtype: 'story' | 'test';
parent?: StoryId; // exists only on tests
parentName?: StoryName; // exists only on tests
};

/** The input for indexing a docs entry. */
Expand Down
Loading