feat(ui): enable storybook snapshot tests
- adds a process-compose namespace for running `storybook` and `luakit` together to replicate the `webkit`-based rendering that happens inside of `webview` - adds some helper scripts for running storybook tests and updating snapshots, with documentation in the README. - adds a `clan-app-ui-storybook` package which builds and tests the storybook, checking for rendering changes Currently, we’re only doing markup-based snapshot tests. We’re also using headless chromium for the tests by default as I couldn't get webkit to work in the nix build. As we’re only markup-based for the time being, this should be ok. But eventually I'd like to get it working with webkit.
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
buildNpmPackage,
|
||||
nodejs_22,
|
||||
importNpmLock,
|
||||
|
||||
clan-ts-api,
|
||||
playwright-driver,
|
||||
ps,
|
||||
fonts,
|
||||
}:
|
||||
buildNpmPackage {
|
||||
buildNpmPackage (finalAttrs: {
|
||||
pname = "clan-app-ui";
|
||||
version = "0.0.1";
|
||||
nodejs = nodejs_22;
|
||||
@@ -15,6 +16,7 @@ buildNpmPackage {
|
||||
npmDeps = importNpmLock {
|
||||
npmRoot = ./ui;
|
||||
};
|
||||
|
||||
npmConfigHook = importNpmLock.npmConfigHook;
|
||||
|
||||
preBuild = ''
|
||||
@@ -22,4 +24,36 @@ buildNpmPackage {
|
||||
cp -r ${clan-ts-api}/* api
|
||||
cp -r ${fonts} ".fonts"
|
||||
'';
|
||||
}
|
||||
|
||||
passthru = rec {
|
||||
storybook = buildNpmPackage {
|
||||
pname = "${finalAttrs.pname}-storybook";
|
||||
inherit (finalAttrs)
|
||||
version
|
||||
nodejs
|
||||
src
|
||||
npmDeps
|
||||
npmConfigHook
|
||||
preBuild
|
||||
;
|
||||
|
||||
nativeBuildInputs = finalAttrs.nativeBuildInputs ++ [
|
||||
ps
|
||||
];
|
||||
|
||||
npmBuildScript = "test-storybook-static";
|
||||
|
||||
env = finalAttrs.env // {
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = 1;
|
||||
PLAYWRIGHT_BROWSERS_PATH = "${playwright-driver.browsers.override {
|
||||
withChromiumHeadlessShell = true;
|
||||
}}";
|
||||
PLAYWRIGHT_HOST_PLATFORM_OVERRIDE = "ubuntu-24.04";
|
||||
};
|
||||
|
||||
postBuild = ''
|
||||
mv storybook-static $out
|
||||
'';
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user