keycloak-scim/cypress/support/pages/admin_console/manage/clients/InitialAccessTokenTab.ts

76 lines
1.8 KiB
TypeScript
Raw Normal View History

2021-03-05 13:47:59 +00:00
export default class InitialAccessTokenTab {
private initialAccessTokenTab = "initialAccessToken";
private emptyAction = "no-initial-access-tokens-empty-action";
2021-03-05 13:47:59 +00:00
2022-03-28 13:14:56 +00:00
private expirationNumberInput = "expiration";
private expirationInput = 'input[name="count"]';
private expirationText = "#expiration-helper";
2021-03-05 13:47:59 +00:00
private countInput = "count";
private countPlusBtn = '[data-testid="count"] [aria-label="Plus"]';
2021-03-05 13:47:59 +00:00
private saveBtn = "save";
goToInitialAccessTokenTab() {
cy.findByTestId(this.initialAccessTokenTab).click();
return this;
}
2021-03-05 13:47:59 +00:00
shouldBeEmpty() {
cy.findByTestId(this.emptyAction).should("exist");
2021-03-05 13:47:59 +00:00
return this;
}
shouldNotBeEmpty() {
cy.findByTestId(this.emptyAction).should("not.exist");
2021-03-05 13:47:59 +00:00
return this;
}
getFirstId(callback: (id: string) => void) {
cy.get('tbody > tr:first-child > [data-label="ID"]')
2021-03-05 13:47:59 +00:00
.invoke("text")
.then((text) => {
callback(text);
});
return this;
}
goToCreateFromEmptyList() {
cy.findByTestId(this.emptyAction).click();
return this;
}
fillNewTokenData(expiration: number, count: number) {
2022-03-28 13:14:56 +00:00
cy.findByTestId(this.expirationNumberInput).clear().type(`${expiration}`);
cy.findByTestId(this.countInput).clear();
for (let i = 0; i < count; i++) {
cy.get(this.countPlusBtn).click();
}
2021-03-05 13:47:59 +00:00
return this;
}
save() {
cy.findByTestId(this.saveBtn).click();
2021-03-05 13:47:59 +00:00
return this;
}
2022-03-28 13:14:56 +00:00
checkExpirationGreaterThanZeroError() {
cy.get(this.expirationText).should(
"have.text",
"Value should should be greater or equal to 1"
);
return this;
}
checkCountValue(value: number) {
cy.get(this.expirationInput).should("have.value", value);
return this;
}
checkSaveButtonIsDisabled() {
cy.findByTestId(this.saveBtn).should("be.disabled");
return this;
}
2021-03-05 13:47:59 +00:00
}