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

test: [M3-8608] - Cypress test for restricted user Image non-empty landing page #11335

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

hasyed-akamai
Copy link
Contributor

@hasyed-akamai hasyed-akamai commented Nov 27, 2024

Description 📝

Added cypress test for restricted user Image non-Empty landing page

Changes 🔄

Added below cypress tests under in spec file - cypress/e2e/core/images/images-non-empty-landing-page.spec.ts

TC_ID TC_NAME Steps Expected Result
TC_1 Verify restricted user access on image non-empty landing page 1. Prerequites -  use mock to display Images.
2. Navigate to images page with restricted user - https://cloud.linode.com/images
1. List image table is present.
2. Validate that "Create Image" button is disabled.
3. Validate the tooltip warning message "You don't have permissions to create Images. Please contact your account administrator to request the necessary permissions."
4. Validate the action menu items are disabled for restricted user except "Deploy to New Linode"
  • checks restricted user has no access to create Image on Image non-Empty landing page
  • checks restricted user has no access to click on disabled action menu items.

How to test 🧪

yarn cy:run -s cypress/e2e/core/images/images-non-empty-landing-page.spec.ts

Verification steps

When test executed using this command yarn cy:run -s cypress/e2e/core/images/images-non-empty-landing-page.spec.ts all tests should pass successfully.

Tests

As an Author I have considered 🤔

Check all that apply

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@hasyed-akamai hasyed-akamai self-assigned this Nov 27, 2024
@hasyed-akamai hasyed-akamai added the e2e Indicates that a PR touches Cypress tests in some way label Nov 27, 2024
cy.wait('@getImages');
cy.url().should('endWith', '/images');

cy.contains('Custom Images')
Copy link
Contributor

Choose a reason for hiding this comment

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

To make the code more robust, search for "Custom Images" using the h3 tag and use .closest() to locate the parent div instead of relying on the div hierarchy. This approach avoids potential failures caused by changes in the div structure.

Suggested change

cy.contains('h3', 'Custom Images')
      .closest('div[data-qa-paper="true"]')
      .find('[role="table"]')
      .should('exist')
      .as('customImageTable');

.should('exist')
.as('customImageTable');

cy.contains('Recovery Images')
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

cy.contains('h3', 'Recovery Images')
      .closest('div[data-qa-paper="true"]')
      .find('[role="table"]')
      .should('exist')
      .as('recoveryImageTable');

.find('tbody tr')
.should('have.length', mockImages.length);

function checkActionMenu(tableAlias: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To enhance the readability of the test, I recommend moving this function outside the test block. This will help reduce nesting and make the test easier to follow.

Copy link
Contributor

@subsingh-akamai subsingh-akamai left a comment

Choose a reason for hiding this comment

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

Please update the test file name to "images-non-empty-landing-page.spec.ts"

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🎉 463 passing tests on test run #4 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
0 Failing463 Passing2 Skipped99m 41s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Indicates that a PR touches Cypress tests in some way
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants