Skip to content

Conversation

@teesloane
Copy link
Contributor

@teesloane teesloane commented Mar 27, 2025

Describe your changes

This PR adds Playwright e2e testing and a handful of example tests. A few notes:

  • Notes on running the e2e test have been added to the readme
  • A few small changes to the application code were required to get tests to be able to target dom elements
  • It is about 90% reliable, and I haven't quite figured out why 10% of the time or tests seem to fail (or rather, they fail, and then when run again they pass).
    • Depending on your internet connection, you could run into issues with the Google maps auto complete working when creating a campaign
    • Sometimes creating a program just... fails when trying to click a text box

I'd like to write more tests, but I also wanted to check in to see if this is going in the right direction first.

NOTE: At this time, running e2e tests just pollutes your local dev. So, I've been dropping the DB and resetting it before fresh runs. The tests have been written in a way to allow continuously running them, but it clutters your db. It may be possible to use the Ecto Sandbox to resolve this (here's a blog post going over that) but I didn't have any luck trying to set that up.

Checklist before requesting a review

  • I have performed a self-review of my code
  • If it is a core feature, I have added tests.
  • Are there other PRs or Issues that I should link to here?
  • Will this be part of a product update? If yes, please write one phrase
    about this update in the description above.
CleanShot.2025-03-27.at.15.23.00.mp4

@impl true
def mount(socket) do
programs = for p <- Delivery.list_programs(), do: {p.name, p.id}
programs = for p <- Delivery.list_programs(), do: [key: p.name, value: p.id, label: p.name]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was required in order to add "label" attributes to options in the <select> tag; these labels are used to traget dropdowns in tests.

"assets.deploy": ["esbuild default --minify", "tailwind default --minify", "phx.digest"]
"assets.deploy": ["esbuild default --minify", "tailwind default --minify", "phx.digest"],
# REVIEW: Sometimes this hangs on a query - `INSERT INTO "tasks_items"...`
"test.e2e": ["ecto.drop", "phx.server"]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure what's going on here—but it just seems to hang. Maybe just remove it?

Comment on lines +43 to +50
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It might be worth removing testing for Firefox and Safari?

Comment on lines +146 to +149
// once the program is created, we need to find it on the program page and EDIT it,
// because at this time there is no "add items" for part when creating a new program
// (only when editing it)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder if this is an intentional part of the New Program form, or if the ability to add items should be possible in that form.

@teesloane teesloane requested a review from mveytsman March 27, 2025 19:33
@mveytsman
Copy link
Member

Hmm is it possible to get this to at least run in the test database instead of dev in order to not wipe it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants