0bbd4ddad1
* Initial version of the create and edit resouce screen * refactored and fixed the attributes form introduced a new component that can be used more easily * Update src/components/json-file-upload/FileUploadForm.tsx Co-authored-by: Jon Koops <jonkoops@gmail.com> * Update src/components/attribute-form/attribute-convert.ts Co-authored-by: Jon Koops <jonkoops@gmail.com> * Update src/clients/authorization/ResourceDetails.tsx Co-authored-by: Jon Koops <jonkoops@gmail.com> * Update src/clients/authorization/ResourceDetails.tsx Co-authored-by: Jon Koops <jonkoops@gmail.com> * Update src/clients/authorization/ResourceDetails.tsx Co-authored-by: Jon Koops <jonkoops@gmail.com> * PR review * fixed tests * PR review comments * resourceId is optional * Update src/components/attribute-form/attribute-convert.ts Co-authored-by: Jon Koops <jonkoops@gmail.com> Co-authored-by: Jon Koops <jonkoops@gmail.com>
66 lines
1.6 KiB
TypeScript
66 lines
1.6 KiB
TypeScript
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";
|
|
|
|
goToTab() {
|
|
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;
|
|
}
|
|
|
|
save() {
|
|
cy.findByTestId("save").click();
|
|
return this;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|