Skip to content

Commit

Permalink
chore: adjust playwright test wrapper
Browse files Browse the repository at this point in the history
CSS vars were not being injected in the test environment
  • Loading branch information
DSil committed Jan 10, 2025
1 parent ac41074 commit 22d600b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/orbit-components/playwright/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,25 @@ import "./index.css";

import * as React from "react";
import { beforeMount } from "@playwright/experimental-ct-react/hooks";
import { tokensToCssVars } from "@kiwicom/orbit-design-tokens";

import RandomIdProvider from "../src/OrbitProvider/RandomId/Provider";
import { getCssVarsForWL } from "../src/OrbitProvider";
import defaultTheme from "../src/defaultTheme";

beforeMount(async ({ App }) => {
const ID = "orbit-theme-css-vars";
const style = document.createElement("style");
style.setAttribute("id", ID);
style.innerText = tokensToCssVars({
tokens: getCssVarsForWL(defaultTheme.orbit),
cssClass: ":root",
});
const head = document.getElementsByTagName("head")[0];
if (!document.getElementById(ID)) {
head.appendChild(style);
}

return (
<RandomIdProvider useId={React.useId}>
<App />
Expand Down

0 comments on commit 22d600b

Please sign in to comment.