-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
175 additions
and
5 deletions.
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,28 @@ | ||
import { GroupsConfig } from '~/pages/groupSettings/groupTypes'; | ||
|
||
export const mockGroupSettings = (): GroupsConfig => ({ | ||
adminGroups: [ | ||
{ | ||
id: 0, | ||
name: 'odh-admins', | ||
enabled: true, | ||
}, | ||
{ | ||
id: 1, | ||
name: 'odh-admins-1', | ||
enabled: false, | ||
}, | ||
], | ||
allowedGroups: [ | ||
{ | ||
id: 0, | ||
name: 'odh-admins', | ||
enabled: false, | ||
}, | ||
{ | ||
id: 1, | ||
name: 'system:authenticated', | ||
enabled: false, | ||
}, | ||
], | ||
}); |
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
51 changes: 51 additions & 0 deletions
51
frontend/src/__tests__/cypress/cypress/e2e/userManagement/userManagement.cy.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,51 @@ | ||
import { mockGroupSettings } from '~/__mocks__/mockGroupConfig'; | ||
import { userManagement } from '~/__tests__/cypress/cypress/pages/userManagement'; | ||
|
||
describe('User Management', () => { | ||
beforeEach(() => { | ||
cy.interceptOdh('GET /api/groups-config', mockGroupSettings()); | ||
cy.interceptOdh('PUT /api/groups-config', mockGroupSettings()).as('saveGroupSetting'); | ||
userManagement.visit(); | ||
}); | ||
|
||
it('Administrator group setting', () => { | ||
const administratorGroupSection = userManagement.getAdministratorGroupSection(); | ||
administratorGroupSection.shouldHaveAdministratorGroupInfo(); | ||
administratorGroupSection.clearMultiChipItem(); | ||
administratorGroupSection.selectMultiGroup('odh-admins'); | ||
administratorGroupSection.findMultiSelectGroupInput().type('odh-admin'); | ||
administratorGroupSection.findMultiGroupOptions('odh-admins-1').click(); | ||
administratorGroupSection.findChipItem().should('contain', 'odh-admins'); | ||
administratorGroupSection.removeChipItem('odh-admins'); | ||
administratorGroupSection.findChipItem().should('not.contain', /^odh-admins$/); | ||
administratorGroupSection.removeChipItem('odh-admins-1'); | ||
administratorGroupSection.findErrorText().should('exist'); | ||
administratorGroupSection.findMultiGroupOptions('odh-admins').click(); | ||
administratorGroupSection.findErrorText().should('not.exist'); | ||
userManagement.findSubmitButton().should('be.disabled'); | ||
}); | ||
|
||
it('User group setting', () => { | ||
const userGroupSection = userManagement.getUserGroupSection(); | ||
userManagement.findSubmitButton().should('be.disabled'); | ||
userGroupSection.findErrorText().should('exist'); | ||
userGroupSection.selectMultiGroup('odh-admins'); | ||
userGroupSection.findMultiGroupOptions('system:authenticated').click(); | ||
userGroupSection.findChipItem().should('contain', 'odh-admins'); | ||
userGroupSection.removeChipItem('odh-admins'); | ||
userManagement.findSubmitButton().should('be.enabled'); | ||
userManagement.findSubmitButton().click(); | ||
cy.wait('@saveGroupSetting').then((interception) => { | ||
expect(interception.request.body).to.eql({ | ||
adminGroups: [ | ||
{ id: 0, name: 'odh-admins', enabled: true }, | ||
{ id: 1, name: 'odh-admins-1', enabled: false }, | ||
], | ||
allowedGroups: [ | ||
{ id: 0, name: 'odh-admins', enabled: false }, | ||
{ id: 1, name: 'system:authenticated', enabled: true }, | ||
], | ||
}); | ||
}); | ||
}); | ||
}); |
68 changes: 68 additions & 0 deletions
68
frontend/src/__tests__/cypress/cypress/pages/userManagement.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,68 @@ | ||
import { Contextual } from './components/Contextual'; | ||
|
||
class GroupSettingSection extends Contextual<HTMLElement> { | ||
shouldHaveAdministratorGroupInfo() { | ||
this.find().findByTestId('data-science-administrator-info'); | ||
return this; | ||
} | ||
|
||
clearMultiChipItem() { | ||
this.find().findByRole('button', { name: 'Clear all' }).click(); | ||
} | ||
|
||
findMultiSelectGroupInput() { | ||
return this.find().find('input'); | ||
} | ||
|
||
findMultiGroupOptions(name: string) { | ||
return this.find().findByTestId('multi-group-selection').findByRole('option', { name }); | ||
} | ||
|
||
private findChipGroup() { | ||
return this.find().findByRole('list', { name: 'Chip group category' }); | ||
} | ||
|
||
findChipItem() { | ||
return this.findChipGroup().find('li'); | ||
} | ||
|
||
removeChipItem(name: string) { | ||
this.findChipGroup() | ||
.findByRole('button', { name: `Remove ${name}` }) | ||
.click(); | ||
} | ||
|
||
findErrorText() { | ||
return this.find().findByTestId('group-selection-error-text'); | ||
} | ||
|
||
selectMultiGroup(name: string) { | ||
this.find().findByRole('button', { name: 'Options menu' }).click(); | ||
this.findMultiGroupOptions(name).click(); | ||
} | ||
} | ||
class UserManagement { | ||
visit() { | ||
cy.visit('/groupSettings'); | ||
this.wait(); | ||
} | ||
|
||
private wait() { | ||
cy.findByTestId('app-page-title').should('have.text', 'User management'); | ||
cy.testA11y(); | ||
} | ||
|
||
findSubmitButton() { | ||
return cy.findByTestId('save-button'); | ||
} | ||
|
||
getAdministratorGroupSection() { | ||
return new GroupSettingSection(() => cy.findByTestId('data-science-administrator-groups')); | ||
} | ||
|
||
getUserGroupSection() { | ||
return new GroupSettingSection(() => cy.findByTestId('data-science-user-groups')); | ||
} | ||
} | ||
|
||
export const userManagement = new UserManagement(); |
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
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
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
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