From 99ec486b79fe6a64ac0361f0dd392952850e0f7b Mon Sep 17 00:00:00 2001
From: Oliver <oliver.henry.walters@gmail.com>
Date: Thu, 27 Mar 2025 01:25:58 +1100
Subject: [PATCH] [Docker] Update node version (#9383)

* Update node version

* Install nvm

* Use n instead of nvm

* Use same approach in devcontainer

* nvm -> npm

* Split commands

* Fix typo

* Workaround : install bash

* Tweak playwright tests

* Bump number of retries

* Update deps

* Only one worker

* SEcurity fix

* Adjust
---
 .devcontainer/Dockerfile                  | 3 +++
 contrib/container/Dockerfile              | 8 ++++++--
 src/frontend/package.json                 | 2 ++
 src/frontend/playwright.config.ts         | 4 ++--
 src/frontend/tests/pages/pui_part.spec.ts | 1 +
 src/frontend/tests/pui_plugins.spec.ts    | 1 +
 src/frontend/yarn.lock                    | 9 ++++++++-
 7 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
index 86ce91c5b5..a847b4c232 100644
--- a/.devcontainer/Dockerfile
+++ b/.devcontainer/Dockerfile
@@ -33,6 +33,9 @@ RUN apt update && apt install -y \
 RUN apt install -y \
    yarn nodejs npm
 
+# Update to the latest stable node version
+RUN npm install -g n --ignore-scripts && n lts
+
 RUN yarn config set network-timeout 600000 -g
 
 ENTRYPOINT ["/bin/bash", "./init.sh"]
diff --git a/contrib/container/Dockerfile b/contrib/container/Dockerfile
index 92a06abd65..8da5baee12 100644
--- a/contrib/container/Dockerfile
+++ b/contrib/container/Dockerfile
@@ -107,7 +107,9 @@ RUN ./install_build_packages.sh --no-cache --virtual .build-deps && \
 # Frontend builder image:
 FROM prebuild AS frontend
 
-RUN apk add --no-cache --update nodejs npm yarn
+RUN apk add --no-cache --update nodejs npm yarn bash
+RUN npm install -g --ignore-scripts n
+RUN bash -c "n lts"
 RUN yarn config set network-timeout 600000 -g
 COPY src ${INVENTREE_HOME}/src
 COPY tasks.py ${INVENTREE_HOME}/tasks.py
@@ -149,7 +151,9 @@ RUN pip install --require-hashes -r base_requirements.txt --no-cache
 
 # Install nodejs / npm / yarn
 
-RUN apk add --no-cache --update nodejs npm yarn
+RUN apk add --no-cache --update nodejs npm yarn bash
+RUN npm install -g --ignore-scripts n
+RUN bash -c "n lts"
 RUN yarn config set network-timeout 600000 -g
 
 # The development image requires the source code to be mounted to /home/inventree/
diff --git a/src/frontend/package.json b/src/frontend/package.json
index ff8b7864f5..9da89d07e3 100644
--- a/src/frontend/package.json
+++ b/src/frontend/package.json
@@ -77,6 +77,7 @@
         "@babel/core": "^7.26.10",
         "@babel/preset-react": "^7.26.3",
         "@babel/preset-typescript": "^7.27.0",
+        "@babel/runtime": "^7.27.0",
         "@codecov/vite-plugin": "^1.9.0",
         "@lingui/babel-plugin-lingui-macro": "^5.3.0",
         "@lingui/cli": "^5.3.0",
@@ -93,6 +94,7 @@
         "@vitejs/plugin-react": "^4.3.4",
         "babel-plugin-macros": "^3.1.0",
         "nyc": "^17.1.0",
+        "rollup": "^4.0.0",
         "rollup-plugin-license": "^3.5.3",
         "typescript": "^5.8.2",
         "vite": "^6.2.3",
diff --git a/src/frontend/playwright.config.ts b/src/frontend/playwright.config.ts
index 6a819597d8..c7f9bf6e4a 100644
--- a/src/frontend/playwright.config.ts
+++ b/src/frontend/playwright.config.ts
@@ -5,8 +5,8 @@ export default defineConfig({
   fullyParallel: true,
   timeout: 90000,
   forbidOnly: !!process.env.CI,
-  retries: process.env.CI ? 2 : 0,
-  workers: process.env.CI ? 3 : undefined,
+  retries: process.env.CI ? 3 : 0,
+  workers: 1, // process.env.CI ? 3 : undefined,
   reporter: process.env.CI ? [['html', { open: 'never' }], ['github']] : 'list',
 
   /* Configure projects for major browsers */
diff --git a/src/frontend/tests/pages/pui_part.spec.ts b/src/frontend/tests/pages/pui_part.spec.ts
index e223430aee..75b1aaf431 100644
--- a/src/frontend/tests/pages/pui_part.spec.ts
+++ b/src/frontend/tests/pages/pui_part.spec.ts
@@ -22,6 +22,7 @@ test('Parts - Tabs', async ({ page }) => {
   // Select a particular part from the table
   await clearTableFilters(page);
   await page.getByPlaceholder('Search').fill('1551');
+  await page.waitForLoadState('networkidle');
   await page.getByText('1551ABK').click();
 
   await loadTab(page, 'Allocations');
diff --git a/src/frontend/tests/pui_plugins.spec.ts b/src/frontend/tests/pui_plugins.spec.ts
index d0765b27bc..8465a5f65c 100644
--- a/src/frontend/tests/pui_plugins.spec.ts
+++ b/src/frontend/tests/pui_plugins.spec.ts
@@ -64,6 +64,7 @@ test('Plugins - Functionality', async ({ page, request }) => {
   await navigate(page, 'settings/admin/plugin/');
   await clearTableFilters(page);
   await page.getByPlaceholder('Search').fill('sample');
+  await page.waitForLoadState('networkidle');
 
   // Activate the plugin
   const cell = await page.getByText('Sample API Caller', { exact: true });
diff --git a/src/frontend/yarn.lock b/src/frontend/yarn.lock
index 2255b1f807..f50a352945 100644
--- a/src/frontend/yarn.lock
+++ b/src/frontend/yarn.lock
@@ -510,6 +510,13 @@
   dependencies:
     regenerator-runtime "^0.14.0"
 
+"@babel/runtime@^7.27.0":
+  version "7.27.0"
+  resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.27.0.tgz#fbee7cf97c709518ecc1f590984481d5460d4762"
+  integrity sha512-VtPOkrdPHZsKc/clNqyi9WUA8TINkZ4cGk63UUE3u4pmB2k+ZMQRDuIOagv8UVd6j7k0T3+RRIb7beKTebNbcw==
+  dependencies:
+    regenerator-runtime "^0.14.0"
+
 "@babel/template@^7.25.0":
   version "7.25.0"
   resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.25.0.tgz#e733dc3134b4fede528c15bc95e89cb98c52592a"
@@ -4441,7 +4448,7 @@ rollup-plugin-license@^3.5.3:
     spdx-expression-validate "~2.0.0"
     spdx-satisfies "~5.0.1"
 
-rollup@^4.30.1:
+rollup@^4.0.0, rollup@^4.30.1:
   version "4.37.0"
   resolved "https://registry.yarnpkg.com/rollup/-/rollup-4.37.0.tgz#e4172f8bdb6ea7df08a1b0acf99abeccb2250378"
   integrity sha512-iAtQy/L4QFU+rTJ1YUjXqJOJzuwEghqWzCEYD2FEghT7Gsy1VdABntrO4CLopA5IkflTyqNiLNwPcOJ3S7UKLg==