Skip to content

Add tests for OTP tokens pages - #1149

Open
carma12 wants to merge 1 commit into
freeipa:mainfrom
carma12:otp-tokens-tests
Open

Add tests for OTP tokens pages#1149
carma12 wants to merge 1 commit into
freeipa:mainfrom
carma12:otp-tokens-tests

Conversation

@carma12

@carma12 carma12 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

The tests should cover all the use cases
of the 'OTP tokens' pages (main, 'Settings',
and 'Is managed by').

Assisted-by: Claude noreply@anthropic.com

Summary by Sourcery

Add comprehensive end-to-end coverage for OTP token management, settings, and manager assignment flows, including supporting test helpers for IPA-backed OTP operations and UI interactions.

New Features:

  • Introduce cucumber feature scenarios for creating, searching, enabling, disabling, and deleting OTP tokens via the main OTP tokens page.
  • Add cucumber feature scenarios for editing OTP token settings, including description, vendor, refresh, and kebab-menu actions (enable, disable, delete).
  • Add cucumber feature scenarios for managing OTP token owners and managers via the "Is managed by" tab.

Enhancements:

  • Extend generic select helper to click inner button elements to support OTP token owner selection in tests.
  • Enhance custom IPA Cypress command to accept execution options for more flexible failure handling.
  • Add shared OTP token management step definitions, including seeding, safe deletion, and table interaction helpers used across OTP-related tests.

Tests:

  • Add new Cypress Cucumber feature files and step definitions covering OTP tokens main page, settings page, and managed-by page end-to-end flows.

@carma12 carma12 self-assigned this Aug 7, 2026
@carma12 carma12 added the needs-review This PR is waiting on a review label Aug 7, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The OTP feature files repeat a lot of boilerplate setup/cleanup (same users/tokens created and deleted in many scenarios); consider extracting common Given steps into shared step definitions or using Background/Scenario Outlines to reduce duplication and make the flows easier to maintain.
  • The updated selectOption helper now assumes that every option element contains a button and uses click({ force: true }); if possible, tighten the selector (e.g., a specific data-cy or role) and assert the button exists before clicking, and only fall back to a forced click when the normal click fails or when a flag is passed, to avoid masking real UI issues.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The OTP feature files repeat a lot of boilerplate setup/cleanup (same users/tokens created and deleted in many scenarios); consider extracting common Given steps into shared step definitions or using Background/Scenario Outlines to reduce duplication and make the flows easier to maintain.
- The updated selectOption helper now assumes that every option element contains a button and uses click({ force: true }); if possible, tighten the selector (e.g., a specific data-cy or role) and assert the button exists before clicking, and only fall back to a forced click when the normal click fails or when a flag is passed, to avoid masking real UI issues.

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.

Comment thread cypress/e2e/otp_tokens/otp_token_management.ts Outdated
Comment thread cypress/e2e/otp_tokens/otp_token_management.ts Outdated
@carma12
carma12 force-pushed the otp-tokens-tests branch 2 times, most recently from 5d689e4 to 49e37da Compare August 11, 2026 11:30
The tests should cover all the use cases
of the 'OTP tokens' pages (main, 'Settings',
and 'Is managed by').

Assisted-by: Claude <noreply@anthropic.com>
Signed-off-by: Carla Martinez <carlmart@redhat.com>
@carma12

carma12 commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator Author

@duzda - I think I amended all the changes mentioned in your feedback.

@veronnicka veronnicka left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi, I have a few suggestions, please look into them.

Then I should see "otpuser" option in the "modal-select-owner" selector

When I click on the "modal-button-add" button
Then I should not see "add-otp-token-modal" modal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And I should see the token in the table or something along the lines

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

similar to this
```
And I should see "add-managedby-success" alert

When I search for "otpmanager" in the members table
Then I should see "otpmanager" entry in the data table

Then I should see "otpuser" option in the "modal-select-owner" selector

When I click on the "modal-button-add" button
Then I should not see "add-otp-token-modal" modal

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

And I should see the token in the table

Then I should not see "add-otp-token-modal" modal

@test
Scenario: Delete button is disabled when no token is selected

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I dont think this test is needed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

and the following two as well

When I click on the "modal-button-ok" button
Then I should not see "enable-disable-otp-tokens-modal" modal
And I should see "success" alert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

there should be @cleanup and @seed again between these tests

And I should not see "delete-otp-tokens-modal" modal

@cleanup
Scenario: Cleanup: Delete test data and remaining tokens

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: the name of the cleanup is a bit confusing

And OTP token "settings_token" exists for user "otpsettingsuser" with type "totp" and description "settings_token"

@test
Scenario: Save and Revert buttons are disabled when no changes

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this test is not necessary


When I click on the "otp-tokens-tab-settings-button-save" button
Then I should see "success" alert
And I should see the "otp-tokens-tab-settings-button-save" button is disabled

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should we check for these buttons? if yes, they are missing in the next test. I would suggest to remove the checks for the buttons

And OTP token "settings_token" exists for user "otpsettingsuser" with type "totp" and description "settings_token"

@test
Scenario: Refresh button is available

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Either remove this or put it with the test with other buttons

And OTP token "settings_token" exists for user "otpsettingsuser" with type "totp" and description "settings_token"

@test
Scenario: Kebab menu opens and contains actions

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

is it really testing if it contains actions?


When I click on the "modal-button-ok" button
Then I should not see "enable-disable-otp-tokens-modal" modal
And I should see "success" alert

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Im missing a check if its really enabled/disabled.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

same for the enable test below

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

Labels

needs-review This PR is waiting on a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants