Skip to content

Update the Compliance Center tests

Mark Lapierre requested to merge ml-update-compliance-center-test into master

What does this MR do and why?

Update the Compliance Center E2E tests

  • Rename test methods from 'report' to 'center'.
  • Update QA selectors to test-ids.
  • Rename UI test-ids on tabs to '*-tab-content' because the ids are on the element that represents the content, not the tab that users can click. This leaves '*-tab' test-ids for the clickable tab control, which can be used as QA selectors.
  • Adds a method to switch to the violations tab if it's not already active. This allows the test to work when the tab is already selected, as it is when the adherence_report_ui feature flag is disabled, and when the tab is not selected, as when the adherence_report_ui feature flag is enabled.

Fixes #428979 (closed) and #428888 (closed)

How to set up and validate locally

From the qa directory:

bundle install
export WEBDRIVER_HEADLESS=false # If you'd like to watch the test in action
export QA_GITLAB_URL="http://gdk.test:3000" # Only needed if GDK is not running on http://127.0.0.1:3000

# Disable the `adherence_report_ui` feature flag
(cd ..; bundle exec rails runner "puts Feature.disable(:adherence_report_ui)")
# => true

# Run the tests while the feature flag is disabled
bundle exec rspec qa/specs/features/ee/browser_ui/10_govern/group/group_compliance_dashboard_spec.rb
...

# Enable the `adherence_report_ui` feature flag
(cd ..; bundle exec rails runner "puts Feature.enable(:adherence_report_ui)")
# => true

# Run the tests again while the feature flag is enabled
bundle exec rspec qa/specs/features/ee/browser_ui/10_govern/group/group_compliance_dashboard_spec.rb
...

# Confirm that the other compliance test passes (it uses some of the updated selectors)
bundle exec rspec qa/specs/features/ee/browser_ui/10_govern/group/compliance_framework_report_spec.rb

Test results

Local run of qa/specs/features/ee/browser_ui/10_govern/group/group_compliance_dashboard_spec.rb with adherence_report_ui disabled passed. Logs included:

[Oct 23 2023 15:07:15 AEDT (QA Tests)] WARN  -- Potentially Slow Code 'has_element? violations-tab' took 0.837s

Ignoring that it's potentially slow, the lack of a click_element entry subsequently confirms that it behaved as expected - it was already on the violations tab.

I got similar results with the feature flag enabled, but this time the logs showed that it did click the violations tab:

[Oct 23 2023 15:18:34 AEDT (QA Tests)] WARN  -- Potentially Slow Code 'has_element? violations-tab' took 1.111s
[Oct 23 2023 15:18:34 AEDT (QA Tests)] INFO  -- clicking :violations-tab

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Mark Lapierre

Merge request reports