From cc90d7f2495ce9d74815ba1c61fbacd8c72a5793 Mon Sep 17 00:00:00 2001
From: Chad Lavimoniere <clavimoniere@gitlab.com>
Date: Mon, 17 Feb 2025 11:40:01 +0000
Subject: [PATCH] Add option to start storybook without prompting for fixtures

When working with storybook locally, if you have to stop and restart it
frequently the prompt to re-download fixtures is a nuisance. This MR
adds an npm script that can be run that will skip the fixtures check
and use the version you already have downloaded.
---
 package.json                        |  1 +
 scripts/frontend/start_storybook.sh | 14 +++++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/package.json b/package.json
index e5fde2a3adf34..119eadca26acb 100644
--- a/package.json
+++ b/package.json
@@ -41,6 +41,7 @@
     "storybook:install": "yarn --cwd ./storybook install",
     "storybook:build": "yarn tailwindcss:build && yarn --cwd ./storybook build --quiet",
     "storybook:start": "./scripts/frontend/start_storybook.sh",
+    "storybook:start:skip-fixtures-update": "./scripts/frontend/start_storybook.sh --skip-fixtures-update",
     "swagger:validate": "swagger-cli validate",
     "webpack": "NODE_OPTIONS=\"${NODE_OPTIONS:=--max-old-space-size=5120}\" webpack --config config/webpack.config.js",
     "webpack-vendor": "NODE_OPTIONS=\"${NODE_OPTIONS:=--max-old-space-size=5120}\" webpack --config config/webpack.vendor.config.js",
diff --git a/scripts/frontend/start_storybook.sh b/scripts/frontend/start_storybook.sh
index b707dcf124dc4..990cbe13d47cd 100755
--- a/scripts/frontend/start_storybook.sh
+++ b/scripts/frontend/start_storybook.sh
@@ -4,12 +4,16 @@ if ! [[ -d storybook/node_modules ]]; then
   yarn storybook:install
 fi
 
-echo "Storybook needs fixture files to run. Generate or download them."
-echo "See: https://docs.gitlab.com/ee/development/testing_guide/frontend_testing.html#frontend-test-fixtures"
-read -rp "Download fixtures? (y/N) " response
+if [[ "$1" == "--skip-fixtures-update" ]]; then
+  echo "Proceeding without installing fixtures."
+else
+  echo "Storybook needs fixture files to run. Generate or download them."
+  echo "See: https://docs.gitlab.com/ee/development/testing_guide/frontend_testing.html#frontend-test-fixtures"
+  read -rp "Download fixtures? (y/N) " response
 
-if [ "$response" = "y" ]; then
-  ./scripts/frontend/download_fixtures.sh
+  if [ "$response" = "y" ]; then
+    ./scripts/frontend/download_fixtures.sh
+  fi
 fi
 
 yarn tailwindcss:build
-- 
GitLab