Files
open-saas/template/e2e-tests
vincanger 7d36c8f0b1 Refactor file upload and toast notifications (#472)
* Refactor file upload and toast notifications

Replaces react-hot-toast with a custom toast system using @radix-ui/react-toast, updating all usages and adding new UI components for toast and dialog. Refactors file upload to use a two-step process: first generating an S3 upload URL, then adding the file to the database, and adds file deletion support with confirmation dialog and S3 cleanup. Updates Prisma schema, removes unused fields, and cleans up navigation and admin settings page.

* Enforce file upload limit and update dependencies on opensaas-sh

Added a check to restrict users to 2 file uploads in the demo, with a new helper function and error handling. Updated navigation items, improved landing page content, and removed unused dependencies (react-hot-toast). Added @radix-ui/react-toast, updated testimonials, and made minor content and code improvements.

* update tests

* Improve file deletion error handling and cleanup

Refactors file deletion to delete the database record before attempting S3 deletion, ensuring the file is removed from the app even if S3 deletion fails. Adds error logging for failed S3 deletions to aid in manual cleanup. Also simplifies error handling in the file upload page and removes unused imports in the demo app page.

* Add credit check and S3 file existence validation

Added logic to decrement user credits or throw an error if out of credits in the AI demo app. Updated file upload operations to validate file existence in S3 before adding to the database, and implemented S3 file existence check utility. Minor UI and code improvements included.

* Update s3Utils.ts

* update app_diff

* fix diff

* Update deletions

* Improve toast UI, error handling, and credit messaging

Updated toast action hover style and icon spacing for better UI consistency. Enhanced error handling in file deletion to display specific error messages. Refined credit/subscription error message in GPT response operation for clarity and removed redundant credit decrement logic.

* Refactor file upload validation and error handling

Replaces error state management with toast notifications for file upload errors and success. Refactors file type validation to use a new ALLOWED_FILE_TYPES_CONST and type AllowedFileTypes. Updates validation logic to throw errors instead of returning error objects, and simplifies type handling across file upload modules.

* Refactor file upload to use s3Key and add cleanup job

Replaces the 'key' field with 's3Key' for file storage references throughout the codebase and database schema. Updates all related logic, types, and API contracts to use 's3Key'. Adds a scheduled job to delete old files from S3 and the database. Cleans up file type validation constants and improves consistency in file upload and download operations.

* add orphaned file clean up

* remove s3 cleanup job from template

removed but added suggestion to docs.

* Update SettingsPage.tsx

* prettier format

* Update  UI, remove unused files

Updated README with deployment and demo details. Removed unused App.tsx and package-lock.json files. Modified Main.css, NavBar constants, file uploading logic, file upload operations, and landing page content sections for improved UI and functionality.

* remove pricing page from isMarketingPage
2025-10-15 12:01:08 +02:00
..

Open SaaS e2e Tests with Playwright

These are e2e tests that are written using Playwright for the Open SaaS project.

They not only serve as tests for development of the Open SaaS project, but also as reference examples for how you can implement tests for the app you build with Open SaaS as a template, if you choose to do so.

Running the tests

Locally

First, make sure you've integrated Stripe into your app. This includes installing the Stripe CLI and logging into it with your Stripe account.

Next, Install the test dependencies:

cd e2e-tests && npm install

Start your Wasp DB and leave it running:

cd ../app && wasp db start

Skipping Email Verification in e2e Tests

Open another terminal and start the Wasp app with the environment variable set to skip email verification in development mode:

Important

When using the email auth method, a verification link is typically sent when a user registers. If you're using the default Dummy provider, this link is logged in the console.

However, during e2e tests, this manual step will cause the tests to hang and fail because the link is never clicked. To prevent this, set the following environment variable when starting your app:

cd app && SKIP_EMAIL_VERIFICATION_IN_DEV=true wasp start

What this step will do:

  • Automated Testing: Skipping email verification ensures e2e tests run uninterrupted.
  • Consistent Behavior: It guarantees login flows wont break during automated test runs.
  • CI/CD Pipelines: This variable should also be set in CI pipelines to avoid test failures.
    env:
      SKIP_EMAIL_VERIFICATION_IN_DEV: "true"
    

In another terminal, run the local e2e tests:

cd e2e-tests && npm run local:e2e:start

This will start the tests in Playwright's UI mode, which will allow you to see and run the tests in an interactive browser environment. You should also see the Stripe events being triggered in the terminal where the tests were started.

To exit the local e2e tests, go back to the terminal were you started your tests and press ctrl + c.

CI/CD

Although the Open SaaS template does not come with an example workflow, you can find one at .github/workflows/e2e-tests.yml of the remote repo.

You can copy and paste the .github/ directory containing the e2e-tests.yml workflow into the root of your own repository to run the tests as part of your CI pipeline.

Important

Please make sure to update the WASP_VERSION environment variable in the e2e-tests.yml file to match the version of Wasp you are using in your project.

In order for these tests to run correctly on GitHub, you need to provide the environment variables mentioned in the e2e-tests.yml file within your GitHub repository's "Actions" secrets so that they can be accessed by the tests.

Upon pushing to the repository's main branch, or creating a PR against the main branch, the tests will run in the CI/CD pipeline.