Skip to content

Conversation

@Tal-applitool
Copy link
Collaborator

Porting the applitools.github.io demo server for CI usage.
In order to serve the demo website in CI it can now be served via spinning a local server.

@Tal-applitool Tal-applitool requested a review from Copilot October 19, 2025 07:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds serving capability to static pages by porting the applitools.github.io demo server for CI usage. The implementation provides a TypeScript-based Express server that can serve demo website content locally, enabling CI environments to host the demo pages for testing purposes.

  • Implements a DemoServer class with static serving functionality and configurable options
  • Adds CLI interfaces for both programmatic usage and command-line execution
  • Includes comprehensive documentation and build configuration for TypeScript compilation

Reviewed Changes

Copilot reviewed 8 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/server.ts Core server implementation with Express-based static file serving
src/test-server.ts Test script demonstrating server functionality
src/server-cli.ts CLI interface with argument parsing for flexible server configuration
package.json Project configuration with dependencies and build scripts
rollup.config.js Rollup bundling configuration for deployment
README.md Comprehensive documentation covering API usage and project structure
EXTERNAL_DEPENDENCIES.md Documentation of external resources used by served pages
.eslintrc.json ESLint configuration for TypeScript code quality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

export default DemoServer;

// If this file is run directly, start the server
if (import.meta.url === `file://${process.argv[1]}`) {
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

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

The condition for detecting if the file is run directly is incorrect. process.argv[1] contains the script path, but import.meta.url is a file URL. Use fileURLToPath(import.meta.url) === process.argv[1] instead.

Suggested change
if (import.meta.url === `file://${process.argv[1]}`) {
if (__filename === process.argv[1]) {

Copilot uses AI. Check for mistakes.
const usedIndices = new Set<number>();
for (let i = 0; i < args.length; i++) {
if (args[i] === '--port' || args[i] === '-p') {
port = parseInt(args[i + 1], 10) || 3000;
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

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

Using || 3000 after parseInt will default to 3000 even for valid port 0. Use isNaN(parsed) ? 3000 : parsed pattern instead to properly handle edge cases.

Suggested change
port = parseInt(args[i + 1], 10) || 3000;
{
const parsed = parseInt(args[i + 1], 10);
port = isNaN(parsed) ? 3000 : parsed;
}

Copilot uses AI. Check for mistakes.
outputToFilesystem: false
})
],
external: ['express']
Copy link

Copilot AI Oct 19, 2025

Choose a reason for hiding this comment

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

Express is marked as external but the banner suggests this is meant to be an executable. Consider whether express should be bundled or if the executable approach conflicts with the external dependency.

Suggested change
external: ['express']

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

do we want to commit this document? Do you plan to remove those external deps?

Comment on lines +134 to +153
<style>
body {
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background-color: #f5f5f5;
}
.error-container {
text-align: center;
padding: 2rem;
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 { color: #d9534f; }
p { color: #666; }
</style>
Copy link
Contributor

Choose a reason for hiding this comment

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

this pr has a lot of code we don't actually need
especially since this is just a test server, let's keep things lean

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.

3 participants