-
Notifications
You must be signed in to change notification settings - Fork 31
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
1 parent
2436425
commit b344e51
Showing
16 changed files
with
466 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import CruResourcePo from '@/utils/components/cru-resource.po'; | ||
import { MANAGEMENT } from '@/constants/types' | ||
import LabeledSelectPo from '@/utils/components/labeled-select.po'; | ||
import RadioButtonPo from '@/utils/components/radio-button.po'; | ||
|
||
export default class UserPo extends CruResourcePo { | ||
constructor() { | ||
super({ | ||
type: MANAGEMENT.CLUSTER_ROLE_TEMPLATE_BINDING | ||
}); | ||
} | ||
|
||
public selectMember() { | ||
return new LabeledSelectPo('.labeled-select.hoverable', `:contains("Select Member")`) | ||
} | ||
|
||
public clusterPermissions() { | ||
return new RadioButtonPo('.radio-group') | ||
} | ||
|
||
public setValue(value: any) { | ||
this.selectMember().search(value?.selectMember) | ||
this.selectMember().select({ option: value?.selectMember }) | ||
|
||
this.clusterPermissions().input(value?.clusterPermissions) | ||
} | ||
|
||
public create(value: any, urlWithNamespace?: boolean) { | ||
cy.visit(`/harvester/c/${Cypress.config('clusterId')}/${this.type}/create`) | ||
|
||
this.setValue(value) | ||
|
||
this.save() | ||
} | ||
|
||
public save({ | ||
buttonText = 'save', | ||
edit, | ||
} : { | ||
buttonText?:string, | ||
edit?: boolean; | ||
} = {}) { | ||
cy.intercept('POST', `/v3/clusterroletemplatebindings`).as('createClusterMember'); | ||
|
||
this.clickFooterBtn(buttonText) | ||
cy.wait('@createClusterMember').then(res => { | ||
expect(res.response?.statusCode, `Create ${this.type} success`).to.equal(201); | ||
}) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import CruResourcePo from '@/utils/components/cru-resource.po'; | ||
import { MANAGEMENT } from '@/constants/types' | ||
import LabeledSelectPo from '@/utils/components/labeled-select.po'; | ||
import RadioButtonPo from '@/utils/components/radio-button.po'; | ||
|
||
export default class ProjectPo extends CruResourcePo { | ||
constructor() { | ||
super({ | ||
type: MANAGEMENT.PROJECT | ||
}); | ||
} | ||
|
||
public setValue(value: any) { | ||
this.name().input(value?.name) | ||
} | ||
|
||
public create(value: any, urlWithNamespace?: boolean) { | ||
cy.visit(`/harvester/c/${Cypress.config('clusterId')}/${this.type}/create`) | ||
|
||
this.setValue(value) | ||
this.addMember(value?.members) | ||
|
||
this.save() | ||
} | ||
|
||
public selectMember() { | ||
return new LabeledSelectPo('.labeled-select.hoverable', `:contains("Select Member")`) | ||
} | ||
|
||
public clusterPermissions() { | ||
return new RadioButtonPo('.radio-group') | ||
} | ||
|
||
public addMember(members: object[] = []) { | ||
members.map(member => { | ||
cy.contains('Add').click() | ||
|
||
this.selectMember().search(member.name) | ||
this.selectMember().select({ option: member.name }) | ||
|
||
this.clusterPermissions().input(member?.permissions) | ||
|
||
cy.get('[data-testid="card-actions-slot"]').contains('Add').click() | ||
}) | ||
} | ||
|
||
public save({ | ||
buttonText = 'save', | ||
edit, | ||
} : { | ||
buttonText?:string, | ||
edit?: boolean; | ||
} = {}) { | ||
cy.intercept('POST', `/v3/projects`).as('createProject'); | ||
|
||
this.clickFooterBtn(buttonText) | ||
cy.wait('@createProject').then(res => { | ||
expect(res.response?.statusCode, `Create ${this.type} success`).to.equal(201); | ||
}) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import CruResourcePo from '@/utils/components/cru-resource.po'; | ||
import { MANAGEMENT } from '@/constants/types' | ||
import LabeledInputPo from '@/utils/components/labeled-input.po'; | ||
import CheckboxPo from '@/utils/components/checkbox.po'; | ||
|
||
export default class UserPo extends CruResourcePo { | ||
constructor() { | ||
super({ | ||
type: MANAGEMENT.USER | ||
}); | ||
} | ||
|
||
public username() { | ||
return new LabeledInputPo('.labeled-input', `:contains("Username")`) | ||
} | ||
|
||
public newPassword() { | ||
return new LabeledInputPo('.labeled-input', `:contains("New Password")`) | ||
} | ||
|
||
public confirmPassword() { | ||
return new LabeledInputPo('.labeled-input', `:contains("Confirm Password")`) | ||
} | ||
|
||
public globalPermissions(string) { | ||
return cy.find('.card-body').contains(string).click() | ||
} | ||
|
||
administrator() { | ||
return new CheckboxPo(':nth-child(1) > [data-testid="card"] > .card-wrap > [data-testid="card-body-slot"] > .checkbox-section > :nth-child(1) > .checkbox-outer-container > .checkbox-container', `:contains("Administrator")`) | ||
} | ||
|
||
public setValue(value: any) { | ||
this.username().input(value?.username) | ||
this.newPassword().input(value?.newPassword) | ||
this.confirmPassword().input(value?.confirmPassword) | ||
|
||
// TODO: Can not get the value of globalPermissions | ||
if (value?.administrator) { | ||
this.administrator().click() | ||
} | ||
} | ||
|
||
public create(value: any, urlWithNamespace?: boolean) { | ||
cy.visit(`/c/local/auth/${this.type}/create`) | ||
|
||
this.setValue(value) | ||
|
||
this.save() | ||
} | ||
|
||
public save({ | ||
buttonText = 'save', | ||
edit, | ||
} : { | ||
buttonText?:string, | ||
edit?: boolean; | ||
} = {}) { | ||
cy.intercept('POST', `/v3/users`).as('create'); | ||
|
||
this.clickFooterBtn(buttonText) | ||
cy.wait('@create').then(res => { | ||
expect(res.response?.statusCode, `Create ${this.type} success`).to.equal(201); | ||
}) | ||
} | ||
} |
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
Oops, something went wrong.