-
Notifications
You must be signed in to change notification settings - Fork 367
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
upcoming: [M3-7775] - Disable ability to edit or delete a proxy user via User Profile page #10202
Merged
mjac0bs
merged 6 commits into
linode:develop
from
mjac0bs:M3-7775-disable-edits-to-proxy-user-profile-page
Feb 20, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
720786d
Disable fields and buttons on proxy user's user profile page
mjac0bs e3de1ae
Separate Display and User Profile test specs; add coverage
mjac0bs bef3568
Finish test coverage
mjac0bs 2d507a0
Clean up
mjac0bs 6ca7a00
Meant to push the changesets too
mjac0bs cd22592
Remove proxy user language
mjac0bs 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 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,5 @@ | ||
--- | ||
"@linode/manager": Tests | ||
--- | ||
|
||
Improve User Profile integration test coverage and separate from Display Settings coverage ([#10202](https://github.com/linode/manager/pull/10202)) |
5 changes: 5 additions & 0 deletions
5
packages/manager/.changeset/pr-10202-upcoming-features-1708119409383.md
This file contains 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,5 @@ | ||
--- | ||
"@linode/manager": Upcoming Features | ||
--- | ||
|
||
Disable ability to edit or delete a proxy user via User Profile page ([#10202](https://github.com/linode/manager/pull/10202)) |
This file contains 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
283 changes: 283 additions & 0 deletions
283
packages/manager/cypress/e2e/core/account/user-profile.spec.ts
This file contains 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,283 @@ | ||
import { accountUserFactory } from 'src/factories/accountUsers'; | ||
import { getProfile } from 'support/api/account'; | ||
import { | ||
interceptGetUser, | ||
mockGetUser, | ||
mockGetUsers, | ||
mockUpdateUsername, | ||
} from 'support/intercepts/account'; | ||
import { randomString } from 'support/util/random'; | ||
import { ui } from 'support/ui'; | ||
import { mockUpdateProfile } from 'support/intercepts/profile'; | ||
|
||
describe('User Profile', () => { | ||
/* | ||
* - Validates the flow of updating the username and email of the active account user via the User Profile page using mocked data. | ||
*/ | ||
it('can change email and username of the active account', () => { | ||
const newUsername = randomString(12); | ||
const newEmail = `${newUsername}@example.com`; | ||
|
||
getProfile().then((profile) => { | ||
const activeUsername = profile.body.username; | ||
const activeEmail = profile.body.email; | ||
|
||
interceptGetUser(activeUsername).as('getUser'); | ||
mockUpdateUsername(activeUsername, newUsername).as('updateUsername'); | ||
mockUpdateProfile({ | ||
...profile.body, | ||
email: newEmail, | ||
}).as('updateEmail'); | ||
|
||
cy.visitWithLogin(`account/users/${activeUsername}`); | ||
cy.wait('@getUser'); | ||
|
||
cy.findByText('Username').should('be.visible'); | ||
cy.findByText('Email').should('be.visible'); | ||
cy.findByText('Delete User').should('be.visible'); | ||
|
||
// Confirm the currently active user cannot be deleted. | ||
ui.button | ||
.findByTitle('Delete') | ||
.should('be.visible') | ||
.should('be.disabled') | ||
.trigger('mouseover'); | ||
// Click the button first, then confirm the tooltip is shown. | ||
ui.tooltip | ||
.findByText('You can\u{2019}t delete the currently active user.') | ||
.should('be.visible'); | ||
|
||
// Confirm user can update their email before updating the username, since you cannot update a different user's (as determined by username) email. | ||
cy.get('[id="email"]') | ||
.should('be.visible') | ||
.should('have.value', activeEmail) | ||
.clear() | ||
.type(newEmail); | ||
|
||
cy.get('[data-qa-textfield-label="Email"]') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Save') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
}); | ||
|
||
cy.wait('@updateEmail'); | ||
|
||
// Confirm success notice displays. | ||
cy.findByText('Email updated successfully').should('be.visible'); | ||
|
||
// Confirm user can update their username. | ||
cy.get('[id="username"]') | ||
.should('be.visible') | ||
.should('have.value', activeUsername) | ||
.clear() | ||
.type(newUsername); | ||
|
||
cy.get('[data-qa-textfield-label="Username"]') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Save') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
}); | ||
|
||
cy.wait('@updateUsername'); | ||
|
||
// No confirmation gets shown on this page when changes are saved. | ||
// Confirm that the text field has the correct value instead. | ||
cy.get('[id="username"]') | ||
.should('be.visible') | ||
.should('have.value', newUsername); | ||
}); | ||
}); | ||
|
||
/* | ||
* - Validates the flow of updating the username and email of another user via the User Profile page using mocked data. | ||
*/ | ||
it('can change the username but not email of another user account', () => { | ||
const newUsername = randomString(12); | ||
|
||
getProfile().then((profile) => { | ||
const additionalUsername = 'mock_user2'; | ||
const mockAccountUsers = accountUserFactory.buildList(1, { | ||
username: additionalUsername, | ||
}); | ||
const additionalUser = mockAccountUsers[0]; | ||
|
||
mockGetUsers(mockAccountUsers).as('getUsers'); | ||
mockGetUser(additionalUser).as('getUser'); | ||
mockUpdateUsername(additionalUsername, newUsername).as('updateUsername'); | ||
|
||
cy.visitWithLogin(`account/users/${additionalUsername}`); | ||
|
||
cy.wait('@getUser'); | ||
|
||
cy.findByText('Username').should('be.visible'); | ||
cy.findByText('Email').should('be.visible'); | ||
cy.findByText('Delete User').should('be.visible'); | ||
ui.button.findByTitle('Delete').should('be.visible').should('be.enabled'); | ||
|
||
// Confirm email of another user cannot be updated. | ||
cy.get('[id="email"]') | ||
.should('be.visible') | ||
.should('have.value', additionalUser.email) | ||
.should('be.disabled') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByAttribute('data-qa-help-button', 'true') | ||
.should('be.visible') | ||
.trigger('mouseover'); | ||
// Click the button first, then confirm the tooltip is shown. | ||
ui.tooltip | ||
.findByText( | ||
'You can\u{2019}t change another user\u{2019}s email address.' | ||
) | ||
.should('be.visible'); | ||
}); | ||
|
||
cy.get('[data-qa-textfield-label="Email"]') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Save') | ||
.should('be.visible') | ||
.should('be.disabled') | ||
.click(); | ||
}); | ||
|
||
// Confirm username of another user can be updated. | ||
cy.get('[id="username"]') | ||
.should('be.visible') | ||
.should('have.value', additionalUsername) | ||
.clear() | ||
.type(newUsername); | ||
|
||
cy.get('[data-qa-textfield-label="Username"]') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Save') | ||
.should('be.visible') | ||
.should('be.enabled') | ||
.click(); | ||
}); | ||
|
||
cy.wait('@updateUsername'); | ||
|
||
// No confirmation gets shown on this page when changes are saved. | ||
// Confirm that the text field has the correct value instead. | ||
cy.get('[id="username"]') | ||
.should('be.visible') | ||
.should('have.value', newUsername); | ||
}); | ||
}); | ||
|
||
/* | ||
* - Validates disabled username and email flow for a proxy user via the User Profile page using mocked data. | ||
*/ | ||
it('cannot change username or email for a proxy user or delete the proxy user', () => { | ||
getProfile().then((profile) => { | ||
const proxyUsername = 'proxy_user'; | ||
const mockAccountUsers = accountUserFactory.buildList(1, { | ||
username: proxyUsername, | ||
user_type: 'proxy', | ||
}); | ||
|
||
mockGetUsers(mockAccountUsers).as('getUsers'); | ||
mockGetUser(mockAccountUsers[0]).as('getUser'); | ||
|
||
cy.visitWithLogin(`account/users/${proxyUsername}`); | ||
|
||
cy.wait('@getUser'); | ||
|
||
cy.findByText('Username').should('be.visible'); | ||
cy.findByText('Email').should('be.visible'); | ||
cy.findByText('Delete User').should('be.visible'); | ||
|
||
cy.get('[id="username"]') | ||
.should('be.visible') | ||
.should('have.value', proxyUsername) | ||
.should('be.disabled') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByAttribute('data-qa-help-button', 'true') | ||
.should('be.visible') | ||
.trigger('mouseover'); | ||
// Click the button first, then confirm the tooltip is shown. | ||
ui.tooltip | ||
.findByText('This account type cannot update this field.') | ||
.should('be.visible'); | ||
}); | ||
|
||
cy.get('[data-qa-textfield-label="Username"]') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Save') | ||
.should('be.visible') | ||
.should('be.disabled'); | ||
}); | ||
|
||
cy.get('[id="email"]') | ||
.should('be.visible') | ||
.should('be.disabled') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByAttribute('data-qa-help-button', 'true') | ||
.should('be.visible') | ||
.trigger('mouseover'); | ||
// Click the button first, then confirm the tooltip is shown. | ||
ui.tooltip | ||
.findByText('This account type cannot update this field.') | ||
.should('be.visible'); | ||
}); | ||
|
||
cy.get('[data-qa-textfield-label="Email"]') | ||
.parent() | ||
.parent() | ||
.parent() | ||
.within(() => { | ||
ui.button | ||
.findByTitle('Save') | ||
.should('be.visible') | ||
.should('be.disabled') | ||
.click(); | ||
}); | ||
|
||
// Confirms the proxy user cannot be deleted. | ||
ui.button | ||
.findByTitle('Delete') | ||
.should('be.visible') | ||
.should('be.disabled') | ||
.trigger('mouseover'); | ||
// Click the button first, then confirm the tooltip is shown. | ||
ui.tooltip | ||
.findByText('You can\u{2019}t delete a business partner user.') | ||
.should('be.visible'); | ||
}); | ||
}); | ||
}); | ||
This file contains 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
Oops, something went wrong.
Oops, something went wrong.
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.
β€οΈ