Skip to content
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

Introduce Playwright for simple integration tests #2455

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from

Conversation

lightswitch05
Copy link
Member

@lightswitch05 lightswitch05 commented Dec 10, 2022

  • What does this PR aim to accomplish?:

I've been playing around with Playwright E2E testing at work, and I thought it might be fun to see if I could add some tests here. I have absolutely no idea if this appeals to anyone here, and I realize that I didn't really discuss it first, but perhaps we can discuss it now, and no hard feelings if it isn't really inline with the project.

  • How does this PR accomplish the above?:

There is a lot in here, and so I'm going to make a bunch of comments on the individual files to perhaps make it more clear. The overall idea is to start up a Pihole docker container with this repo volume-mounted within it. Next, startup a playwright docker container to run tests against the Pihole. Playwright does not have to be ran from docker, but I thought it made networking simple in this case.

There are only two tests in here at the moment, and they are very basic. The majority of this PR is just all setup, if y'all like this PR and accept the changes, then it wouldn't be much more work to expand out the tests to hit more pages.

  • What documentation changes (if any) are needed to support this PR?:

n/a, or perhaps make a note about having docker-compose and running ./tests/run


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code and I have tested my changes.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

  • I have read the above and my PR is ready for review. Check this box to confirm

dev-pihole:
image: ghcr.io/pi-hole/pihole:latest
volumes:
- ../:/var/www/html/admin:ro
Copy link
Member Author

Choose a reason for hiding this comment

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

To have functional frontend tests, you need a backend too. I achieved this by using the official docker image and overlaying the repo code.

// Save signed-in state to 'storageState.json'.
await page.context().storageState({ path: 'storageState.json' });
await browser.close();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

All this setup does is log into the Pihole a single time and then extracts the cookies so that the different browsers and tests do not also have to login multiple times

@lightswitch05 lightswitch05 force-pushed the testing/add-playwright-integration-tests-2 branch from 6637e26 to 85e52c0 Compare December 13, 2022 01:01
@lightswitch05 lightswitch05 force-pushed the testing/add-playwright-integration-tests-2 branch 6 times, most recently from fc02f17 to a41fb49 Compare December 23, 2022 15:38
…sons

Signed-off-by: Daniel <daniel@developerdan.com>
@lightswitch05 lightswitch05 force-pushed the testing/add-playwright-integration-tests-2 branch from a41fb49 to 4d33966 Compare December 23, 2022 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant