Fix Cypress tests (#1569)

Co-authored-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
Jon Koops 2021-11-18 13:55:21 +01:00 committed by GitHub
parent d591e0d4a4
commit ff4f58404a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 21 additions and 10 deletions

View file

@ -28,7 +28,7 @@ describe("Events tests", () => {
realmSettingsPage
.toggleSwitch(realmSettingsPage.enableEvents)
.save(realmSettingsPage.modalConfirm);
.save(realmSettingsPage.eventsUserSave);
masthead.signOut();
loginPage.logIn();
@ -78,7 +78,7 @@ describe("Events tests", () => {
realmSettingsPage
.toggleSwitch(realmSettingsPage.enableAdminEvents)
.save(realmSettingsPage.modalConfirm);
.save(realmSettingsPage.eventsAdminSave);
sidebarPage.goToEvents();
cy.findByTestId("admin-events-tab").click();

View file

@ -55,7 +55,7 @@ export default class UserEventsTab {
cy.get("[id^=remove_group]").click();
cy.wait("@eventsFetch");
cy.get("table").should("be.visible").contains("td", "LOGOUT");
cy.get("table").should("not.contain", "LOGOUT");
}
shouldHaveSearchBtnEnabled() {

View file

@ -33,10 +33,13 @@ export function useFetch<T>(
const adminClient = useAdminClient();
const onError = useErrorHandler();
const source = axios.CancelToken.source();
adminClient.setConfig({ requestConfig: { cancelToken: source.token } });
useEffect(() => {
const source = axios.CancelToken.source();
adminClient.setConfig({
requestConfig: { cancelToken: source.token },
});
adminClientCall()
.then((result) => {
if (!source.token.reason) {
@ -49,6 +52,10 @@ export function useFetch<T>(
}
});
adminClient.setConfig({
requestConfig: { cancelToken: undefined },
});
return () => {
source.cancel();
};

View file

@ -15,6 +15,7 @@ import {
DropdownToggle,
Gallery,
PageSection,
Spinner,
Split,
SplitItem,
Text,
@ -50,9 +51,8 @@ export default function IdentityProvidersSection() {
const [addProviderOpen, setAddProviderOpen] = useState(false);
const [manageDisplayDialog, setManageDisplayDialog] = useState(false);
const [providers, setProviders] = useState<IdentityProviderRepresentation[]>(
[]
);
const [providers, setProviders] =
useState<IdentityProviderRepresentation[]>();
const [selectedProvider, setSelectedProvider] =
useState<IdentityProviderRepresentation>();
@ -142,7 +142,7 @@ export default function IdentityProvidersSection() {
alias: selectedProvider!.alias!,
});
setProviders([
...providers.filter((p) => p.alias !== selectedProvider?.alias),
...providers!.filter((p) => p.alias !== selectedProvider?.alias),
]);
refresh();
addAlert(t("deletedSuccess"), AlertVariant.success);
@ -152,6 +152,10 @@ export default function IdentityProvidersSection() {
},
});
if (!providers) {
return <Spinner />;
}
return (
<>
<DeleteConfirm />