update testing
This commit is contained in:
parent
b7afefb715
commit
59ef010b0e
@ -64,7 +64,7 @@ describe("backend context api ", () => {
|
|||||||
} as MerchantBackend.Instances.QueryInstancesResponse,
|
} as MerchantBackend.Instances.QueryInstancesResponse,
|
||||||
});
|
});
|
||||||
|
|
||||||
management.setNewToken("another_token" as AccessToken);
|
management.setNewAccessToken(undefined,"another_token" as AccessToken);
|
||||||
},
|
},
|
||||||
({ instance, management, admin }) => {
|
({ instance, management, admin }) => {
|
||||||
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
||||||
@ -113,7 +113,7 @@ describe("backend context api ", () => {
|
|||||||
name: "instance_name",
|
name: "instance_name",
|
||||||
} as MerchantBackend.Instances.QueryInstancesResponse,
|
} as MerchantBackend.Instances.QueryInstancesResponse,
|
||||||
});
|
});
|
||||||
instance.setNewToken("another_token" as AccessToken);
|
instance.setNewAccessToken(undefined, "another_token" as AccessToken);
|
||||||
},
|
},
|
||||||
({ instance, management, admin }) => {
|
({ instance, management, admin }) => {
|
||||||
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
||||||
|
@ -158,7 +158,7 @@ describe("instance api interaction with details", () => {
|
|||||||
},
|
},
|
||||||
} as MerchantBackend.Instances.QueryInstancesResponse,
|
} as MerchantBackend.Instances.QueryInstancesResponse,
|
||||||
});
|
});
|
||||||
api.setNewToken("secret" as AccessToken);
|
api.setNewAccessToken(undefined, "secret" as AccessToken);
|
||||||
},
|
},
|
||||||
({ query, api }) => {
|
({ query, api }) => {
|
||||||
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
||||||
@ -234,7 +234,7 @@ describe("instance api interaction with details", () => {
|
|||||||
} as MerchantBackend.Instances.QueryInstancesResponse,
|
} as MerchantBackend.Instances.QueryInstancesResponse,
|
||||||
});
|
});
|
||||||
|
|
||||||
api.clearToken();
|
api.clearAccessToken(undefined);
|
||||||
},
|
},
|
||||||
({ query, api }) => {
|
({ query, api }) => {
|
||||||
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
expect(env.assertJustExpectedRequestWereMade()).deep.eq({
|
||||||
|
@ -39,9 +39,6 @@ type Entity = MerchantBackend.Instances.InstanceReconfigurationMessage & {
|
|||||||
//MerchantBackend.Instances.InstanceAuthConfigurationMessage
|
//MerchantBackend.Instances.InstanceAuthConfigurationMessage
|
||||||
interface Props {
|
interface Props {
|
||||||
onUpdate: (d: Entity) => void;
|
onUpdate: (d: Entity) => void;
|
||||||
onChangeAuth: (
|
|
||||||
d: MerchantBackend.Instances.InstanceAuthConfigurationMessage,
|
|
||||||
) => Promise<void>;
|
|
||||||
selected: MerchantBackend.Instances.QueryInstancesResponse;
|
selected: MerchantBackend.Instances.QueryInstancesResponse;
|
||||||
isLoading: boolean;
|
isLoading: boolean;
|
||||||
onBack: () => void;
|
onBack: () => void;
|
||||||
@ -78,7 +75,6 @@ function getTokenValuePart(t?: string): string | undefined {
|
|||||||
|
|
||||||
export function UpdatePage({
|
export function UpdatePage({
|
||||||
onUpdate,
|
onUpdate,
|
||||||
onChangeAuth,
|
|
||||||
selected,
|
selected,
|
||||||
onBack,
|
onBack,
|
||||||
}: Props): VNode {
|
}: Props): VNode {
|
||||||
|
@ -46,17 +46,17 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function Update(props: Props): VNode {
|
export default function Update(props: Props): VNode {
|
||||||
const { updateInstance, clearToken, setNewToken } = useInstanceAPI();
|
const { updateInstance } = useInstanceAPI();
|
||||||
const result = useInstanceDetails();
|
const result = useInstanceDetails();
|
||||||
return CommonUpdate(props, result, updateInstance, clearToken, setNewToken);
|
return CommonUpdate(props, result, updateInstance, );
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AdminUpdate(props: Props & { instanceId: string }): VNode {
|
export function AdminUpdate(props: Props & { instanceId: string }): VNode {
|
||||||
const { updateInstance, clearToken, setNewToken } = useManagementAPI(
|
const { updateInstance } = useManagementAPI(
|
||||||
props.instanceId,
|
props.instanceId,
|
||||||
);
|
);
|
||||||
const result = useManagedInstanceDetails(props.instanceId);
|
const result = useManagedInstanceDetails(props.instanceId);
|
||||||
return CommonUpdate(props, result, updateInstance, clearToken, setNewToken);
|
return CommonUpdate(props, result, updateInstance, );
|
||||||
}
|
}
|
||||||
|
|
||||||
function CommonUpdate(
|
function CommonUpdate(
|
||||||
@ -73,8 +73,6 @@ function CommonUpdate(
|
|||||||
MerchantBackend.ErrorDetail
|
MerchantBackend.ErrorDetail
|
||||||
>,
|
>,
|
||||||
updateInstance: any,
|
updateInstance: any,
|
||||||
clearToken: () => Promise<void>,
|
|
||||||
setNewToken: (t: AccessToken) => Promise<void>,
|
|
||||||
): VNode {
|
): VNode {
|
||||||
const [notif, setNotif] = useState<Notification | undefined>(undefined);
|
const [notif, setNotif] = useState<Notification | undefined>(undefined);
|
||||||
const { i18n } = useTranslationContext();
|
const { i18n } = useTranslationContext();
|
||||||
@ -114,13 +112,6 @@ function CommonUpdate(
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onChangeAuth={(
|
|
||||||
d: MerchantBackend.Instances.InstanceAuthConfigurationMessage,
|
|
||||||
): Promise<void> => {
|
|
||||||
const apiCall =
|
|
||||||
d.method === "external" ? clearToken() : setNewToken(d.token! as AccessToken);
|
|
||||||
return apiCall.then(onConfirm).catch(onUpdateError);
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user