Skip to content

feat: Introduce E2E tests for project-builder-cli#459

Merged
kingston merged 7 commits into
mainfrom
kingston/eng-574-introduce-e2e-tests-for-project-creation-and-saving
Mar 18, 2025
Merged

feat: Introduce E2E tests for project-builder-cli#459
kingston merged 7 commits into
mainfrom
kingston/eng-574-introduce-e2e-tests-for-project-creation-and-saving

Conversation

@kingston

@kingston kingston commented Mar 18, 2025

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Introduced comprehensive end-to-end testing capabilities that enhance the reliability of project initialization and settings management.
    • Added new testing setups for streamlined CLI and UI interactions.
    • Implemented a new method for managing project IDs in local storage.
  • Refactor

    • Streamlined build and test commands along with dependency installation.
    • Enhanced error messaging and logging for a better user experience.
    • Improved project name generation to ensure adherence to specific formatting.
  • Tests

    • Expanded automated test suites to validate project setup, configuration persistence, and overall system robustness.
    • Added new test helpers for improved server setup in testing environments.
    • Introduced new test cases for initializing projects and managing settings.
  • Chores

    • Updated configuration files and environment settings to support improved testing and build workflows.
    • Removed unnecessary dependencies to simplify project setup.
    • Updated ESLint configuration for enhanced customization.

@linear

linear Bot commented Mar 18, 2025

Copy link
Copy Markdown
ENG-574 Introduce E2E tests for project creation and saving

We should make sure project-builder-web survives various scenarios involving saving/updating

@changeset-bot

changeset-bot Bot commented Mar 18, 2025

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7393f29

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@halfdomelabs/project-builder-server Patch
@halfdomelabs/project-builder-cli Patch
@halfdomelabs/project-builder-lib Patch
@halfdomelabs/project-builder-web Patch
@halfdomelabs/create-project Patch
@halfdomelabs/project-builder-common Patch
@halfdomelabs/project-builder-test Patch
@halfdomelabs/baseplate-plugin-storage Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Mar 18, 2025

Copy link
Copy Markdown

Walkthrough

The changes introduce a new changeset documenting updates across various packages in the project-builder ecosystem. Multiple packages have been patched to support end-to-end testing, with notable modifications made to the CLI, web server, and test configurations. Updates include refactoring server startup logic to use a centralized service manager, revising TypeScript configurations, and enhancing error handling with user‐friendly errors. Additionally, testing workflows, ESLint configuration, and local storage project ID handling in the web client have been updated and expanded.

Changes

File(s) Change Summary
.changeset/tired-places-pay.md New file documenting a patch for multiple packages with a focus on end-to-end testing support for the CLI.
.github/workflows/test-e2e.yml Updated dependency installation command to include the @halfdomelabs/project-builder-cli filter.
package.json (root) Modified test:e2e and test:e2e:affected scripts to call tests directly with the --continue flag, removing specific project-builder-test references.
packages/create-project/src/project-creator.ts Removed an unused import and the code block responsible for writing project-definition.json.
packages/project-builder-cli/{.gitignore, package.json, playwright.config.ts, src/index.ts, src/server.ts, src/services/logger.ts, src/utils/version.ts, tests/**} Revamped CLI functionality: reintroduced node_modules ignore rules, updated build/test scripts (including Playwright integration), refactored error and version handling, adjusted the serve command signature, and added testing fixtures and specs.
packages/project-builder-cli/{tsconfig.app.json, tsconfig.build.json, tsconfig.e2e.json, tsconfig.json} Added new TypeScript configuration files and restructured the main tsconfig to reference project-specific configs.
packages/project-builder-lib/{src/migrations/index.ts, src/schema/project-definition.ts} Modified schema version handling: removed the default fallback in migrations and enforced a strict numeric type for schemaVersion in the project definition schema.
packages/project-builder-server/{src/api/*.ts, src/plugins/plugin-discovery.ts, src/server/*, src/service/builder-service.ts, src/utils/errors.ts} Refactored API and server logic by replacing array-based service management with a centralized BuilderServiceManager, updated service lookups, delegated server initialization to dedicated methods, and switched error handling from InitializeServerError to UserVisibleError.
packages/project-builder-web/{src/app/ProjectDefinitionProvider/ProjectDefinitionProvider.tsx, src/app/ProjectDefinitionProvider/services/parse-project-definition-contents.ts, src/services/{error-formatter.ts, project-id.service.ts}} Simplified state management in the project definition provider; updated error messaging and formatting; and enhanced project ID handling by introducing a setter for local storage management.
packages/tools/eslint.config.node.js Introduced the generateNodeConfig function for a configurable Node.js ESLint configuration, updating the default export accordingly.
tests/simple/packages/e2e/package.json Upgraded the @playwright/test dependency version from 1.48.0 to 1.51.0.
turbo.json Added a global pass-through for environment variables (PLAYWRIGHT_*) and introduced a new test:e2e task that depends on the build step.

Sequence Diagram(s)

sequenceDiagram
    participant CLI
    participant serveWebServer
    participant BuilderServiceManager
    participant WebServer

    CLI->>serveWebServer: Invoke serveWebServer(directories, options)
    serveWebServer->>BuilderServiceManager: Initialize with directories, CLI version, & plugins
    BuilderServiceManager-->>serveWebServer: Return service manager instance
    serveWebServer->>WebServer: Call startWebServer(serviceManager, options)
    WebServer-->>serveWebServer: Return FastifyInstance
    serveWebServer-->>CLI: Return { FastifyInstance, serviceManager }
Loading
sequenceDiagram
    participant Browser
    participant ProjectIDService
    participant LocalStorage
    participant URL

    Browser->>ProjectIDService: Request getLocalStorageProjectId()
    ProjectIDService->>LocalStorage: Attempt to retrieve projectId
    alt projectId not found in LocalStorage
        ProjectIDService->>URL: Check URL query parameters for projectId
        URL-->>ProjectIDService: Return projectId (if available)
        ProjectIDService->>LocalStorage: setLocalStorageProjectId(value)
    end
    ProjectIDService-->>Browser: Return projectId (or null)
Loading

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cd0036a and 7393f29.

📒 Files selected for processing (1)
  • .github/workflows/test-e2e.yml (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/test-e2e.yml

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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 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.

@socket-security

socket-security Bot commented Mar 18, 2025

Copy link
Copy Markdown

Updated dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@playwright/test@1.48.01.51.0 None +2 3.23 MB dgozman-ms, mxschmitt, pavelfeldman, ...1 more

View full report↗︎

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (11)
packages/project-builder-cli/tsconfig.build.json (1)

1-8: Consider specifying a rootDir.
If you have source files in a subdirectory, using rootDir in addition to outDir avoids potential issues with TypeScript output paths.

packages/project-builder-cli/tsconfig.app.json (1)

1-11: Looks good!
Configuration is straightforward. Optionally consider stricter compiler checks ("strict": true) to catch potential issues early.

packages/project-builder-server/src/api/projects.ts (1)

17-39: Maintain consistent error handling.

Retrieving services via ctx.serviceManager.getServices() is consistent with the new architecture. However, consider using UserVisibleError for invalid definitions to maintain uniform error reporting.

packages/project-builder-cli/tests/settings.spec.ts (1)

19-38: Good coverage for external modifications.
This test properly ensures that changes to the underlying project definition are reflected in the UI. Consider expanding to test partial modifications or validation errors.

packages/project-builder-cli/package.json (1)

33-34: Validate the new scripts.
Introducing "test:e2e": "pnpm playwright test" is a welcome addition for end-to-end testing. Note, however, that "tsc --build tsconfig.json" can produce compiled artifacts during type checks. If your workflow requires noEmit type-checking in CI, consider using tsc --noEmit or a separate script.

packages/project-builder-server/src/server/plugin.ts (1)

25-27: Verbose project logging.
Logging out all loaded projects is handy but could become excessive for large setups. Consider providing a more concise or debug-level log.

packages/project-builder-cli/tests/fixtures/server-fixture.test-helper.ts (3)

22-61: Consider using OS-assigned ephemeral ports for better reliability.

Currently, the function generates a random port in the range 10000-15000 and then retries up to 100 times in case of conflicts. While this may work for test environments, it can still lead to port collisions under heavy parallel testing. To further reduce the risk of conflicts, you might consider letting the OS assign an ephemeral port automatically (typically by passing port: 0 to your server starter, depending on your server framework’s capabilities).


28-29: Avoid magic range for ports, or document it clearly.

You’re randomly starting at port 10000 and scanning upward. This is fine for test environments, but either document the rationale (e.g., to avoid ephemeral port collisions) or consider using the system ephemeral ports by passing port: 0.


224-239: Initialization fixture could use additional validation.

addInitializedProject automatically marks the project as isInitialized: true. If your tests need to verify whether initialization logic was properly applied, consider adding a post-creation check or an assertion verifying that the project is truly in a ready state (e.g., required files are present).

packages/project-builder-cli/src/server.ts (2)

41-45: Validate existence of project-builder-web in all environments.

It's good that you throw an error if projectBuilderWebDir is not found. A friendly user-facing error message or fallback behavior (if feasible) could improve the developer experience, but this is sufficient for most CLI usage.


69-92: Avoid swallowing errors in the CLI command.

When using .action(...), any error within serveWebServer will propagate, but re-check how you handle potential upstream errors. If user input leads to an unhandled rejection (e.g., invalid directories), you may want to refine CLI error messages before re-throwing to produce more specific feedback.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e4f744f and 6161492.

⛔ Files ignored due to path filters (2)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • tests/simple/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (38)
  • .changeset/tired-places-pay.md (1 hunks)
  • .github/workflows/test-e2e.yml (1 hunks)
  • package.json (1 hunks)
  • packages/create-project/src/project-creator.ts (0 hunks)
  • packages/project-builder-cli/.gitignore (1 hunks)
  • packages/project-builder-cli/package.json (2 hunks)
  • packages/project-builder-cli/playwright.config.ts (1 hunks)
  • packages/project-builder-cli/src/index.ts (1 hunks)
  • packages/project-builder-cli/src/server.ts (2 hunks)
  • packages/project-builder-cli/src/services/logger.ts (1 hunks)
  • packages/project-builder-cli/src/utils/version.ts (2 hunks)
  • packages/project-builder-cli/tests/fixtures/server-fixture.test-helper.ts (1 hunks)
  • packages/project-builder-cli/tests/initialize-project.spec.ts (1 hunks)
  • packages/project-builder-cli/tests/settings.spec.ts (1 hunks)
  • packages/project-builder-cli/tsconfig.app.json (1 hunks)
  • packages/project-builder-cli/tsconfig.build.json (1 hunks)
  • packages/project-builder-cli/tsconfig.e2e.json (1 hunks)
  • packages/project-builder-cli/tsconfig.json (1 hunks)
  • packages/project-builder-lib/src/migrations/index.ts (1 hunks)
  • packages/project-builder-lib/src/schema/project-definition.ts (1 hunks)
  • packages/project-builder-server/src/api/context.ts (1 hunks)
  • packages/project-builder-server/src/api/projects.ts (1 hunks)
  • packages/project-builder-server/src/api/trpc.ts (1 hunks)
  • packages/project-builder-server/src/api/types.ts (1 hunks)
  • packages/project-builder-server/src/plugins/plugin-discovery.ts (3 hunks)
  • packages/project-builder-server/src/server/builder-service-manager.ts (1 hunks)
  • packages/project-builder-server/src/server/index.ts (3 hunks)
  • packages/project-builder-server/src/server/plugin.ts (6 hunks)
  • packages/project-builder-server/src/server/server.ts (3 hunks)
  • packages/project-builder-server/src/service/builder-service.ts (1 hunks)
  • packages/project-builder-server/src/utils/errors.ts (1 hunks)
  • packages/project-builder-web/src/app/ProjectDefinitionProvider/ProjectDefinitionProvider.tsx (2 hunks)
  • packages/project-builder-web/src/app/ProjectDefinitionProvider/services/parse-project-definition-contents.ts (1 hunks)
  • packages/project-builder-web/src/services/error-formatter.ts (1 hunks)
  • packages/project-builder-web/src/services/project-id.service.ts (1 hunks)
  • packages/tools/eslint.config.node.js (1 hunks)
  • tests/simple/packages/e2e/package.json (1 hunks)
  • turbo.json (2 hunks)
💤 Files with no reviewable changes (1)
  • packages/create-project/src/project-creator.ts
🧰 Additional context used
🧬 Code Definitions (11)
packages/project-builder-server/src/api/types.ts (1)
packages/project-builder-server/src/server/builder-service-manager.ts (1) (1)
  • BuilderServiceManager (7:63)
packages/project-builder-cli/src/index.ts (1)
packages/project-builder-cli/src/server.ts (1) (1)
  • addServeCommand (69:95)
packages/project-builder-server/src/server/builder-service-manager.ts (1)
packages/project-builder-server/src/service/builder-service.ts (1) (1)
  • ProjectBuilderService (75:282)
packages/project-builder-server/src/api/trpc.ts (2)
packages/project-builder-server/src/api/context.ts (1) (1)
  • Context (27:29)
packages/project-builder-server/src/utils/errors.ts (1) (1)
  • UserVisibleError (8:19)
packages/project-builder-cli/src/utils/version.ts (1)
packages/create-project/src/version.ts (1) (1)
  • getPackageVersion (7:27)
packages/project-builder-server/src/plugins/plugin-discovery.ts (1)
packages/project-builder-server/src/utils/errors.ts (1) (1)
  • UserVisibleError (8:19)
packages/project-builder-server/src/server/plugin.ts (2)
packages/project-builder-lib/src/feature-flags/flags.ts (1) (1)
  • FeatureFlag (3:3)
packages/project-builder-server/src/server/builder-service-manager.ts (1) (1)
  • BuilderServiceManager (7:63)
packages/project-builder-cli/tests/settings.spec.ts (1)
packages/project-builder-cli/tests/fixtures/server-fixture.test-helper.ts (1) (1)
  • test (96:240)
packages/project-builder-server/src/server/server.ts (3)
packages/project-builder-lib/src/feature-flags/flags.ts (1) (1)
  • FeatureFlag (3:3)
packages/project-builder-server/src/server/builder-service-manager.ts (1) (1)
  • BuilderServiceManager (7:63)
packages/project-builder-server/src/server/plugin.ts (1) (1)
  • baseplatePlugin (18:155)
packages/project-builder-cli/tests/fixtures/server-fixture.test-helper.ts (5)
packages/project-builder-server/src/server/builder-service-manager.ts (1) (1)
  • BuilderServiceManager (7:63)
packages/project-builder-server/src/server/index.ts (1) (1)
  • BuilderServiceManager (16:16)
packages/project-builder-cli/src/server.ts (1) (1)
  • serveWebServer (25:67)
packages/project-builder-cli/src/services/logger.ts (1) (1)
  • DEFAULT_LOGGER_OPTIONS (3:11)
packages/project-builder-lib/src/schema/project-definition.ts (1) (1)
  • ProjectDefinition (61:61)
packages/project-builder-web/src/app/ProjectDefinitionProvider/ProjectDefinitionProvider.tsx (1)
packages/project-builder-web/src/services/error-formatter.ts (1) (1)
  • formatError (25:31)
🔇 Additional comments (57)
tests/simple/packages/e2e/package.json (1)

13-13: Check for breaking changes in updated Playwright version.
Upgrading from 1.48.0 to 1.51.0 may include changes in the API or new recommended usage. Ensure your E2E tests still pass as expected.

packages/project-builder-lib/src/schema/project-definition.ts (1)

54-54: Ensure existing code sets a numeric schemaVersion.
Changing schemaVersion to a strictly numeric value may break older definitions. Verify all references and migrations handle this constraint.

packages/project-builder-web/src/app/ProjectDefinitionProvider/services/parse-project-definition-contents.ts (1)

23-23: Improved error clarity.
Requiring schemaVersion is consistent with the updated schema. This error message clearly indicates what users must fix.

packages/project-builder-server/src/api/context.ts (1)

14-14: Use of serviceManager.getService
Nice refactor for improved readability and maintainability. Ensure all references to the service retrieval logic elsewhere are similarly updated.

packages/project-builder-cli/.gitignore (1)

3-9: Added ignore entries for node_modules and Playwright outputs
Great additions to keep build artifacts and test outputs out of source control.

packages/project-builder-cli/tsconfig.e2e.json (1)

1-11: E2E TypeScript configuration
Configuration aligns well with E2E test requirements. NoEmit is suitable, baseUrl and paths are properly set. Looks good!

turbo.json (1)

3-3: New E2E test task and environment pass-through
Good addition to ensure the E2E tests run after the build and have the right environment variables.

Also applies to: 22-24

packages/project-builder-lib/src/migrations/index.ts (1)

46-46: Validate handling of schemaVersion.
Confirm that schemaVersion is guaranteed to be defined and numeric. If config can lack this property, consider a fallback or validation to avoid potential issues.

packages/project-builder-server/src/api/trpc.ts (2)

3-4: Import for UserVisibleError looks correct.
No immediate concerns.


9-20: Enhanced error formatting is well-structured.
Returning isUserVisible and descriptionText aligns with more user-friendly errors. Consider logging or tracking these details if needed.

packages/project-builder-cli/src/index.ts (1)

44-44: Check for dependencies on version parameter.
Dropping the version argument is fine if nothing depends on it. Verify that existing code or scripts don’t rely on passing a version to addServeCommand.

packages/project-builder-cli/playwright.config.ts (1)

1-36: Looks great!
Good configuration for Playwright with parallelization, CI-friendly retries, and multiple browsers defined.

.github/workflows/test-e2e.yml (1)

36-36: Dependency installation looks correct
Thanks for adding the CLI filter; it ensures all relevant dependencies are installed for E2E tests.

packages/project-builder-server/src/api/types.ts (1)

4-8:

Details

❓ Verification inconclusive

Refactored service management
Switching from an array to a single serviceManager aligns the code with the new architecture. Ensure any references to the old structure are updated.


🏁 Script executed:

#!/bin/bash
# Checking for obsolete references to "services" property
rg -A 3 "services\s*:" 

Length of output: 2184


Action Required: Verify All Service Management References

The changes in packages/project-builder-server/src/api/types.ts (using a single serviceManager) correctly reflect the new architecture. However, our grep search detected remaining references to a services array pattern—most notably in:

  • packages/project-builder-server/src/compiler/backend/feature.ts
    The property services: buildServicesForFeature(builder, featureId) is still present, which might conflict with the updated design.

Additionally, similar patterns appear in Docker configuration and generator files. Please review these cases to confirm they either remain valid for their context or need to be refactored to align with the new service management approach.

.changeset/tired-places-pay.md (1)

1-10: Documentation is clear
The new changeset correctly outlines patches and states the introduction of E2E testing for project-builder-cli.

packages/project-builder-cli/tsconfig.json (1)

2-10:

Details

✅ Verification successful

Validate references to external tsconfig files.

Ensure that the referenced files (tsconfig.app.json and tsconfig.e2e.json) exist and are correctly configured, especially as they replace the previous extends approach.


🏁 Script executed:

#!/bin/bash
# Verify existence of tsconfig.app.json and tsconfig.e2e.json in the current package.
fd 'tsconfig.app.json' packages/project-builder-cli
fd 'tsconfig.e2e.json' packages/project-builder-cli

Length of output: 197


External tsconfig References Verified

Both tsconfig.app.json and tsconfig.e2e.json exist within the packages/project-builder-cli directory, confirming that the references in packages/project-builder-cli/tsconfig.json are valid. No changes are required to the configuration.

packages/project-builder-server/src/plugins/plugin-discovery.ts (3)

14-14: Consistent error import.

Replacing InitializeServerError with UserVisibleError aligns with the new user-friendly error handling strategy.


28-31: Improved error transparency.

Throwing a UserVisibleError here helps users understand the issue when the package.json is missing. Good enhancement.


42-46: Enhanced JSON read error.

Switching to UserVisibleError clarifies file read problems and indicates they are user-facing. This is beneficial for surfacing actionable feedback to end users.

packages/project-builder-server/src/service/builder-service.ts (1)

139-145: Confirm name sanitization behavior.

Deriving and sanitizing the project name is logical, but confirm it won’t restrict valid use cases where underscores or other characters are expected. If such characters are needed, consider adjusting the regex or adding a fallback mechanism.

packages/project-builder-web/src/services/error-formatter.ts (3)

1-3: Imports look appropriate.
They align well with the newly introduced TRPC error handling mechanism.


8-8: Good introduction of TypedTRPCClientError.
Defining a specialized error type improves type safety for TRPC errors.


11-18: Enhanced TRPC user-visible error handling.
The conditional logic cleanly checks if the error is user-visible and prints a friendlier message.

packages/project-builder-cli/tests/initialize-project.spec.ts (1)

1-18: New E2E test verifies project initialization.
The flow from adding a project to confirming the final state looks solid and user-centric.

packages/project-builder-web/src/app/ProjectDefinitionProvider/ProjectDefinitionProvider.tsx (2)

57-57: Simplified project state usage.
Removing unused references to currentProjectId reduces complexity in this provider.


170-170: Context override for error formatting.
Passing an empty string omits the default message, ensuring error text is displayed plainly.

packages/project-builder-cli/src/services/logger.ts (2)

3-11: Good extraction of default logger options.
Encapsulating config in a constant improves readability and reuse for advanced setups.


13-13: Logger instantiation with extracted options.
This approach allows future customization without scattering config details.

packages/project-builder-cli/tests/settings.spec.ts (1)

3-17: Validation of basic settings flow looks thorough.
This test accurately verifies that the updated project name is saved and persists after reloading.

packages/tools/eslint.config.node.js (2)

6-21: Flexible Node config generation.
The approach with dynamic extra default project files is clean and extensible.


24-24: Default export usage.
Exporting the config via generateNodeConfig() centralizes the logic neatly.

packages/project-builder-server/src/server/index.ts (1)

1-1: Enhanced server startup return.
Exposing FastifyInstance and BuilderServiceManager fosters more flexible integration and testability.

Also applies to: 16-16, 20-20, 50-50

packages/project-builder-web/src/services/project-id.service.ts (2)

1-10: Local storage project ID handling.
Storing/removing the projectId here is clear and aligns with typical browser usage.


12-30: Query param fallback logic.
Auto-updating localStorage when detecting a projectId in the URL is convenient. Verify that it's only used in browser environments where globalThis.location is defined.

package.json (1)

25-26: Looks good—just ensure the new references exist.

The simplified script references streamline E2E tests. Double-check that the test:e2e and test:e2e:affected steps are properly defined in your turbo configuration.

packages/project-builder-server/src/utils/errors.ts (1)

1-19: User-visible error handling improvement.

Replacing the standard Error with TRPCError and including a default error code is a clean way to provide user-friendly error messages.

packages/project-builder-server/src/server/builder-service-manager.ts (1)

1-64: Service management design looks solid.

Storing services in a map, generating stable IDs via SHAKE256, and ensuring proper cleanup and initialization all follow best practices.

packages/project-builder-cli/src/utils/version.ts (1)

5-29: Stricter error handling enhances reliability.

Switching to always returning a string and throwing if the version is unavailable avoids null-check pitfalls.

packages/project-builder-cli/package.json (3)

25-25: Ensure the new TypeScript build config is valid.
Switching to tsconfig.build.json is a neat way to separate build outputs. Double-check that tsconfig.build.json is kept in sync with project needs, such as correct rootDir, outDir, and include entries.


49-49:

Details

✅ Verification successful

Check for possible vulnerabilities or upgrades for Playwright.
While pinning @playwright/test to 1.51.0 can be stable, ensure there are no known security advisories or performance issues.


🏁 Script executed:

#!/bin/bash
# Description: Query GitHub's advisory DB for known vulnerabilities in @playwright/test

gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "@playwright/test") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}
'

Length of output: 350


Playwright Security & Upgrade Check Confirmed
The GitHub advisory query returned no known security vulnerabilities for @playwright/test version 1.51.0. It appears that the pinned version does not have any reported issues from the advisory DB. However, it's always a good idea to periodically review for updates, performance improvements, or new advisories as future versions are released.


53-53:

Details

✅ Verification successful

Confirm Fastify v5 compatibility and stability.
Upgrading to fastify@5.1.0 may introduce breaking changes if you previously used a major version below 5. Confirm any potential migration steps. Additionally, check for security advisories.


🏁 Script executed:

#!/bin/bash
# Description: Query GitHub's advisory DB for known vulnerabilities in fastify

gh api graphql -f query='
{
  securityVulnerabilities(first: 5, ecosystem: NPM, package: "fastify") {
    nodes {
      advisory {
        summary
        severity
        publishedAt
      }
      vulnerableVersionRange
      firstPatchedVersion {
        identifier
      }
    }
  }
}
'

Length of output: 1495


Fastify v5.1.0 Verified – Confirm Migration Steps if Needed

The GitHub advisory query confirms that the vulnerabilities reported for Fastify affect only versions prior to v5, and none impact Fastify v5.1.0. Based on this, the upgrade appears secure from a vulnerability standpoint. However, please ensure that any required migration steps—especially changes in configuration or plugin compatibility when moving from earlier major versions—are addressed by consulting the Fastify migration guide.

  • Verified that known vulnerabilities target versions below Fastify v5.
  • No current security advisories affect Fastify v5.1.0.
  • Action Required: Manually review the Fastify migration guide to confirm that all necessary adjustments have been made.
packages/project-builder-server/src/server/server.ts (4)

1-1: No issues with the new import.
Importing FeatureFlag here is consistent with your updated WebServerOptions interface.


14-15: Confirm the new dependency usage.
Bringing in BuilderServiceManager aligns with your new centralized service architecture.


24-24: Added serviceManager to WebServerOptions.
Ensure that all callers of buildServer() supply a properly configured serviceManager instance.


32-32: serviceManager destructuring looks correct.
The function now has what it needs to manage services properly.

packages/project-builder-server/src/server/plugin.ts (7)

1-1: FeatureFlag import.
This import ensures that the plugin can handle feature flags seamlessly.


16-16: New import for BuilderServiceManager.
This aligns the plugin with your centralized service management solution.


21-22: Refined plugin signature for serviceManager.
Replacing array-based service handling with a serviceManager parameter centralizes control and simplifies the plugin’s interface.


38-38: serviceManager in TRPC context.
Injecting serviceManager into the context is a clean approach for consistent service lookups.


59-59: Graceful handling of missing services.
Using serviceManager.getService(projectId) plus a 404 fallback is correct and user-friendly.


101-101: Same approach for /web route.
This maintains consistent 404 handling if the service doesn’t exist.


153-153: Proper resource cleanup.
serviceManager.removeAllServices() on close helps ensure a clean shutdown.

packages/project-builder-cli/tests/fixtures/server-fixture.test-helper.ts (4)

19-21: Robust error handling confirmation.

Your logic correctly checks for 'EADDRINUSE' and retries or re-throws other errors. However, confirm whether there are any other transient errors (e.g., permission issues, ephemeral race conditions) that you wish to handle in a similar manner to ensure robust test reliability.

Also applies to: 47-57


66-93: Interface definitions promote clear collaboration.

The ProjectPayload interface is well-defined, making it straightforward to understand how project data is accessed or mutated. Good job including doc comments to clarify usage.


140-223: Potential concurrency concerns with repeated calls to addProject.

Each new call increments projectIdx and writes to a new directory under temporaryDirectory. This might break if the test runs concurrently and multiple processes attempt to manage the same base folder. Validate that your test runs in an isolated environment or consider adding a unique identifier (like a UUID) to the folder name.


242-243: Exporting expect is convenient.

Forwarding expect from @playwright/test here is a neat approach to keep imports tidy in your tests. This is a good pattern to enforce consistent usage of the test library.

packages/project-builder-cli/src/server.ts (1)

25-67: Modular approach to server setup is commendable.

Extracting the logic into serveWebServer clarifies responsibilities, makes it easier to test, and fosters reusability. Good practice!

Comment on lines +45 to +53
await server.register(fastifyHelmet, {
contentSecurityPolicy: {
directives: {
// Disable upgrade-insecure-requests to allow insecure requests to localhost
// This is required for Safari to work (https://github.com/helmetjs/helmet/issues/429)
upgradeInsecureRequests: null,
},
},
});

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

Disable upgradeInsecureRequests with caution.
Allowing mixed content in Safari can be helpful during local development, but it may pose security risks in production. Consider conditionally disabling upgradeInsecureRequests only in development environments.

@kingston kingston merged commit 7cede9b into main Mar 18, 2025
@kingston kingston deleted the kingston/eng-574-introduce-e2e-tests-for-project-creation-and-saving branch March 18, 2025 10:13
@github-actions github-actions Bot mentioned this pull request Mar 18, 2025
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