Skip to content

Commit ead2c60

Browse files
heswellCopilot
andcommitted
Use Rspack context for gallery stories
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent a04e7c0 commit ead2c60

2 files changed

Lines changed: 12 additions & 10 deletions

File tree

vuu-ui/packages/vuu-table-extras/src/__tests__/__component__/csv-upload/CsvUpload.playwright.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ test.describe("Given a CsvUpload with rowDefaults", () => {
100100
mount,
101101
page,
102102
}) => {
103-
await mount(<CsvUploadWithRowDefaults />);
103+
await mount("TableExtras/CsvUpload/CsvUploadWithRowDefaults");
104104

105105
await page.locator('input[type="file"]').setInputFiles({
106106
name: "id-only.csv",
@@ -126,7 +126,7 @@ test.describe("Given a CsvUpload with rowDefaults", () => {
126126
mount,
127127
page,
128128
}) => {
129-
await mount(<CsvUploadWithRowDefaults />);
129+
await mount("TableExtras/CsvUpload/CsvUploadWithRowDefaults");
130130

131131
await page.locator('input[type="file"]').setInputFiles({
132132
name: "both-cols.csv",

vuu-ui/playwright/gallery/main.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ declare global {
3636
}
3737
}
3838

39-
const stories = import.meta.glob<StoryModule>(
40-
"../../showcase/src/examples/**/*.examples.{tsx,jsx}",
41-
{ eager: true },
42-
);
39+
const stories = import.meta.webpackContext("../../showcase/src/examples", {
40+
mode: "eager",
41+
recursive: true,
42+
regExp: /\.examples\.(tsx|jsx)$/,
43+
});
4344
const rootElement = document.getElementById("root");
4445

4546
if (!rootElement) {
@@ -48,19 +49,20 @@ if (!rootElement) {
4849

4950
const storyPath = (file: string) =>
5051
file
51-
.replace("../../showcase/src/examples/", "")
52+
.replace(/^.*showcase\/src\/examples\//, "")
53+
.replace(/^\.?\//, "")
5254
.replace(/\.examples\.\w+$/, "");
5355

5456
async function resolveStory(storyId: string) {
5557
const separator = storyId.lastIndexOf("/");
5658
const path = storyId.slice(0, separator);
5759
const name = storyId.slice(separator + 1);
58-
const file = Object.keys(stories).find(
60+
const file = stories.keys().find(
5961
(candidate) =>
6062
storyPath(candidate) === path || storyPath(candidate).endsWith(`/${path}`),
6163
);
62-
const storyModule = file ? stories[file] : undefined;
63-
return storyModule?.[name];
64+
const storyModule = file ? stories(file) : undefined;
65+
return storyModule?.[name] ?? storyModule?.default?.[name];
6466
}
6567

6668
let root: Root | undefined;

0 commit comments

Comments
 (0)