Skip to content

Comments

feat: add playwright tests that do not require cucumber feature files#658

Merged
carlosthe19916 merged 19 commits intoguacsec:mainfrom
carlosthe19916:task/move-trustify-testsw
Sep 10, 2025
Merged

feat: add playwright tests that do not require cucumber feature files#658
carlosthe19916 merged 19 commits intoguacsec:mainfrom
carlosthe19916:task/move-trustify-testsw

Conversation

@carlosthe19916
Copy link
Collaborator

@carlosthe19916 carlosthe19916 commented Aug 20, 2025

Summary by Sourcery

Set up a standalone Playwright-based end-to-end testing suite without relying on Cucumber feature files by adding page object abstractions and comprehensive UI test specifications, and update the devcontainer configuration to enable code generation support.

New Features:

  • Introduce Playwright page objects for Toolbar, Table, Pagination, DetailsPageLayout, Navigation, and LabelsModal components
  • Add domain-specific tab page classes for vulnerabilities, advisories, SBOMs, packages, and their list/detail pages
  • Implement end-to-end UI test specs covering filtering, sorting, pagination, and action flows for all main entities

Enhancements:

  • Update devcontainer template to reference the Dockerfile within the .devcontainer directory for proper codegen integration
  • Incorporate changes from the previous PR to consolidate Playwright test setup

Tests:

  • Add comprehensive Playwright test files for advisory-list, package-list, sbom-list, vulnerability-list, and their corresponding detail tabs

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Sorry @carlosthe19916, your pull request is too large to review

@codecov
Copy link

codecov bot commented Aug 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.21%. Comparing base (888b0d3) to head (f70fa03).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #658      +/-   ##
==========================================
+ Coverage   57.28%   63.21%   +5.93%     
==========================================
  Files         146      150       +4     
  Lines        2430     2474      +44     
  Branches      552      561       +9     
==========================================
+ Hits         1392     1564     +172     
+ Misses        833      687     -146     
- Partials      205      223      +18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@carlosthe19916 carlosthe19916 changed the title Move trustify-tests & include PR #62 feat: add playwright tests that do not require cucumber feature files Aug 21, 2025
@carlosthe19916 carlosthe19916 added the backport release/0.3.z This PR should be backported to release/0.3.z branch. label Aug 21, 2025
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
# Conflicts:
#	.devcontainer/template.json
@carlosthe19916 carlosthe19916 force-pushed the task/move-trustify-testsw branch from afd3bbd to 07f30d6 Compare August 21, 2025 12:05
@carlosthe19916 carlosthe19916 marked this pull request as ready for review August 21, 2025 12:13
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Aug 21, 2025

Reviewer's Guide

This PR migrates and consolidates the existing Trustify-tests into a full Playwright-based E2E suite by introducing page object model classes, test pages and tabs, helper utilities, and comprehensive spec files for UI interactions, along with updating the devcontainer configuration to point at the correct Dockerfile.

File-Level Changes

Change Details Files
Update devcontainer setup
  • Point devcontainer template to local Dockerfile
  • Include .env file for environment configuration
.devcontainer/template.json
.env
Introduce core Playwright page object model classes
  • Add Toolbar, Table, Pagination, DetailsPageLayout, LabelsModal, Navigation classes
  • Ensure each POM class exposes build methods and common UI actions
e2e/tests/ui/pages/Toolbar.ts
e2e/tests/ui/pages/Table.ts
e2e/tests/ui/pages/Pagination.ts
e2e/tests/ui/pages/DetailsPageLayout.ts
e2e/tests/ui/pages/LabelsModal.ts
e2e/tests/ui/pages/Navigation.ts
Add page and tab object classes for list and detail views
  • Implement ListPage classes for Advisories, Packages, SBOMs, Vulnerabilities
  • Implement DetailsPage classes and associated Tab classes under each feature
e2e/tests/ui/pages/advisory-list/AdvisoryListPage.ts
e2e/tests/ui/pages/package-list/PackageListPage.ts
e2e/tests/ui/pages/sbom-list/SbomListPage.ts
e2e/tests/ui/pages/vulnerability-list/VulnerabilityListPage.ts
e2e/tests/ui/pages/advisory-details/AdvisoryDetailsPage.ts
e2e/tests/ui/pages/package-details/PackageDetailsPage.ts
e2e/tests/ui/pages/sbom-details/SbomDetailsPage.ts
e2e/tests/ui/pages/vulnerability-details/VulnerabilityDetailsPage.ts
e2e/tests/ui/pages/advisory-details/vulnerabilities/VulnerabilitiesTab.ts
e2e/tests/ui/pages/advisory-details/sboms/SbomsTab.ts
e2e/tests/ui/pages/advisory-details/advisories/AdvisoriesTab.ts
e2e/tests/ui/pages/package-details/vulnerabilities/VulnerabilitiesTab.ts
e2e/tests/ui/pages/package-details/sboms/SbomsTab.ts
e2e/tests/ui/pages/sbom-details/vulnerabilities/VulnerabilitiesTab.ts
e2e/tests/ui/pages/sbom-details/packages/PackagesTab.ts
e2e/tests/ui/pages/vulnerability-details/advisories/AdvisoriesTab.ts
e2e/tests/ui/pages/vulnerability-details/sboms/SbomsTab.ts
Add helper utilities for test assertions
  • Implement sortArray and expectSort functions for sorting assertions
e2e/tests/ui/pages/Helpers.ts
Add comprehensive spec files for UI functionality
  • Cover columns, filtering, sorting, pagination, actions, and info across all pages
  • Include additional tests like donutchart where applicable
e2e/tests/ui/pages/**/*.spec.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes - here's some feedback:

  • Consider DRY-ing up the nearly identical Tab classes by extracting a generic base or factory to reduce boilerplate and maintenance overhead.
  • Many page objects expose internal Locator fields (e.g. _toolbar, _table) publicly – make those private or provide explicit methods to better encapsulate implementation details.
  • Navigation.goToSidebar always starts by calling /upload; this indirection can slow or break tests—consider parameterizing the entry path or navigating directly to the target page.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider DRY-ing up the nearly identical Tab classes by extracting a generic base or factory to reduce boilerplate and maintenance overhead.
- Many page objects expose internal Locator fields (e.g. _toolbar, _table) publicly – make those private or provide explicit methods to better encapsulate implementation details.
- Navigation.goToSidebar always starts by calling `/upload`; this indirection can slow or break tests—consider parameterizing the entry path or navigating directly to the target page.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Contributor

@vobratil vobratil left a comment

Choose a reason for hiding this comment

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

@carlosthe19916 Overall, I'd say the code is up to a high standard and can be approved. However, I can see that it has a rather large overlap with the currently existing UI tests, duplicating many of the methods and scenarios. Seeing as we already have less time to write these tests than we would like, I'd really like to avoid having to extensively rewrite the little that's already in there. It would be nice to get an opinion from @queria on how to approach this.

One way to avoid the overlap and have a situation where we have a test run where certain tests run basically twice or more times (differently named tests that test the same thing), would be to add tags to these tests. If I understand it correctly, the purpose of this PR is to test UI elements, whereas the QE tests are supposed to test user scenarios, which currently leads to very similar tests. It's possible that the QE tests will eventually diverge from these UI element tests, so it would make sense to run these two sets separately. Again, would like the opinion of @queria .

Aside from the above, I've left a few comments on minor improvements and notes on what to watch out for in the future.

await tab.click();
}

async clickOnPageAction(actionName: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should make sure to unify the usage of methods like this across the repo, since they also implemented somewhere in the UI tests directory exactly the same way and used in the tests. The better we do this, the less of a pain it will be. I'm just adding this comment, so we don't forget to create issues in the repo for this sort of thing.

@@ -0,0 +1,23 @@
import { expect } from "@playwright/test";

export const sortArray = (arr: string[], asc: boolean) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above. I'm pretty sure that Rajan implemented something similar in one of his tests, so we should make sure we don't duplicate code unnecessarily.

// Navigate to next page
await nextPageButton.click();

// Verify that previous buttons are enabled after moving to next page
Copy link
Contributor

Choose a reason for hiding this comment

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

If we are this thorough, should we also check if the next button is disabled on the last page?

await this._page.getByRole("menuitem", { name: actionName }).click();
}

async verifyTableIsSortedBy(columnName: string, asc: boolean = true) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, this and the next method are for sure candidates for unification with what's already in some of the UI tests.

@queria queria added the tests label Sep 8, 2025
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
@queria
Copy link

queria commented Sep 8, 2025

@sourcery-ai review

@SourceryAI
Copy link

Hi @queria! 👋

Only authors and team members can run @sourcery-ai commands on public repos.

If you are a team member, install the @sourcery-ai bot to get access ✨

@queria
Copy link

queria commented Sep 8, 2025

@sourcery-ai review

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@queria
Copy link

queria commented Sep 9, 2025

Hey there - I've reviewed your changes and they look great!
Sourcery is free for open source - if you like our reviews please consider sharing them ✨

* [X](https://twitter.com/intent/tweet?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai)

* [Mastodon](https://mastodon.social/share?text=I%20just%20got%20an%20instant%20code%20review%20from%20%40SourceryAI%2C%20and%20it%20was%20brilliant%21%20It%27s%20free%20for%20open%20source%20and%20has%20a%20free%20trial%20for%20private%20code.%20Check%20it%20out%20https%3A//sourcery.ai)

* [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https://sourcery.ai)

* [Facebook](https://www.facebook.com/sharer/sharer.php?u=https://sourcery.ai)

Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@sourcery-ai
Can You also consider the review comments from vobratil, and recommend which helpers or page objects can be deduplicated in this PR and existing ui test steps?

Signed-off-by: Carlos Feria <2582866+carlosthe19916@users.noreply.github.com>
@carlosthe19916
Copy link
Collaborator Author

@vobratil @queria i addressed all your suggestions in separate commits. The remaining ones are about justified code duplication tasks. I suggest we create issues for not forgetting those things. general speaking the verification for duplication should cover sorting, pagination, filtering

@carlosthe19916
Copy link
Collaborator Author

carlosthe19916 commented Sep 10, 2025

@vobratil @queria don't want to put pressure. But it would be nice to merge this PR and immediately after , anyone of us create the gh issues for address duplication. Unless there are more required changes needed in this PR :)

@vobratil
Copy link
Contributor

vobratil commented Sep 10, 2025

@carlosthe19916 Yeah, I agree. Could you just please tag all the tests with a tag, e.g. @ui-elements? That way we can easily run these tests separately or exclude them from the test run. Hopefully it will be possible with just the search and replace function in VS Code.

@carlosthe19916
Copy link
Collaborator Author

carlosthe19916 commented Sep 10, 2025

@carlosthe19916 Yeah, I agree. Could you just please tag all the tests with a tag, e.g. @ui-elements? That way we can easily run these tests separately or exclude them from the test run. Hopefully it will be possible with just the search and replace function in VS Code.

@vobratil
I can definitely add tags. But as of today there is already a clear separation between the BDD Cucumber tests and the tests proposed in this PR.

For executing only the BDD tests we would do (all tests in this PR will be excluded):

npx playwright test --project='bdd'

On the other hand, for executing only the tests in this PR without including any of the bdd tests we could do:

npx playwright test --project='chromium'

As per this PR, both will run, the dbb and the tests inside this PR as defined in the package.json here https://github.com/carlosthe19916/trustify-ui/blob/task/move-trustify-testsw/e2e/package.json#L12C31-L12C71

And the separation between dbb and the tests in this PR are defined here https://github.com/carlosthe19916/trustify-ui/blob/task/move-trustify-testsw/e2e/playwright.config.ts#L73-L80

I can add tags, but I think we could use tags in a different way. i believe we already have some tags like slow, which means that we could use that tag both in the dbb tests as well ass the tests in this PR and when eventually execute those tests we can filter tests by tags. So I would use tags more globally and use our current separation of projects (https://github.com/carlosthe19916/trustify-ui/blob/task/move-trustify-testsw/e2e/playwright.config.ts#L73-L80) to divide dbb and vanilla tests

@carlosthe19916 carlosthe19916 added needs-backport Indicates a PR needs to be backported and removed backport release/0.3.z This PR should be backported to release/0.3.z branch. labels Sep 10, 2025
@carlosthe19916
Copy link
Collaborator Author

carlosthe19916 commented Sep 10, 2025

Btw, same logic applies to the "api" tests, we are not setting labels to separate api tests, we are using Playwright projects. E.g. npx playwright test --project='api'. Labels should be used for different purposes

@vobratil
Copy link
Contributor

@carlosthe19916 Oh, I didn't know you could run the BDD tests like that. In that case there's nothing else to discuss. Approving :).

Copy link
Contributor

@vobratil vobratil left a comment

Choose a reason for hiding this comment

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

@carlosthe19916 After the discussion, I don't think this PR needs any more changes. Approved.

@carlosthe19916 carlosthe19916 added this pull request to the merge queue Sep 10, 2025
Merged via the queue into guacsec:main with commit 947d2c4 Sep 10, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-backport Indicates a PR needs to be backported tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants