This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 832
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Device manager - promote to beta (#9380)
* promote new session manager to beta * hide old sessions section when new dm enabled * use correct logic * add new ViewUserDeviceSettings action * replace device management ctas with viewUserDeviceSettings * test SecurityUserSettingsTab * more complete mocks * more thorough mocks * more mocks * test LabsUserSettingsTab * lint * updated copy * update snaps for new copy
- Loading branch information
Kerry
authored
Oct 11, 2022
1 parent
b336e18
commit 87d3fbd
Showing
15 changed files
with
504 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { UserTab } from "../../components/views/dialogs/UserTab"; | ||
import { Action } from "../../dispatcher/actions"; | ||
import defaultDispatcher from "../../dispatcher/dispatcher"; | ||
|
||
/** | ||
* Redirect to the correct device manager section | ||
* Based on the labs setting | ||
*/ | ||
export const viewUserDeviceSettings = (isNewDeviceManagerEnabled: boolean) => { | ||
defaultDispatcher.dispatch({ | ||
action: Action.ViewUserSettings, | ||
initialTabId: isNewDeviceManagerEnabled ? UserTab.SessionManager : UserTab.Security, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { viewUserDeviceSettings } from "../../../src/actions/handlers/viewUserDeviceSettings"; | ||
import { UserTab } from "../../../src/components/views/dialogs/UserTab"; | ||
import { Action } from "../../../src/dispatcher/actions"; | ||
import defaultDispatcher from "../../../src/dispatcher/dispatcher"; | ||
|
||
describe('viewUserDeviceSettings()', () => { | ||
const dispatchSpy = jest.spyOn(defaultDispatcher, 'dispatch'); | ||
|
||
beforeEach(() => { | ||
dispatchSpy.mockClear(); | ||
}); | ||
|
||
it('dispatches action to view new session manager when enabled', () => { | ||
const isNewDeviceManagerEnabled = true; | ||
viewUserDeviceSettings(isNewDeviceManagerEnabled); | ||
|
||
expect(dispatchSpy).toHaveBeenCalledWith({ | ||
action: Action.ViewUserSettings, | ||
initialTabId: UserTab.SessionManager, | ||
}); | ||
}); | ||
|
||
it('dispatches action to view old session manager when disabled', () => { | ||
const isNewDeviceManagerEnabled = false; | ||
viewUserDeviceSettings(isNewDeviceManagerEnabled); | ||
|
||
expect(dispatchSpy).toHaveBeenCalledWith({ | ||
action: Action.ViewUserSettings, | ||
initialTabId: UserTab.Security, | ||
}); | ||
}); | ||
}); |
73 changes: 73 additions & 0 deletions
73
test/components/views/settings/tabs/user/LabsUserSettingsTab-test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
Copyright 2022 The Matrix.org Foundation C.I.C. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
|
||
import LabsUserSettingsTab from '../../../../../../src/components/views/settings/tabs/user/LabsUserSettingsTab'; | ||
import SettingsStore from '../../../../../../src/settings/SettingsStore'; | ||
import { | ||
getMockClientWithEventEmitter, | ||
mockClientMethodsServer, | ||
mockClientMethodsUser, | ||
} from '../../../../../test-utils'; | ||
import SdkConfig from '../../../../../../src/SdkConfig'; | ||
|
||
describe('<SecurityUserSettingsTab />', () => { | ||
const sdkConfigSpy = jest.spyOn(SdkConfig, 'get'); | ||
|
||
const defaultProps = { | ||
closeSettingsFn: jest.fn(), | ||
}; | ||
const getComponent = () => <LabsUserSettingsTab {...defaultProps} />; | ||
|
||
const userId = '@alice:server.org'; | ||
getMockClientWithEventEmitter({ | ||
...mockClientMethodsUser(userId), | ||
...mockClientMethodsServer(), | ||
}); | ||
|
||
const settingsValueSpy = jest.spyOn(SettingsStore, 'getValue'); | ||
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
settingsValueSpy.mockReturnValue(false); | ||
sdkConfigSpy.mockReturnValue(false); | ||
}); | ||
|
||
it('renders settings marked as beta as beta cards', () => { | ||
const { getByTestId } = render(getComponent()); | ||
expect(getByTestId("labs-beta-section")).toMatchSnapshot(); | ||
}); | ||
|
||
it('does not render non-beta labs settings when disabled in config', () => { | ||
const { container } = render(getComponent()); | ||
expect(sdkConfigSpy).toHaveBeenCalledWith('show_labs_settings'); | ||
|
||
const labsSections = container.getElementsByClassName('mx_SettingsTab_section'); | ||
// only section is beta section | ||
expect(labsSections.length).toEqual(1); | ||
}); | ||
|
||
it('renders non-beta labs settings when enabled in config', () => { | ||
// enable labs | ||
sdkConfigSpy.mockImplementation(configName => configName === 'show_labs_settings'); | ||
const { container } = render(getComponent()); | ||
|
||
const labsSections = container.getElementsByClassName('mx_SettingsTab_section'); | ||
expect(labsSections.length).toEqual(11); | ||
}); | ||
}); |
Oops, something went wrong.