Enable client consent text when client consent is enabled (#3145)
This commit is contained in:
parent
4f25c71eed
commit
b9e2ba2a2f
4 changed files with 36 additions and 8 deletions
|
@ -285,6 +285,25 @@ describe("Client Scopes test", () => {
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("hides 'consent text' field when 'display consent' switch is disabled", () => {
|
||||||
|
sidebarPage.waitForPageLoad();
|
||||||
|
listingPage.goToCreateItem();
|
||||||
|
|
||||||
|
createClientScopePage
|
||||||
|
.getSwitchDisplayOnConsentScreenInput()
|
||||||
|
.should("be.checked");
|
||||||
|
|
||||||
|
createClientScopePage.getConsentScreenTextInput().should("exist");
|
||||||
|
|
||||||
|
createClientScopePage.switchDisplayOnConsentScreen();
|
||||||
|
|
||||||
|
createClientScopePage
|
||||||
|
.getSwitchDisplayOnConsentScreenInput()
|
||||||
|
.should("not.be.checked");
|
||||||
|
|
||||||
|
createClientScopePage.getConsentScreenTextInput().should("not.exist");
|
||||||
|
});
|
||||||
|
|
||||||
it("Client scope CRUD test", () => {
|
it("Client scope CRUD test", () => {
|
||||||
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
itemId += "_" + (Math.random() + 1).toString(36).substring(7);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ export default class CreateClientScopePage extends CommonPage {
|
||||||
clientScopeDescriptionInput: string;
|
clientScopeDescriptionInput: string;
|
||||||
clientScopeTypeDrpDwn: string;
|
clientScopeTypeDrpDwn: string;
|
||||||
clientScopeTypeList: string;
|
clientScopeTypeList: string;
|
||||||
|
displayOnConsentInput: string;
|
||||||
displayOnConsentSwitch: string;
|
displayOnConsentSwitch: string;
|
||||||
consentScreenTextInput: string;
|
consentScreenTextInput: string;
|
||||||
includeInTokenSwitch: string;
|
includeInTokenSwitch: string;
|
||||||
|
@ -25,8 +26,9 @@ export default class CreateClientScopePage extends CommonPage {
|
||||||
this.clientScopeDescriptionInput = "#kc-description";
|
this.clientScopeDescriptionInput = "#kc-description";
|
||||||
this.clientScopeTypeDrpDwn = "#kc-protocol";
|
this.clientScopeTypeDrpDwn = "#kc-protocol";
|
||||||
this.clientScopeTypeList = "#kc-protocol + ul";
|
this.clientScopeTypeList = "#kc-protocol + ul";
|
||||||
|
this.displayOnConsentInput = '[id="kc-display.on.consent.screen-switch"]';
|
||||||
this.displayOnConsentSwitch =
|
this.displayOnConsentSwitch =
|
||||||
'[id="kc-display.on.consent.screen"] + .pf-c-switch__toggle';
|
this.displayOnConsentInput + " + .pf-c-switch__toggle";
|
||||||
this.consentScreenTextInput = "#kc-consent-screen-text";
|
this.consentScreenTextInput = "#kc-consent-screen-text";
|
||||||
this.includeInTokenSwitch =
|
this.includeInTokenSwitch =
|
||||||
'[id="includeInTokenScope"] + .pf-c-switch__toggle';
|
'[id="includeInTokenScope"] + .pf-c-switch__toggle';
|
||||||
|
@ -77,6 +79,14 @@ export default class CreateClientScopePage extends CommonPage {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getSwitchDisplayOnConsentScreenInput() {
|
||||||
|
return cy.get(this.displayOnConsentInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
getConsentScreenTextInput() {
|
||||||
|
return cy.get(this.consentScreenTextInput);
|
||||||
|
}
|
||||||
|
|
||||||
switchDisplayOnConsentScreen() {
|
switchDisplayOnConsentScreen() {
|
||||||
cy.get(this.displayOnConsentSwitch).click();
|
cy.get(this.displayOnConsentSwitch).click();
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,7 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
setValue,
|
setValue,
|
||||||
formState: { errors },
|
formState: { errors },
|
||||||
} = useForm<ClientScopeRepresentation>({
|
} = useForm<ClientScopeRepresentation>();
|
||||||
defaultValues: { attributes: { "display.on.consent.screen": "true" } },
|
|
||||||
});
|
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
|
||||||
const providers = useLoginProviders();
|
const providers = useLoginProviders();
|
||||||
|
@ -54,11 +52,12 @@ export const ScopeForm = ({ clientScope, save }: ScopeFormProps) => {
|
||||||
const [openType, setOpenType] = useState(false);
|
const [openType, setOpenType] = useState(false);
|
||||||
const { id } = useParams<{ id: string }>();
|
const { id } = useParams<{ id: string }>();
|
||||||
|
|
||||||
const displayOnConsentScreen = useWatch({
|
const displayOnConsentScreen = useWatch<string>({
|
||||||
control,
|
control,
|
||||||
name: "attributes.display.on.consent.screen",
|
name: convertAttributeNameToForm("attributes.display.on.consent.screen"),
|
||||||
defaultValue:
|
defaultValue:
|
||||||
clientScope.attributes?.["display.on.consent.screen"] ?? "true",
|
clientScope.attributes?.["display.on.consent.screen"] ??
|
||||||
|
(id ? "false" : "true"),
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
|
@ -24,7 +24,7 @@ export const LoginSettingsPanel = ({ access }: { access?: boolean }) => {
|
||||||
const loginThemes = useServerInfo().themes!["login"];
|
const loginThemes = useServerInfo().themes!["login"];
|
||||||
const consentRequired = watch("consentRequired");
|
const consentRequired = watch("consentRequired");
|
||||||
const displayOnConsentScreen: string = watch(
|
const displayOnConsentScreen: string = watch(
|
||||||
"attributes.display.on.consent.screen"
|
convertAttributeNameToForm("attributes.display.on.consent.screen")
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue