Fix broken Cypress tests (#28414)

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2024-04-03 19:16:03 +02:00 committed by GitHub
parent 2b9ac828c1
commit 82843d3e0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 45 deletions

View file

@ -485,7 +485,7 @@ export default class ProviderBaseGeneralSettingsPage extends PageObject {
this.selectFirstLoginFlowOption(LoginFlowOption.browser); this.selectFirstLoginFlowOption(LoginFlowOption.browser);
this.selectPostLoginFlowOption(LoginFlowOption.directGrant); this.selectPostLoginFlowOption(LoginFlowOption.directGrant);
this.selectSyncModeOption(SyncModeOption.legacy); this.selectSyncModeOption(SyncModeOption.import);
this.clickRevertBtn(); this.clickRevertBtn();
cy.get(this.#advancedSettingsToggle).scrollIntoView().click(); cy.get(this.#advancedSettingsToggle).scrollIntoView().click();
@ -498,7 +498,7 @@ export default class ProviderBaseGeneralSettingsPage extends PageObject {
this.assertFirstLoginFlowSelectOptionEqual(LoginFlowOption.empty); this.assertFirstLoginFlowSelectOptionEqual(LoginFlowOption.empty);
this.assertPostLoginFlowSelectOptionEqual(LoginFlowOption.none); this.assertPostLoginFlowSelectOptionEqual(LoginFlowOption.none);
this.assertSyncModeSelectOptionEqual(SyncModeOption.import); this.assertSyncModeSelectOptionEqual(SyncModeOption.legacy);
this.assertClientAssertSigAlgSelectOptionEqual( this.assertClientAssertSigAlgSelectOptionEqual(
ClientAssertionSigningAlg.algorithmNotSpecified, ClientAssertionSigningAlg.algorithmNotSpecified,
); );

View file

@ -11,16 +11,16 @@ import {
import { useState } from "react"; import { useState } from "react";
import { Controller, useFormContext, useWatch } from "react-hook-form"; import { Controller, useFormContext, useWatch } from "react-hook-form";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { HelpItem } from "ui-shared"; import { HelpItem, SelectControl } from "ui-shared";
import { adminClient } from "../../admin-client"; import { adminClient } from "../../admin-client";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
import { useFetch } from "../../utils/useFetch"; import { useFetch } from "../../utils/useFetch";
import useIsFeatureEnabled, { Feature } from "../../utils/useIsFeatureEnabled"; import useIsFeatureEnabled, { Feature } from "../../utils/useIsFeatureEnabled";
import type { FieldProps } from "../component/FormGroupField"; import type { FieldProps } from "../component/FormGroupField";
import { FormGroupField } from "../component/FormGroupField"; import { FormGroupField } from "../component/FormGroupField";
import { SwitchField } from "../component/SwitchField"; import { SwitchField } from "../component/SwitchField";
import { TextField } from "../component/TextField"; import { TextField } from "../component/TextField";
import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput";
const LoginFlow = ({ const LoginFlow = ({
field, field,
@ -90,7 +90,7 @@ const LoginFlow = ({
); );
}; };
const syncModes = ["import", "legacy", "force"]; const SYNC_MODES = ["IMPORT", "LEGACY", "FORCE"];
type AdvancedSettingsProps = { isOIDC: boolean; isSAML: boolean }; type AdvancedSettingsProps = { isOIDC: boolean; isSAML: boolean };
export const AdvancedSettings = ({ isOIDC, isSAML }: AdvancedSettingsProps) => { export const AdvancedSettings = ({ isOIDC, isSAML }: AdvancedSettingsProps) => {
@ -101,7 +101,6 @@ export const AdvancedSettings = ({ isOIDC, isSAML }: AdvancedSettingsProps) => {
setValue, setValue,
formState: { errors }, formState: { errors },
} = useFormContext<IdentityProviderRepresentation>(); } = useFormContext<IdentityProviderRepresentation>();
const [syncModeOpen, setSyncModeOpen] = useState(false);
const filteredByClaim = useWatch({ const filteredByClaim = useWatch({
control, control,
name: "config.filteredByClaim", name: "config.filteredByClaim",
@ -268,46 +267,19 @@ export const AdvancedSettings = ({ isOIDC, isSAML }: AdvancedSettingsProps) => {
</FormGroupField> </FormGroupField>
)} )}
{syncModeAvailable && ( {syncModeAvailable && (
<FormGroup <SelectControl
className="pf-u-pb-3xl"
label={t("syncMode")}
labelIcon={
<HelpItem helpText={t("syncModeHelp")} fieldLabelId="syncMode" />
}
fieldId="syncMode"
>
<Controller
name="config.syncMode" name="config.syncMode"
defaultValue={syncModes[0].toUpperCase()} label={t("syncMode")}
control={control} labelIcon={t("syncModeHelp")}
render={({ field }) => ( options={SYNC_MODES.map((syncMode) => ({
<Select key: syncMode,
toggleId="syncMode" value: t(`syncModes.${syncMode.toLocaleLowerCase()}`),
required }))}
direction="up" controller={{
onToggle={() => setSyncModeOpen(!syncModeOpen)} defaultValue: SYNC_MODES[0],
onSelect={(_, value) => { rules: { required: t("required") },
field.onChange(value as string);
setSyncModeOpen(false);
}} }}
selections={t(`syncModes.${field.value.toLowerCase()}`)}
variant={SelectVariant.single}
aria-label={t("syncMode")}
isOpen={syncModeOpen}
>
{syncModes.map((option) => (
<SelectOption
selected={option === field.value}
key={option}
value={option.toUpperCase()}
>
{t(`syncModes.${option}`)}
</SelectOption>
))}
</Select>
)}
/> />
</FormGroup>
)} )}
</> </>
); );