Skip to content

Commit

Permalink
🐛 fix templates examples (#2507)
Browse files Browse the repository at this point in the history
* 🐛 fix templates examples, filter-code now throws on dubious input & output + add tests

* 🎨 convert filter-code to use string instead of code match

* 🎨 Kan nå se 404 sider i sandbox

* 🔥 Fjernet testing av templates

---------

Co-authored-by: Ken <[email protected]>
Co-authored-by: Ken <[email protected]>
  • Loading branch information
3 people authored Nov 28, 2023
1 parent 8dda590 commit 1079e84
Show file tree
Hide file tree
Showing 343 changed files with 437 additions and 48 deletions.
6 changes: 3 additions & 3 deletions aksel.nav.no/website/e2e/sandbox.e2e.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { test, expect } from "@playwright/test";
import { expect, test } from "@playwright/test";
import { getDirectories } from "../scripts/update-examples/parts/get-directories";
import { parseCodeFiles } from "../scripts/update-examples/parts/parse-code-files";

Expand Down Expand Up @@ -26,7 +26,7 @@ test.describe("sandbox examples (all)", () => {
}
});

test.describe("templates", () => {
/* test.describe("templates", () => {
const subdirs = getDirectories("templates");
for (const subdir of subdirs) {
Expand All @@ -47,5 +47,5 @@ test.describe("sandbox examples (all)", () => {
});
}
}
});
}); */
});
7 changes: 3 additions & 4 deletions aksel.nav.no/website/e2e/smoketest.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";
import urls from "./test-urls.json";
import { expect, test } from "@playwright/test";
import { getDirectories } from "../scripts/update-examples/parts/get-directories";
import { parseCodeFiles } from "../scripts/update-examples/parts/parse-code-files";
import urls from "./test-urls.json";

test.describe("Smoketest all pages", () => {
for (const url of urls) {
Expand All @@ -28,9 +28,8 @@ test.describe("Smoketest all pages", () => {

test.describe("sandbox examples (just a few)", () => {
const examples = getDirectories("eksempler");
const templates = getDirectories("templates");

const folders = [...examples, ...templates];
const folders = [...examples];

const randomFolders = [folders[0], folders[20], folders[50]];

Expand Down
7 changes: 4 additions & 3 deletions aksel.nav.no/website/pages/eksempler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Eksempler må ligge under `eksempler/[gruppe]/[eksempel].tsx`

### Kode

Alle linjer som inneholder `withDsExample` + alt under `export default withDsExample(Example);` blir automatisk fjernet fra kode-snippet.
Alle linjer som inneholder `examples/withDsExample` + alt under `// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE` blir automatisk fjernet fra kode-snippet.

Demo-komponent må ha navn `Example` for at CodeSandbox-knapp skal fungere riktig.

Expand All @@ -28,10 +28,11 @@ const Example = () => {
return <Button>Primary</Button>;
};

export default withDsExample(Example); <- Alt under denne linjen fjernes fra vist kode
// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

export const args = {
index: 0,
desc: "Primærknapp brukes til xyz"
desc: "Primærknapp brukes til xyz",
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "static" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "static" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/accordion/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "static" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/accordion/size.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "static" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "static" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/fullwidth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/inline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/med-heading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const AlertWithCloseButton = ({
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/small.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Example = () => {
return <Alert variant="success">Søknad er sendt inn!</Alert>;
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/alert/warning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodylong/align.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodylong/colors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodylong/large.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodylong/medium.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Example = () => {
return <BodyLong as="span">Dette er nå en span!</BodyLong>;
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodylong/small.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodyshort/align.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodyshort/colors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodyshort/large.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodyshort/medium.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Example = () => {
return <BodyShort as="span">Dette er nå en span!</BodyShort>;
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/bodyshort/small.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function Divider() {
return <hr className="border-border-subtle" />;
}

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example, { variant: "full" });

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/button/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/button/disabled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/button/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/button/loading.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Example = () => {
return <Button loading>Loading</Button>;
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/button/neutral.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
1 change: 1 addition & 0 deletions aksel.nav.no/website/pages/eksempler/button/small.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const Example = () => {
);
};

// EXAMPLES DO NOT INCLUDE CONTENT BELOW THIS LINE
export default withDsExample(Example);

/* Storybook story */
Expand Down
Loading

0 comments on commit 1079e84

Please sign in to comment.