-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add headless tests to starter templates #2868
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,79 @@ | |||
#!/bin/bash | |||
|
|||
# Script to run E2E tests for a given Wasp template. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a script because we need to generate projects from the starter templates.
Starter templates are not valid wasp projects:
- Missing files which are part of starters skeleton
main.wasp
has interpolation placeholder values for e.g. version, which is invalid wasp syntax
@@ -0,0 +1,6 @@ | |||
import { expect, test } from "@playwright/test"; | |||
|
|||
test("health check", async ({ page }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Text the app runs successfully and works."
use: { ...devices["Desktop Chrome"] }, | ||
}, | ||
// { | ||
// name: "firefox", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we are only testing that the app works, mobile is not really needed.
Though it might be useful to try it with firefox and webkit since we did have a firefox only bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After we decide I will of course remove all the commented code.
Deploying wasp-docs-on-main with
|
Latest commit: |
373f731
|
Status: | ✅ Deploy successful! |
Preview URL: | https://b8b48221.wasp-docs-on-main.pages.dev |
Branch Preview URL: | https://franjo-starters-headless-tes.wasp-docs-on-main.pages.dev |
…ess-tests # Conflicts: # waspc/cli/src/Wasp/Cli/Command/CreateNewProject/StarterTemplates.hs # waspc/data/Cli/starters/README.md
"main": "index.js", | ||
"keywords": [], | ||
"scripts": { | ||
"test": "for starter in basic minimal; do ./run-starter-headless-tests.sh $starter wasp || exit 1; done", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a better way for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions
@@ -0,0 +1,70 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe the script can run npm install
before starting to ensure Playwright is installed.
We could run npx -y playwright test
to avoid asking the user if they want to install the Playwright CLI.
DEBUG=pw:webserver E2E_APP_PATH="./${TEMP_PROJECT_NAME}" WASP_CLI_CMD="${WASP_CLI_CMD}" HEADLESS_TEST_MODE=build npx playwright test | ||
} | ||
|
||
template_uses_sqlite() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like the sqlite
detection is kinda fragile, can we do better?
Do we want to upgrade from bash to Node.js and use zx
here - we can reuse same logic for detecting SQlite from the Wasp App Runner: https://github.com/wasp-lang/wasp/blob/main/wasp-app-runner/src/waspCli.ts#L94
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to use zx
regardless of reusing the SQLite detection logic, I feel like it's a quite common tool we use (Wasp App Runner, deploy package).
"test:dev": "for starter in basic minimal; do ./run-starter-headless-tests.sh $starter wasp-cli || exit 1; done" | ||
}, | ||
"devDependencies": { | ||
"@playwright/test": "^1.53.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest we pin the Playwright version so browsers can be reused (Playwright versions and browser version are tied together).
We use the same version across kitchen sink app and example apps, I believe it's "@playwright/test": "1.51.1"
@@ -0,0 +1,6 @@ | |||
import { expect, test } from "@playwright/test"; | |||
|
|||
test("health check", async ({ page }) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be much more comfortable with not testing starters manually we did something like added a new task with the basic
template.
@@ -0,0 +1,70 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we test saas
starter with this as well?
- There is an issue that the
saas
template has the app in the/app
folder. - Also the
saas
starter needs some.env
vars set up to be able to run the app. - We can't test the
saas
starter in production mode with email sender set asDummy
.
@@ -0,0 +1,70 @@ | |||
#!/bin/bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could be declarative around which tests we are doing, and define an object:
minimal
/ [sqlite
] / use.
as dirbasic
/ [sqlite
] / use.
as dirsaas
/ [postgres
] / useapp
as dir
This way we don't bother with parsing the db type and we can declare stuff like app dir.
Also, do we see some value in testing all the starters with both database types?
Fixes: #2833
Since starter templates are not a valid Wasp project by themselves, we need to use Wasp CLI to generate the projects to test them out.
For that I created the
waspc/starters-headless-tests/run-starter-headless-tests.sh
script.It:
sqlite
, runs the headless test in BUILD modeNote: we are only testing
minimal
andbasic
starters here.open-saas
has it's own tests, and we are not testing AI generated apps.