From 03f989f9107cd9c8bf498eba90d5929715b6496f Mon Sep 17 00:00:00 2001 From: vincanger <70215737+vincanger@users.noreply.github.com> Date: Thu, 18 Jul 2024 13:06:13 +0200 Subject: [PATCH] Add test docs (#239) * add test docs * Update README.md * Update contentSections.ts.diff --- .../src/landing-page/contentSections.ts.diff | 2 +- opensaas-sh/blog/astro.config.mjs | 1 + .../blog/src/content/docs/guides/tests.md | 36 +++++++++++++++++++ template/e2e-tests/README.md | 9 +++-- 4 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 opensaas-sh/blog/src/content/docs/guides/tests.md diff --git a/opensaas-sh/app_diff/src/landing-page/contentSections.ts.diff b/opensaas-sh/app_diff/src/landing-page/contentSections.ts.diff index 83a874c..0324bbb 100644 --- a/opensaas-sh/app_diff/src/landing-page/contentSections.ts.diff +++ b/opensaas-sh/app_diff/src/landing-page/contentSections.ts.diff @@ -92,7 +92,7 @@ + name: 'E2E Tests w/ Playwright', + description: 'Move fast without breaking too much. Tests and a CI pipeline w/ GitHub Actions are set up for you.', + icon: '๐Ÿงช', -+ href: DocsUrl, ++ href: DocsUrl + '/guides/tests/', + }, + { + name: 'Complete Documentation & Support', diff --git a/opensaas-sh/blog/astro.config.mjs b/opensaas-sh/blog/astro.config.mjs index f1fd179..5321b9d 100644 --- a/opensaas-sh/blog/astro.config.mjs +++ b/opensaas-sh/blog/astro.config.mjs @@ -68,6 +68,7 @@ export default defineConfig({ { label: 'Email Sending', link: '/guides/email-sending/' }, { label: 'File Uploading', link: '/guides/file-uploading/' }, { label: 'Cookie Consent', link: '/guides/cookie-consent/' }, + { label: 'Tests', link: '/guides/tests/' }, { label: 'Deploying', link: '/guides/deploying/' }, ], }, diff --git a/opensaas-sh/blog/src/content/docs/guides/tests.md b/opensaas-sh/blog/src/content/docs/guides/tests.md new file mode 100644 index 0000000..e4da7ed --- /dev/null +++ b/opensaas-sh/blog/src/content/docs/guides/tests.md @@ -0,0 +1,36 @@ +--- +title: Tests +banner: + content: | + Open SaaS is now running on Wasp v0.14!
๐Ÿ๐Ÿš€
If you're running an older version, please follow the migration instructions. +--- + +This guide will show you how to use the included end-to-end (e2e) tests for your Open SaaS application. + +## The Tests Directory + +In the root of your project, you'll find an `e2e-tests` directory which contains the [Playwright](https://playwright.dev) tests for your Open SaaS application.: + +``` +. +โ”œโ”€โ”€ e2e-tests/ +โ”‚ โ”œโ”€โ”€ tests/ # Directory containing the test files +โ”‚ โ”œโ”€โ”€ README.md # Instructions on how to run the tests +โ”‚ โ”œโ”€โ”€ ci-start-app-and-db.js # Script to start the app and db for CI +โ”‚ โ”œโ”€โ”€ playwright.config.ts # Playwright configuration +โ”‚ โ”œโ”€โ”€ package.json +โ”‚ โ”œโ”€โ”€ ... +``` + +To run the tests locally, or in a CI pipeline, follow the instructions in the `README.md` file in the `e2e-tests` directory. + +## Using Tests in CI with GitHub Actions +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](https://github.com/wasp-lang/open-saas). + +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. + +:::caution[WASP_VERSION] +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. diff --git a/template/e2e-tests/README.md b/template/e2e-tests/README.md index 3df4eb0..7cc2b26 100644 --- a/template/e2e-tests/README.md +++ b/template/e2e-tests/README.md @@ -36,8 +36,13 @@ To exit the local e2e tests, go back to the terminal were you started your tests ## CI/CD -In `.github/workflows/e2e-tests.yml`, you can see the workflow that runs the headless e2e tests in a CI/CD pipeline via GitHub actions. +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](https://github.com/wasp-lang/open-saas). -In order for these tests to run correctly, 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. +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.