Skip to content

Commit

Permalink
readd tests for node module CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
alextaing committed Oct 23, 2023
1 parent 4e5d0b9 commit 2864bae
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "./index.css";
import "@yext/search-ui-react/lib/bundle.css";

import ComplexBanner from "../ComponentFile/ComplexBanner";
import { TemplateProps } from "@yext/pages";

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import "@yext/search-ui-react/bundle.css";
import ComplexBanner from "../ComponentFile/ComplexBanner";
import { GetPath, TemplateConfig, TemplateProps } from "@yext/pages";

export const config: TemplateConfig = {
stream: {
$id: "studio-stream-id",
localization: { locales: ["en"] },
filter: { entityTypes: ["location"] },
fields: ["title", "slug"],
},
};

export const getPath: GetPath<TemplateProps> = ({
document,
}: TemplateProps) => {
return document.slug;
};

export default function BrokenCss({ document }: TemplateProps) {
return <ComplexBanner title={document.title} num={3} bool={false} />;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import "./index.css";
import "@yext/search-ui-react/lib/bundle.css";

import ComplexBanner from "../ComponentFile/ComplexBanner";
import { GetPath, TemplateConfig, TemplateProps } from "@yext/pages";

Expand Down
5 changes: 4 additions & 1 deletion packages/studio-plugin/tests/sourcefiles/LayoutFile.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ describe("getLayoutState", () => {
it("correctly parses CSS imports", () => {
const result = getLayoutState("BasicLayout");
const expectedIndexCssPath = getFixturePath("LayoutFile/index.css");
expect(result.value.cssImports).toEqual([expectedIndexCssPath]);
expect(result.value.cssImports).toEqual([
expectedIndexCssPath,
expect.stringContaining("/node_modules/@yext/search-ui-react/lib/bundle.css")
]);
});

it("correctly gets filepath", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ describe("getPageState", () => {

assertIsOk(result);
const expectedIndexCssPath = getFixturePath("PageFile/index.css");
expect(result.value.cssImports).toEqual([expectedIndexCssPath]);
expect(result.value.cssImports).toEqual([
expectedIndexCssPath,
expect.stringContaining("/node_modules/@yext/search-ui-react/lib/bundle.css")
]);
});

it("correctly gets filepath", () => {
Expand Down Expand Up @@ -121,5 +124,13 @@ describe("getPageState", () => {
);
expect(consoleErrorSpy).toHaveBeenCalledTimes(2);
});

it("cannot resolve node_module CSS import using package.json export alias", () => {
const pageFile = createPageFile("brokenCssImport");

expect(pageFile.getPageState()).toHaveErrorMessage(
/^@yext\/search-ui-react\/bundle.css could not be resolved /
);
});
});
});

0 comments on commit 2864bae

Please sign in to comment.