2021-12-01 07:58:25 +00:00
|
|
|
import type ResourceRepresentation from "@keycloak/keycloak-admin-client/lib/defs/resourceRepresentation";
|
|
|
|
|
|
|
|
export default class AuthenticationTab {
|
|
|
|
private tabName = "#pf-tab-authorization-authorization";
|
|
|
|
private resourcesTabName = "#pf-tab-41-resources";
|
|
|
|
private nameColumnPrefix = "name-column-";
|
|
|
|
private createResourceButton = "createResource";
|
|
|
|
|
2022-01-08 09:27:57 +00:00
|
|
|
goToAuthenticationTab() {
|
2021-12-01 07:58:25 +00:00
|
|
|
cy.get(this.tabName).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
goToResourceSubTab() {
|
|
|
|
cy.get(this.resourcesTabName).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
goToCreateResource() {
|
|
|
|
cy.findAllByTestId(this.createResourceButton).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
fillResourceForm(resource: ResourceRepresentation) {
|
|
|
|
Object.entries(resource).map(([key, value]) => {
|
|
|
|
if (Array.isArray(value)) {
|
|
|
|
for (let index = 0; index < value.length; index++) {
|
|
|
|
const v = value[index];
|
|
|
|
cy.get(`input[name="${key}[${index}].value"]`).type(v);
|
|
|
|
cy.findByTestId("addValue").click();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
cy.get(`#${key}`).type(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-12-16 16:31:17 +00:00
|
|
|
setPolicy(policyName: string) {
|
|
|
|
cy.findByTestId(policyName).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-12-01 07:58:25 +00:00
|
|
|
save() {
|
|
|
|
cy.findByTestId("save").click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-12-16 16:31:17 +00:00
|
|
|
saveSettings() {
|
|
|
|
cy.findByTestId("authenticationSettingsSave").click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2021-12-01 07:58:25 +00:00
|
|
|
pressCancel() {
|
|
|
|
cy.findAllByTestId("cancel").click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
private getResourceLink(name: string) {
|
|
|
|
return cy.findByTestId(this.nameColumnPrefix + name);
|
|
|
|
}
|
|
|
|
|
|
|
|
goToResourceDetails(name: string) {
|
|
|
|
this.getResourceLink(name).click();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
assertDefaultResource() {
|
|
|
|
return this.assertResource("Default Resource");
|
|
|
|
}
|
|
|
|
|
|
|
|
assertResource(name: string) {
|
|
|
|
this.getResourceLink(name).should("exist");
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|