Skip to content

Conversation

@arkid15r
Copy link
Collaborator

Proposed change

Test Next env in the test images

Add the PR description here.

Checklist

  • I've read and followed the contributing guidelines.
  • I've run make check-test locally; all checks and tests passed.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 29, 2025

Summary by CodeRabbit

  • Tests

    • Standardized test containers with a consistent local environment variable for e2e and unit tests.
    • Updated unit test execution to run Jest directly with improved CI flags for reliability and clearer output.
    • Adjusted type-check and test flow to streamline developer feedback.
  • Chores

    • Simplified Docker build configuration by removing redundant environment settings during test image builds.
    • Refined CI pipeline commands for faster, more consistent frontend test runs.

Walkthrough

Removed inline NEXT_PUBLIC_ENVIRONMENT from Makefile docker builds, added ENV NEXT_PUBLIC_ENVIRONMENT=local to both test Dockerfiles, changed CI frontend unit-test run to invoke Jest directly inside the container, and removed --noEmit from the frontend test:unit script (Jest now runs unconditionally after tsc).

Changes

Cohort / File(s) Summary
Build target updates
frontend/Makefile
Removed NEXT_PUBLIC_ENVIRONMENT=local from docker build invocations for test-frontend-e2e and test-frontend-unit; DOCKER_BUILDKIT=1 and other flags unchanged.
Test Docker images (ENV additions)
frontend/docker/Dockerfile.e2e.test, frontend/docker/Dockerfile.unit.test
Added ENV NEXT_PUBLIC_ENVIRONMENT=local to each Dockerfile's ENV block; no other Dockerfile instructions changed.
CI test-run command
.github/workflows/run-ci-cd.yaml
Replaced frontend unit-test docker run ... pnpm run test:unit with docker run ... sh -c "NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest --ci --no-cache --verbose --detectOpenHandles --forceExit".
Test script tweak
frontend/package.json
test:unit script changed from tsc --noEmit && NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest to tsc; NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest (removed --noEmit and runs Jest regardless of tsc failure).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • kasya

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title "Move Next env to test images" accurately describes the main change in this pull request. The changeset shows the NEXT_PUBLIC_ENVIRONMENT variable being removed from Makefile docker build commands and added directly into the test Dockerfiles (Dockerfile.e2e.test and Dockerfile.unit.test), which is precisely a move of the Next environment configuration into the test images. The title is concise, clear, and correctly summarizes the primary technical change without being overly broad or vague.
Description Check ✅ Passed The description "Test Next env in the test images" is related to the changeset, though it's somewhat brief. The changes do involve moving the NEXT_PUBLIC_ENVIRONMENT configuration into the test Docker images, which aligns with testing the Next.js environment within those images. While the description could be more detailed, it does convey the general intent of the changes and is not off-topic or unrelated to what was actually modified in the pull request.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ark/fix-frontend-tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🧪 Early access (Sonnet 4.5): enabled

We are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience.

Note:

  • Public repositories are always opted into early access features.
  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot added frontend docker Pull requests that update Docker code makefile labels Sep 29, 2025
@github-actions github-actions bot added the ci label Sep 29, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7b80aa7 and 732c4f3.

📒 Files selected for processing (1)
  • frontend/package.json (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests
  • GitHub Check: CodeQL (javascript-typescript)
🔇 Additional comments (1)
frontend/package.json (1)

18-18: Verify: Tests now run even when type-checking fails

Changing && to ; means jest will execute regardless of whether tsc succeeds, which could mask type errors during local development and testing.

However, note that noEmit is already configured in tsconfig.json (line 7: "noEmit": true), so TypeScript will not emit compiled output regardless of command-line flags.

-    "test:unit": "tsc && NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest"
+    "test:unit": "tsc; NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest"

Consider: Is this change intentional for the Docker/CI test image context mentioned in this PR? The CI workflow runs this command inside a Docker container, so verify whether allowing tests to run despite type errors is the desired behavior for your test pipeline.

"start": "next start",
"test:e2e": "npx playwright test",
"test:unit": "tsc --noEmit && NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest"
"test:unit": "tsc; NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' jest"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Verify: Is this change related to the PR objective?

The PR is about moving NEXT_PUBLIC_ENVIRONMENT to test Docker images, but this change modifies TypeScript compilation and test execution behavior. Please clarify:

  1. Is this change intentional or a workaround for another issue?
  2. Are there type errors that need to be addressed?
  3. Does the environment variable change affect TypeScript compilation?

Run this script to check for TypeScript errors:


🏁 Script executed:

#!/bin/bash
# Check for TypeScript compilation errors in the frontend

cd frontend && npx tsc --noEmit 2>&1 | head -50

Length of output: 626


I need to gather more information to verify this change. Let me check the TypeScript installation and the broader context of the PR changes.


🏁 Script executed:

#!/bin/bash
# Check if TypeScript is installed and what version
cd frontend
if [ -f package.json ]; then
  echo "=== TypeScript in dependencies ==="
  cat package.json | jq '.dependencies.typescript // .devDependencies.typescript // "not found"'
  echo ""
fi

# Try running tsc from node_modules
echo "=== Running TypeScript compiler ==="
if [ -f node_modules/.bin/tsc ]; then
  ./node_modules/.bin/tsc --noEmit 2>&1 | head -100
else
  echo "TypeScript not installed in node_modules"
fi

Length of output: 121


🏁 Script executed:

#!/bin/bash
# Check the git diff for this specific file to see the full change
echo "=== Git diff for frontend/package.json ==="
git diff HEAD~1 HEAD -- frontend/package.json 2>/dev/null || git diff --cached -- frontend/package.json 2>/dev/null || echo "Could not retrieve git diff"

Length of output: 597


🏁 Script executed:

#!/bin/bash
# Look for PR description or commit messages
echo "=== Recent commit messages ==="
git log --oneline -5 2>/dev/null || echo "Git log unavailable"

echo ""
echo "=== Check for environment variable usage ==="
cd frontend
rg -n "NEXT_PUBLIC_ENVIRONMENT" --type=json --type=js --type=ts -g '!node_modules' -C2 | head -50

Length of output: 365


@sonarqubecloud
Copy link

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.github/workflows/run-ci-cd.yaml (1)

208-208: Consider the implications of --forceExit and direct Jest invocation.

The updated command introduces several changes:

  1. --forceExit flag: Forces Jest to exit after all tests complete, which can mask issues with improper async cleanup (e.g., open handles, timers, or connections). This may hide underlying problems that should be fixed.

  2. Direct Jest invocation: Bypasses the test:unit script in package.json, which can lead to drift between local development (pnpm run test:unit) and CI. If the script in package.json changes, CI won't reflect those changes unless this workflow is also updated.

  3. Command complexity: The inline command is more verbose and harder to maintain compared to delegating to a package.json script.

Recommendation: Consider one of the following approaches:

Option 1 (Preferred): Use pnpm run test:unit and move the NODE_OPTIONS and Jest flags to the package.json script or a Jest config file. This ensures consistency between local and CI environments.

       - name: Run frontend unit tests
         run: |
-          docker run --env-file frontend/.env.example owasp/nest:test-frontend-unit-latest sh -c "NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' npx jest --ci --no-cache --verbose --detectOpenHandles --forceExit"
+          docker run --env-file frontend/.env.example owasp/nest:test-frontend-unit-latest pnpm run test:unit

Then update frontend/package.json:

"test:unit": "NODE_OPTIONS='--experimental-vm-modules --no-warnings=DEP0040' tsc && jest --ci --no-cache --verbose --detectOpenHandles"

Option 2: If --forceExit is necessary, document why it's needed (e.g., known issue with a specific library). However, prefer fixing the underlying async cleanup issues instead.

Option 3: Remove --detectOpenHandles in CI if it's primarily a debugging tool, as it can slow down test execution.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f2008d and 37934f0.

📒 Files selected for processing (1)
  • .github/workflows/run-ci-cd.yaml (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests
  • GitHub Check: Run frontend unit tests

@arkid15r arkid15r closed this Sep 30, 2025
@arkid15r arkid15r deleted the ark/fix-frontend-tests branch September 30, 2025 01:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci docker Pull requests that update Docker code frontend makefile

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants