-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adds headless tests for example apps #2478
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
Conversation
e1ee1c0
to
4a9c181
Compare
3ea3f9d
to
494a31d
Compare
What are next steps here? |
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.
Excellent work!
But I can't decide whether we should remove most of the tests. They're pretty repetitive and unlikely to fail if waspc/todoApp
works. Then again, we run them manually every time...
Another big repetition is the playwright config, so we should decide whether to do something about that too.
# Headless tests | ||
!.env.*.headless | ||
test-results/ |
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.
Hmm, I may have changed my mind on this grouping 😅
It makes sense to kepp all the headless stuff together. But netlify
should definitely be pushed up.
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.
This app is now gone, but the headless ignore patterns are grouped together in all other apps as well 👍
examples/hackathon-submissions/headless-tests/playwright.config.ts
Outdated
Show resolved
Hide resolved
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 this app is supposed to test streaming, can we somehow write the test to check for that (not just the final content)?
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've migrated streaming
to todoApp
with a test that you mention, you'd be pleased 👍
await page.locator("button").click(); | ||
} | ||
|
||
export async function performLogin( |
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 probably skip on testing the signup and the login in all apps. It's a lot of repetitive code that brings little benefit I'd say.
However, if and where we test for it (e.g., in waspc/todoApp
), we should also test for unsuccessful logins and signups.
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.
Jumping in a bit, but I see this is in helper.ts and I guess login is just needed to test the rest of the app, so probably no point in trying to do less of it?
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.
Yep, testing login and signup is something we do along the way because we need to authenticate anyways to test the apps.
// Fill input[name="description"] with random task | ||
await page.locator("input[name='description']").fill(randomTask); | ||
// Click input[type="submit"] to submit the form | ||
await page.locator("input[type='submit']").click(); | ||
// Expect to see the task on the page | ||
await expect(page.locator("body")).toContainText(randomTask); | ||
// Check the task as done input[type="checkbox"] | ||
await page.locator("input[type='checkbox']").click(); | ||
// Reload the page | ||
await page.reload(); | ||
// Expect the task to be checked | ||
await expect(page.locator("input[type='checkbox']")).toBeChecked(); | ||
}); |
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.
The comments are probably gpt leftovers, we can remove them :)
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.
Yep, probably me telling Copilot what to write (or I generated this with Playwright's extension, not sure).
examples/tutorials/TodoAppTs/headless-tests/tests/simple.spec.ts
Outdated
Show resolved
Hide resolved
119a4b4
to
f7cb11b
Compare
Signed-off-by: Mihovil Ilakovac <[email protected]>
f0e42a0
to
a8ea42c
Compare
Signed-off-by: Mihovil Ilakovac <[email protected]>
@@ -8,16 +8,16 @@ import addWaspSourceHeader from '../common/addWaspSourceHeader' | |||
|
|||
import mainLogo from '../common/waspello-logo.svg' |
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.
Move to Typescript to cleanup a bit, there was a type error hiding in the Signup page, so I wanted to convert the Login as well.
@@ -7,18 +7,16 @@ import addWaspSourceHeader from '../common/addWaspSourceHeader' | |||
|
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.
There was a type error (which I didn't notice) when using this code with the latest released Wasp, but this code works with main
Wasp CLI. Cleaned up and converted to Typescript just in case.
@@ -11,38 +11,18 @@ | |||
{ |
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.
Migrated to latest tsconfig.json
@@ -1,13 +1,21 @@ | |||
import { type ServerToClientPayload, useSocket, useSocketListener } from "wasp/client/webSocket"; |
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.
Most of this file is formatting, but I added some classes for easier headless testing
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.
Went through it again.
Everything looks ok functionally, but I'm still uneasy about the duplication:
playwright.config.ts
files seem to be identical, at least we intend them to be. But they're already drifting apart through small unintended differences (e.g., quotes and variables, check screenshot below).- I believe the same applies for
simple.spec.ts
files.
Can we do anything about this? It doesn't need to be fancy. For example, we could symlink them all to the same file.
} catch (err) { | ||
if (err.statusCode == 422) { | ||
} catch (err: any) { | ||
// TODO: Update this to check against WaspHttpError https://github.com/wasp-lang/wasp/issues/2767 |
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 mention this in the issue? We'll otherwise forget to update it.
} catch (err) { | ||
if (err.statusCode == 422) { | ||
} catch (err: any) { | ||
// TODO: Update this to check against WaspHttpError https://github.com/wasp-lang/wasp/issues/2767 |
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.
Also please mention it in the issue.
I get you, I agree with you on the config duplication, but in the tests I wouldn't try to be fancy since most of the work is just replicating what users would do manually while testing the app. t might get quite messy if we try to abstract that away.
I guess we are trying to solve the issue of sharing JS code between multiple different Wasp apps. I'm not sure symlinking is the best way to go (it feels OS specific to me, correct if I'm wrong). This is one argument for publishing the Maybe we can locally install the |
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.
Talked out of band, we'll handle the duplication separately. @infomiho Please link the issue when you create it.
Good to go!
Great, thanks! I'll merge this then and here's the issue for deduplication effort: #2790 |
examples/waspello
examples/waspleau
examples/websockets-realtime-voting
examples/tutorials/TodoApp
examples/tutorials/TodoAppTs