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 Functional Tests using Playwright and Behave #31

Merged
merged 68 commits into from
Jan 13, 2025

Conversation

AdamHawtin
Copy link
Contributor

@AdamHawtin AdamHawtin commented Nov 18, 2024

What is the context of this PR?

This PR adds functional tests for the app, written in the Behave BDD framework and using Playwright to test browser interactions.

How to review

  • Try running the functional tests in your development environment, following the new instructions in the README

  • Review the new documentation. Does it provide enough guidance for you to be happy adding new test features/scenarios as part of future work? Do the suggested code standards and patterns make sense? These are intended to be a starting point, based on my experience with large test suites in Behave, but they should be reviewed agreed as a team, not just taken as written.

  • Try running the tests in your IDE or editor of choice. Is it possible to easily run individual scenarios or debug them? Certain functionality might require installing extensions.

  • Check the custom fixture code for test setup and teardown, does it all make sense and is it sufficiently documented and understandable?

  • Check the features and scenarios. These are my initial guesses at some suitable scenarios, they are not driven by any explicit requirements from those features. I am perfectly happy to modify them, or even tear them up and do it differently if people take issue, I just needed some example features in place to demonstrate the code structure.

Follow-up Actions

We still need to agree how we will utilise this method on testing in further development. I would suggest the test scenarios need to be agreed at refinement time for future incoming tickets, but this still needs wider discussion and agreement around how these new tests fit into our definitions or ready and done.

We will also need to dicuss and add tasks for backfilling tests on existing features.

Topics to Revisit:

  • Potential to use serialized_rollback instead of our hand-rolled DSLR based database clean/restore between tests. Can we get it working and to a satisfactory speed?
  • Building reusable page classes for consistent navigation in playwright
  • Consider setting IS_EXTERNAL_ENV to true when testing the external site, to better replicate a production setting
  • Pursuing multi-browser testing

Known Issues

  • The initial scenarios currently only reliably pass in the chromium browser. We have agreed to address this in future work.

@AdamHawtin AdamHawtin force-pushed the playwright-functional-tests-CMS-198 branch from 67ff194 to 47902ad Compare November 19, 2024 15:58
@AdamHawtin AdamHawtin changed the title CMS-198 Introduce Functional Tests using Playwright and Behave Introduce Functional Tests using Playwright and Behave Nov 22, 2024
@AdamHawtin AdamHawtin force-pushed the playwright-functional-tests-CMS-198 branch from 8a307ea to 05a8a7a Compare November 22, 2024 12:26
@sanjeevz3009 sanjeevz3009 self-requested a review November 22, 2024 15:39
Add missing dependency

Ignore pylint false negative

Playwright install in action and try to understand if we have pg_dump available

Try to understand if we have pg_dump available

Set paths to PG client tools, remove debugging outputs

Update the action runner postgres client

apt get update first

Try the postgres package instead

Try brew installation

Use path to brew

Add brew link

Try pointing the pg_dump/restore to the brew install location
Remove step name that may be bad syntax

Update step 'if' syntax

Fix traces path and ensure traces are enabled

Try shortening step name

Fail a step intentionally to get a trace

Add step name

Try removing the new step

Re-add step
… feature

Remove commented code

Neaten up code and add comments
Add make file comments
Stop the markdown linter complaining

Fail a test on purpose

Fix intentional failure
Update README
@AdamHawtin AdamHawtin force-pushed the playwright-functional-tests-CMS-198 branch from e0a271f to 2a0fc49 Compare November 27, 2024 12:36
@AdamHawtin AdamHawtin force-pushed the playwright-functional-tests-CMS-198 branch from 43fa69b to efcdf76 Compare November 29, 2024 13:01
@AdamHawtin AdamHawtin marked this pull request as ready for review November 29, 2024 13:24
@AdamHawtin AdamHawtin requested a review from a team as a code owner November 29, 2024 13:24
Copy link
Contributor

@sanjeevz3009 sanjeevz3009 left a comment

Choose a reason for hiding this comment

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

Reviewed every file. It looks good to me. Pulled down the branch and tested everything locally and things are working as it should. Awesome work @AdamHawtin

Left some minor comments =)

@sanjeevz3009
Copy link
Contributor

sanjeevz3009 commented Dec 2, 2024

@MebinAbraham I know we had this conversation at various stages. But we need to end the docstring madness 😭

I'll show you Mebin in another comment and tag you in. I'll @AdamHawtin into it as well.

Copy link
Contributor

@sanjeevz3009 sanjeevz3009 left a comment

Choose a reason for hiding this comment

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

Tested it everything once again after the recent changes. All is good =)

Copy link
Contributor

@RealOrangeOne RealOrangeOne left a comment

Choose a reason for hiding this comment

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

Assuming the various "revisit later" tasks are tracked somewhere, I think this is fine as a first pass to get something in and working.

@AdamHawtin AdamHawtin merged commit 70c93d7 into main Jan 13, 2025
9 checks passed
@AdamHawtin AdamHawtin deleted the playwright-functional-tests-CMS-198 branch January 13, 2025 10:55
@zerolab
Copy link
Contributor

zerolab commented Jan 13, 2025

🎉

@zerolab zerolab added the DX Developer eXperience label Jan 13, 2025
ababic pushed a commit that referenced this pull request Jan 16, 2025
* main:
  Update the embed block to be a custom video embed that uses the design system video embed template (#62)
  Django Migration Linter Integration (#43)
  Tidy up the info/warning panel and fix title/no title output (#73)
  Introduce Functional Tests using Playwright and Behave #31

# Conflicts:
#	poetry.lock
#	pyproject.toml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DX Developer eXperience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants