Skip to content

adding visual tests coverage on cloud credential #16322

Merged
a-arias merged 1 commit intorancher:masterfrom
a-arias:visualtesting1824-25b
Jan 15, 2026
Merged

adding visual tests coverage on cloud credential #16322
a-arias merged 1 commit intorancher:masterfrom
a-arias:visualtesting1824-25b

Conversation

@a-arias
Copy link
Copy Markdown
Contributor

@a-arias a-arias commented Jan 6, 2026

Summary

Fixes #1825
Fixes rancher/qa-tasks#1825

Occurred changes and/or fixed issues

Technical notes summary

Areas or cases that should be tested

Areas which could experience regressions

Screenshot/Video

Checklist

  • The PR is linked to an issue and the linked issue has a Milestone, or no issue is needed
  • The PR has a Milestone
  • The PR template has been filled out
  • The PR has been self reviewed
  • The PR has a reviewer assigned
  • The PR has automated tests or clear instructions for manual tests and the linked issue has appropriate QA labels, or tests are not needed
  • The PR has reviewed with UX and tested in light and dark mode, or there are no UX changes
  • The PR has been reviewed in terms of Accessibility
  • The PR has considered, and if applicable tested with, the three Global Roles Admin, Standard User and User Base

@izaac
Copy link
Copy Markdown
Contributor

izaac commented Jan 7, 2026

These should be atomic, both the setUserPreference and percySnapshot. In its own it block.

Copy link
Copy Markdown
Contributor

@izaac izaac left a comment

Choose a reason for hiding this comment

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

Read previous comment.

@izaac
Copy link
Copy Markdown
Contributor

izaac commented Jan 7, 2026

Another possibility would be adding a helper method to the cloud credential page object and call that. takePercySnapshot(name: string). To handle all those hideElementBySelector inline calls. Thoughts? @a-arias @yonasberhe23

@a-arias a-arias modified the milestones: v2.5.4, v2.14.0 Jan 7, 2026
@yonasberhe23
Copy link
Copy Markdown
Contributor

These should be atomic, both the setUserPreference and percySnapshot. In its own it block.

@a-arias

I agree with @izaac. setUserPreference and percySnapshot should be atomic, each in its own it block.

I think we need to be more consistent with these Percy tests. In some cases, the Percy tests are embedded within other tests, and others have their own describe/it block. In my opinion, each visual test should be in its own it block within a dedicated describe block (e.g., describe('Visual Testing', ...)).
If a visual test requires setUserPreference, that setup should be in the same isolated it block, not shared with functional tests.
This keeps visual tests isolated, prevents interference with functional tests, and makes failures easier to diagnose.

Good pattern (isolated):
machine-sets.spec.ts - separate describe('Visual Testing', ...) block
machine-deployments.spec.ts - separate describe('Visual testing MachineDeployments', ...) block
home.spec.ts - separate it('Validate home page with percy', ...) block

Not so good pattern (embedded in other tests):
login.spec.ts - percySnapshot inside it('Log in with valid credentials', ...)
gitrepo.spec.ts - multiple percySnapshot calls inside it('Can create a GitRepo', ...)

@yonasberhe23
Copy link
Copy Markdown
Contributor

Another possibility would be adding a helper method to the cloud credential page object and call that. takePercySnapshot(name: string). To handle all those hideElementBySelector inline calls. Thoughts? @a-arias @yonasberhe23

@izaac i like this idea but I think a custom command would be better than a page object method because it would be easier to maintain and update across all visual tests

@izaac
Copy link
Copy Markdown
Contributor

izaac commented Jan 8, 2026

I'm inclined to less maintenance too.

@a-arias a-arias changed the title adding visual tests coverage on cloud credential and cluster manager adding visual tests coverage on cloud credential Jan 9, 2026
@rancher-ui-project-bot rancher-ui-project-bot bot modified the milestones: v2.14.0, v2.5.4 Jan 9, 2026
@a-arias a-arias modified the milestones: v2.5.4, v2.14.0 Jan 9, 2026
@a-arias a-arias force-pushed the visualtesting1824-25b branch 3 times, most recently from e913cf5 to b468cf6 Compare January 9, 2026 00:51
@a-arias
Copy link
Copy Markdown
Contributor Author

a-arias commented Jan 9, 2026

@yonasberhe23 @izaac I added the own describe blocks for the percy visual test for cloud credentials, please review again

Comment on lines +368 to +374
cy.hideElementBySelector('[data-testid="nav_header_showUserMenu"]');
// Ignoring the side navbar counters
cy.hideElementBySelector("[data-testid='type-count']");
// Ignoring the side cluster menu
cy.hideElementBySelector("[ data-testid='top-level-menu-cluster-1']");
// takes percy snapshot.
cy.percySnapshot('empty cloud credential creation page');
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.

@a-arias could you follow up on what's proposed in this comment? #16322 (comment)

Encapsulating this in a custom command would be preferable than inline invocation.

Comment on lines +331 to +349
before(() => {
cy.login();
// Clean up any orphaned Amazon cloud credentials from previous test runs to ensure tests start with a clean state
cy.getRancherResource('v3', 'cloudcredentials', null, null).then((resp: Cypress.Response<any>) => {
const body = resp.body;

if (body.pagination['total'] > 0) {
body.data.forEach((item: any) => {
if (item.amazonec2credentialConfig) {
const id = item.id;

cy.deleteRancherResource('v3', 'cloudcredentials', id, false);
} else {
cy.log('There are no existing amazon cloud credentials to delete');
}
});
}
});
});
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 we need this here

Comment on lines +377 to +385
after(() => {
for (let i = 0; i < doCreatedCloudCredsIds.length; i++) {
cy.deleteRancherResource('v3', `cloudcredentials`, doCreatedCloudCredsIds[i]);
}

for (let i = 0; i < azCreatedCloudCredsIds.length; i++) {
cy.deleteRancherResource('v3', `cloudcredentials`, azCreatedCloudCredsIds[i]);
}
});
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 we need this here

@a-arias a-arias closed this Jan 14, 2026
@a-arias a-arias reopened this Jan 14, 2026
@rancher-ui-project-bot rancher-ui-project-bot bot modified the milestones: v2.14.0, v2.5.4 Jan 14, 2026
@a-arias a-arias modified the milestones: v2.5.4, v2.14.0 Jan 14, 2026
@a-arias a-arias requested a review from izaac January 14, 2026 21:00
@a-arias a-arias requested a review from yonasberhe23 January 14, 2026 21:00
@a-arias a-arias force-pushed the visualtesting1824-25b branch from 09bc0cd to ce5ada5 Compare January 14, 2026 23:15
});
Cypress.Commands.add('hideElementBySelector', (selector:string) => {
cy.get(selector).invoke('css', 'opacity', '0');
Cypress.Commands.add('hideElementBySelector', (...selectors: string[]) => {
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.

Nice!

Copy link
Copy Markdown
Contributor

@yonasberhe23 yonasberhe23 left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@izaac izaac left a comment

Choose a reason for hiding this comment

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

:shipit:

@a-arias a-arias merged commit 1e456e8 into rancher:master Jan 15, 2026
34 checks passed
@a-arias a-arias deleted the visualtesting1824-25b branch January 15, 2026 00:08
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.

Ingress Details Polishing [Visual Testing] Cloud credentials

3 participants