Skip to content

Feat: Playwright /docker + vite watcher on html + css#1

Open
schoettler wants to merge 11 commits into
TinyHealth:mainfrom
schoettler:main
Open

Feat: Playwright /docker + vite watcher on html + css#1
schoettler wants to merge 11 commits into
TinyHealth:mainfrom
schoettler:main

Conversation

@schoettler
Copy link
Copy Markdown

@schoettler schoettler commented Jul 26, 2025

Hey man! Give these changes a try:

  1. vite as html + css watcher
    npm run dev:frontend

Changing the .html should do hot reloads (no refresh)

  1. Playwright via container
  • sudo chmod +x ./bin/run.sh to make it executable
  • ./bin/run.sh

Should start npm run dev and wait until it's ready before launching Playwright tests via container

Summary by CodeRabbit

  • New Features

    • Added a script to automate end-to-end UI testing using Playwright in a Docker container.
    • Introduced a Dockerfile for running Playwright tests in a consistent environment.
    • Added a Vite configuration for the frontend development server.
  • Chores

    • Updated development scripts to use Vite for the frontend and added related dependencies.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jul 26, 2025

Warning

Rate limit exceeded

@schoettler has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 20 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 2ad54a5 and 5701088.

📒 Files selected for processing (4)
  • bin/run.sh (1 hunks)
  • package.json (2 hunks)
  • playwright.Dockerfile (1 hunks)
  • vite.config.ts (1 hunks)

Walkthrough

A new end-to-end UI testing workflow is introduced using Playwright within Docker. Supporting scripts and configuration files are added, including a shell script for orchestrating containerized testing, a Playwright-specific Dockerfile, a Vite configuration for frontend development, and updates to package.json to use Vite and wait-on for development and testing automation.

Changes

File(s) Change Summary
bin/run.sh New shell script to automate Playwright UI tests in Docker, orchestrating server start and tests
playwright.Dockerfile New Dockerfile for Playwright, setting up environment and running tests in container
vite.config.ts New Vite config specifying frontend root and dev server port
package.json Switched frontend dev script to Vite, added vite and wait-on as devDependencies
src/frontend/index.html Whitespace and formatting normalization only; no structural or content changes

Sequence Diagram(s)

sequenceDiagram
    participant Developer
    participant run.sh
    participant Docker
    participant PlaywrightContainer
    participant DevServer (Vite)
    participant TestRunner

    Developer->>run.sh: Execute script
    run.sh->>Docker: Start PlaywrightContainer (mount code, expose ports)
    Docker->>PlaywrightContainer: Container starts
    PlaywrightContainer->>DevServer (Vite): npm run dev (background)
    PlaywrightContainer->>run.sh: Wait for ports 3000 and 3001 (wait-on)
    run.sh->>TestRunner: npm run test:ui
    TestRunner->>DevServer (Vite): Run UI tests
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

In Docker’s warren, tests now run,
With Vite and Playwright, oh what fun!
A shell script hops to start the show,
Ports await, then green lights glow.
The frontend’s swift, the tests are neat—
This bunny’s code is hard to beat! 🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@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: 4

🧹 Nitpick comments (2)
vite.config.ts (1)

3-8: Consider adding common development configurations.

While the current setup works, you might want to add commonly useful Vite configurations for better development experience.

 export default defineConfig({
   root: 'src/frontend',
   server: {
     port: 3001,
+    host: true, // Allow external connections (useful for Docker)
+    watch: {
+      usePolling: true // Better file watching in some environments
+    }
   }
 });
playwright.Dockerfile (1)

1-13: Consider Dockerfile optimizations.

The current Dockerfile works but could be optimized for better caching and smaller image size.

 FROM mcr.microsoft.com/playwright:v1.52.0-noble
 
 WORKDIR /app
 
+# Copy package files first for better Docker layer caching
 COPY package.json package-lock.json ./
-
-RUN npm i --frozen-lockfile;
-
+RUN npm ci --frozen-lockfile
+
+# Copy test files
 COPY tests ../tests
 COPY playwright.config.ts .
 
 ENV BASE_URL=http://host.docker.internal:8081
 CMD ["npx", "playwright", "test"]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 12450a6 and c1e144a.

📒 Files selected for processing (4)
  • bin/run.sh (1 hunks)
  • package.json (2 hunks)
  • playwright.Dockerfile (1 hunks)
  • vite.config.ts (1 hunks)
🔇 Additional comments (4)
vite.config.ts (1)

1-8: LGTM! Clean and minimal Vite configuration.

The configuration correctly sets up Vite for the frontend development with proper port alignment across the project files.

package.json (2)

8-8: LGTM! Script change aligns with Vite integration.

The update from http-server to vite with proper port configuration supports the hot reload functionality mentioned in the PR objectives.


31-32: Dependencies correctly added for the new workflow.

The vite and wait-on packages support the new development and testing workflow as described in the PR objectives.

playwright.Dockerfile (1)

9-10: Playwright files verified
The tests directory and playwright.config.ts are present at the project root, matching the COPY paths in playwright.Dockerfile. No changes required.

Comment thread bin/run.sh
Comment on lines +5 to +11
docker run -d --rm \
--name "e2e-fullstack-challenge" \
-v "$PWD":/app \
-w /app \
-p 3000:3000 \
-p 3001:3001 \
mcr.microsoft.com/playwright:v1.52.0-noble
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Docker container setup seems disconnected from test execution.

The script creates a Docker container but then runs npm run test:ui on the host, not inside the container. This appears to contradict the PR objectives of running Playwright tests "inside the container."

Consider clarifying the intended workflow. If tests should run inside the container:

-docker run -d --rm \
+docker run -d --rm \
    --name "e2e-fullstack-challenge" \
    -v "$PWD":/app \
    -w /app \
    -p 3000:3000 \
    -p 3001:3001 \
    mcr.microsoft.com/playwright:v1.52.0-noble
+   tail -f /dev/null  # Keep container running

Then execute tests inside the container:

-npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
+npx wait-on --http-get http://localhost:3000 http://localhost:3001 && docker exec e2e-fullstack-challenge npm run test:ui

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In bin/run.sh around lines 5 to 11, the script starts a Docker container but
runs the Playwright tests on the host machine, not inside the container as
intended. To fix this, modify the script to execute the test command (e.g., npm
run test:ui) inside the running container using docker exec or run the tests as
part of the container startup command. This ensures the tests run within the
container environment as per the PR objectives.

Comment thread bin/run.sh
Comment on lines +13 to +15
npm run dev &
echo "Starting services..."
npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Missing process cleanup and error handling.

The script starts background processes but doesn't clean them up on exit or failure, which could leave orphaned processes running.

Add proper cleanup and error handling:

+#!/bin/bash
+
+set -e
+
+# Cleanup function
+cleanup() {
+    echo "Cleaning up..."
+    pkill -f "npm run dev" || true
+    docker stop e2e-fullstack-challenge || true
+    docker rm e2e-fullstack-challenge || true
+}
+
+# Set trap to cleanup on exit
+trap cleanup EXIT INT TERM
+
 # Launch Playwright using Docker
 docker run -d --rm \
    --name "e2e-fullstack-challenge" \
    -v "$PWD":/app \
    -w /app \
    -p 3000:3000 \
    -p 3001:3001 \
    mcr.microsoft.com/playwright:v1.52.0-noble
 
 npm run dev &
+DEV_PID=$!
 echo "Starting services..."
 npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
npm run dev &
echo "Starting services..."
npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
#!/bin/bash
set -e
# Cleanup function
cleanup() {
echo "Cleaning up..."
pkill -f "npm run dev" || true
docker stop e2e-fullstack-challenge || true
docker rm e2e-fullstack-challenge || true
}
# Ensure cleanup on exit, interrupt, or termination
trap cleanup EXIT INT TERM
# Launch Playwright using Docker
docker run -d --rm \
--name "e2e-fullstack-challenge" \
-v "$PWD":/app \
-w /app \
-p 3000:3000 \
-p 3001:3001 \
mcr.microsoft.com/playwright:v1.52.0-noble
# Start the dev server in the background and remember its PID
npm run dev &
DEV_PID=$!
echo "Starting services..."
npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
🤖 Prompt for AI Agents
In bin/run.sh around lines 13 to 15, the script starts background processes
without handling cleanup or errors, risking orphaned processes. Modify the
script to capture the background process ID after starting npm run dev, add a
trap to kill this process on script exit or interruption, and include error
handling to stop the script if npx wait-on or npm run test:ui fail. This ensures
proper cleanup and prevents orphaned processes.

Comment thread bin/run.sh

npm run dev &
echo "Starting services..."
npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Consider timeout and better error messaging for service readiness.

The wait-on command should have a timeout and better error handling to avoid hanging indefinitely.

-npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
+echo "Waiting for services to be ready..."
+npx wait-on --timeout 60000 --http-get http://localhost:3000 http://localhost:3001
+echo "Services are ready, running tests..."
+npm run test:ui
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
npx wait-on --http-get http://localhost:3000 http://localhost:3001 && npm run test:ui
echo "Waiting for services to be ready..."
npx wait-on --timeout 60000 --http-get http://localhost:3000 http://localhost:3001
echo "Services are ready, running tests..."
npm run test:ui
🤖 Prompt for AI Agents
In bin/run.sh at line 15, the wait-on command currently lacks a timeout and
error handling, which can cause the script to hang indefinitely if the services
do not become ready. Add a timeout option to the wait-on command to limit how
long it waits for the services, and modify the script to check the exit status
of wait-on. If wait-on fails or times out, output a clear error message and
prevent the subsequent npm run test:ui command from running.

Comment thread playwright.Dockerfile Outdated
COPY tests ../tests
COPY playwright.config.ts .

ENV BASE_URL=http://host.docker.internal:8081
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Port mismatch in BASE_URL configuration.

The BASE_URL is set to port 8081, but based on the other files, services run on ports 3000 (backend) and 3001 (frontend). This inconsistency will likely cause test failures.

Verify which port the tests should target and update accordingly:

-ENV BASE_URL=http://host.docker.internal:8081
+ENV BASE_URL=http://host.docker.internal:3000

Or if testing the frontend:

-ENV BASE_URL=http://host.docker.internal:8081
+ENV BASE_URL=http://host.docker.internal:3001
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ENV BASE_URL=http://host.docker.internal:8081
# For backend tests
ENV BASE_URL=http://host.docker.internal:3000
Suggested change
ENV BASE_URL=http://host.docker.internal:8081
# For frontend tests
ENV BASE_URL=http://host.docker.internal:3001
🤖 Prompt for AI Agents
In playwright.Dockerfile at line 12, the BASE_URL environment variable is set to
use port 8081, which does not match the backend port 3000 or frontend port 3001
used by the services. Determine whether the tests should target the backend or
frontend service and update the BASE_URL to use the correct port (3000 for
backend or 3001 for frontend) to ensure proper connectivity during testing.

@schoettler schoettler force-pushed the main branch 4 times, most recently from 89ac868 to 50ceba9 Compare July 26, 2025 01:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant