Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 112 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Node modules
node_modules/
*/node_modules/
**/node_modules/

# Build outputs
dist/
build/
.next/
out/

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Coverage directory used by tools like istanbul
coverage/
*.lcov

# nyc test coverage
.nyc_output

# Dependency directories
jspm_packages/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack' (except the one we need for tests)
*.tgz
!metricinsights-pp-dev-latest.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.local
.env.development.local
.env.test.local
.env.production.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Git
.git/
.gitignore

# Docker
Dockerfile*
docker-compose*
.dockerignore

# Test results
test-results/
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: CI
on:
pull_request:
branches: [main, develop]
push:
branches: [develop]

jobs:
build:
Expand Down
6 changes: 6 additions & 0 deletions .releaserc.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
}
],
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
"npmPublish": false
}
],
[
"@semantic-release/git",
{
Expand Down
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use official Node.js image
FROM node:22-alpine

# Set working directory
WORKDIR /app

# Copy the built pp-dev package
COPY metricinsights-pp-dev-latest.tgz ./

# Copy test folders (without node_modules - they will be installed)
COPY tests/ ./tests/

# Copy and setup script for running tests
COPY run-tests.sh /usr/local/bin/run-tests.sh

# Fix line endings (Windows -> Unix)
RUN sed -i 's/\r$//' /usr/local/bin/run-tests.sh

# Make script executable
RUN chmod +x /usr/local/bin/run-tests.sh

# Set entry point
ENTRYPOINT ["/usr/local/bin/run-tests.sh"]

# Default command runs commonjs tests
CMD ["dev-commonjs"]
61 changes: 61 additions & 0 deletions e2e/config-watcher/watcher.debounce.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { test, expect } from '@playwright/test';

const testType = process.env.TEST_TYPE;
const baseURL = process.env.BASE_URL ?? '';

test.describe('Config Watcher Debounce Behavior', () => {
test.skip(testType !== 'config', 'Only run for config test type');

test('should not restart immediately on config change', async ({ page }) => {
// The debounce is set to 500ms in the CLI
// This test verifies server doesn't restart too quickly

await page.goto(baseURL);
await expect(page).toHaveURL(/\/p[tl]?\//);

// Record initial time
const startTime = Date.now();

// Make multiple rapid requests
for (let i = 0; i < 5; i++) {
const response = await page.request.get(baseURL);
expect(response.ok()).toBe(true);
}

const endTime = Date.now();

// All requests should complete relatively quickly
// If debounce wasn't working, server restarts would cause delays
expect(endTime - startTime).toBeLessThan(10000);
});

test('should coalesce multiple rapid config changes', async ({ page }) => {
await page.goto(baseURL);

// Verify server is stable
await page.waitForTimeout(1000);

// Make several requests to verify stability
const requests = [];
for (let i = 0; i < 3; i++) {
requests.push(page.request.get(baseURL));
}

const responses = await Promise.all(requests);
responses.forEach((response) => {
expect(response.ok()).toBe(true);
});
});

test('should remain responsive during config reload', async ({ page }) => {
await page.goto(baseURL);

// The page should remain usable even during config watch
const toolbar = page.locator('.pp-dev-info');

// For Vite projects, toolbar should be visible
if (testType === 'config' || testType?.includes('commonjs')) {
await expect(toolbar).toBeVisible({ timeout: 10000 });
}
});
});
74 changes: 74 additions & 0 deletions e2e/config-watcher/watcher.reload.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import { test, expect } from '@playwright/test';

const testType = process.env.TEST_TYPE;
const baseURL = process.env.BASE_URL ?? '';

// Only run config watcher tests for the config test type
test.describe('Config File Watcher - Reload', () => {
test.skip(testType !== 'config', 'Only run for config test type');

test('should detect config file changes', async ({ page }) => {
// This test verifies the config watcher detects changes
// In the Docker environment, we can modify config files

// Navigate to verify server is running
await page.goto(baseURL);
await expect(page).toHaveURL(/\/p[tl]?\//);

// The actual file modification and server restart is tested
// in the Docker environment setup
// Here we just verify the server responds correctly
const title = await page.title();
expect(title).toBeDefined();
});

test('should maintain server functionality after config change', async ({ page }) => {
await page.goto(baseURL);

// Verify redirect still works
await expect(page).toHaveURL(/\/p[tl]?\//);

// Verify page loads correctly
const body = await page.locator('body');
await expect(body).toBeVisible();
});

test('should handle rapid config changes gracefully (debounce)', async ({ page }) => {
// This test verifies the debounce mechanism works
// The server should not restart multiple times for rapid changes

await page.goto(baseURL);

// Wait a bit for server to stabilize
await page.waitForTimeout(2000);

// Verify server is responsive
const response = await page.request.get(baseURL);
expect(response.status()).toBe(200);
});
});

test.describe('Config File Watcher - File Types', () => {
test.skip(testType !== 'config', 'Only run for config test type');

test('should watch pp-dev.config.ts files', async ({ page }) => {
// Verify the server watches TypeScript config files
await page.goto(baseURL);
await expect(page).toHaveURL(/\/p[tl]?\//);
});

test('should watch package.json for pp-dev field', async ({ page }) => {
// Verify the server watches package.json
await page.goto(baseURL);
await expect(page).toHaveURL(/\/p[tl]?\//);
});

test('should watch .env files', async ({ page }) => {
// Verify the server watches .env files
await page.goto(baseURL);

// Server should be running and responsive
const response = await page.request.get(baseURL);
expect(response.ok()).toBe(true);
});
});
Loading
Loading