-
Notifications
You must be signed in to change notification settings - Fork 366
[WIP] Fix custom buttons using role names that can change #9709
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
Open
jrafanie
wants to merge
4
commits into
ManageIQ:master
Choose a base branch
from
jrafanie:fix-custom-buttons-using-role-names-that-can-change
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
cypress/e2e/ui/Automation/Embedded-Automate/customization_buttons.cy.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| /* eslint-disable no-undef */ | ||
| import { flashClassMap } from '../../../../support/assertions/assertion_constants'; | ||
|
|
||
| describe('Automation > Embedded Automate > Customization > Buttons', () => { | ||
| beforeEach(() => { | ||
| cy.login(); | ||
| cy.menu('Automation', 'Embedded Automate', 'Customization'); | ||
| cy.get('#explorer_title_text'); | ||
|
|
||
| // Navigate to Buttons accordion | ||
| cy.accordion('Buttons'); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| cy.appDbState('restore'); | ||
| }); | ||
|
|
||
| describe('Button Creation', () => { | ||
| it('Creates a new button for Availability Zone', () => { | ||
| // Navigate through the accordion: Object Types > Availability Zone > [Unassigned Buttons] | ||
| cy.selectAccordionItem(['Object Types', 'Availability Zone', '[Unassigned Buttons]']); | ||
|
|
||
| // Use toolbar command to add a new button | ||
| cy.toolbar('Configuration', 'Add a new Button'); | ||
|
|
||
| // Verify we're on the add button page | ||
| cy.get('#explorer_title_text').contains('Adding a new Button'); | ||
|
|
||
| // Fill in name and description with hardcoded values | ||
| cy.get('#name').type('Test Availability Zone Button'); | ||
| cy.get('#description').type('Test button for availability zone'); | ||
|
|
||
| // Select an icon from the dropdown | ||
| cy.get('.icon-button').click(); | ||
| cy.get(':nth-child(1) > span > .ff').click(); | ||
| cy.get('.bx--modal-footer > .bx--btn--primary').click(); | ||
|
|
||
| // Click the Advanced tab | ||
| cy.tabs({ tabLabel: 'Advanced' }); | ||
|
|
||
| // Scroll to object details part of the form and fill in the request field | ||
| cy.get('#object_request').scrollIntoView(); | ||
| cy.get('#object_request').type('test_request'); | ||
|
|
||
| // Scroll to role access section and select "<By Role>" from dropdown | ||
| cy.get('#form_role_visibility button[data-id="visibility_typ"]').scrollIntoView(); | ||
| cy.get('#form_role_visibility button[data-id="visibility_typ"]').click(); | ||
| cy.get('#form_role_visibility .dropdown-menu [data-original-index="1"] > a').click(); | ||
|
|
||
| // Scroll to User Roles section to make roles visible | ||
| cy.contains('User Roles').scrollIntoView(); | ||
|
|
||
| // Check EvmRole-auditor and EvmRole-desktop | ||
| cy.interceptApi({ | ||
| alias: 'checkAuditorRole', | ||
| urlPattern: '/miq_ae_customization/automate_button_field_changed', | ||
| triggerFn: () => cy.get('#form_role_visibility').contains('EvmRole-auditor').closest('td').find('input[type="checkbox"]').check(), | ||
| waitOnlyIfRequestIntercepted: true, | ||
| }); | ||
|
|
||
| cy.interceptApi({ | ||
| alias: 'checkDesktopRole', | ||
| urlPattern: '/miq_ae_customization/automate_button_field_changed', | ||
| triggerFn: () => cy.get('#form_role_visibility').contains('EvmRole-desktop').closest('td').find('input[type="checkbox"]').check(), | ||
| waitOnlyIfRequestIntercepted: true, | ||
| }); | ||
|
|
||
| // Click Add button | ||
| // TODO: cy.getFormButtonByTypeWithText expects this in the main_content div, but it's in the form_buttons_div | ||
| // within the full_content div - enhance the cy.getFormButtonByTypeWithText to accept a div id or normalize the location of the button | ||
| cy.get('#buttons_on > .btn-primary').click(); | ||
|
|
||
| // Verify flash message that button was added | ||
| cy.expect_flash(flashClassMap.success, 'was added'); | ||
|
|
||
| // Verify the button was added successfully by clicking it in the accordion | ||
| cy.get('.clickable-row').contains('Test Availability Zone Button').click(); | ||
|
|
||
| // Verify the name, description, request, and roles are displayed correctly in the main div | ||
| cy.get('#main_div').contains('Test Availability Zone Button'); | ||
| cy.get('#main_div').contains('Test button for availability zone'); | ||
| cy.get('#main_div').contains('test_request'); | ||
| cy.get('.visibility').contains('EvmRole-auditor'); | ||
| cy.get('.visibility').contains('EvmRole-desktop'); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -325,7 +325,7 @@ | |
| :object_request => 'request', | ||
| :open_url => true, | ||
| :visibility_typ => 'role', | ||
| :roles => [role.id.to_s], | ||
| :roles => [role.id], | ||
| :display_for => :list} | ||
| } | ||
| } | ||
|
|
@@ -340,13 +340,13 @@ | |
|
|
||
| it "sets new role visibility for custom button" do | ||
| controller.send(:button_set_record_vars, custom_button) | ||
| expect(custom_button.visibility[:roles]).to eq([role.name]) | ||
| expect(custom_button.visibility[:roles]).to eq([role.id]) | ||
| end | ||
|
|
||
| it "sets new role and preserves old role for custom button" do | ||
| edit[:new][:roles] = [old_role.id, role.id.to_s] # old roles are represented by int and new ones by string | ||
| controller.send(:button_set_record_vars, custom_button) | ||
| expect(custom_button.visibility[:roles]).to eq([old_role.name, role.name]) | ||
| expect(custom_button.visibility[:roles]).to eq([old_role.id, role.id.to_s]) | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: that comment on line 347 is nuts. I need to figure out if roles as strings and ints is an actual thing. |
||
| end | ||
| end | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: keep the lookup but drop the loop...