Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Hide account deactivation for externally managed accounts #11445

Merged
merged 13 commits into from
Aug 22, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,8 @@ export default class GeneralUserSettingsTab extends React.Component<IProps, ISta
const supportsMultiLanguageSpellCheck = plaf?.supportsSpellCheckSettings();

let accountManagementSection: JSX.Element | undefined;
if (SettingsStore.getValue(UIFeature.Deactivate)) {
const isAccountManagedExternally = !!this.state.externalAccountManagementUrl;
if (SettingsStore.getValue(UIFeature.Deactivate) && !isAccountManagedExternally) {
accountManagementSection = this.renderManagementSection();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ describe("<GeneralUserSettingsTab />", () => {
expect(screen.queryByText("Deactivate account")).not.toBeInTheDocument();
expect(SettingsStore.getValue).toHaveBeenCalledWith(UIFeature.Deactivate);
});
it("should not render section when account is managed externally", async () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(settingName) => settingName === UIFeature.Deactivate,
);
// account is managed externally when we have delegated auth configured
mockClient.getClientWellKnown.mockReturnValue({
[M_AUTHENTICATION.name]: {
issuer: "https://issuer.org",
account: "https://issuer.org/account",
},
});
render(getComponent());

await flushPromises();

expect(screen.queryByText("Deactivate account")).not.toBeInTheDocument();
});
it("should render section when account deactivation feature is enabled", () => {
jest.spyOn(SettingsStore, "getValue").mockImplementation(
(settingName) => settingName === UIFeature.Deactivate,
Expand Down