@@ -15,13 +15,11 @@ limitations under the License.
15
15
*/
16
16
17
17
import React from "react" ;
18
- import { render , screen , waitFor } from "@testing-library/react" ;
19
- import userEvent from "@testing-library/user-event" ;
18
+ import { render , screen } from "@testing-library/react" ;
20
19
21
20
import LabsUserSettingsTab from "../../../../../../src/components/views/settings/tabs/user/LabsUserSettingsTab" ;
22
21
import SettingsStore from "../../../../../../src/settings/SettingsStore" ;
23
22
import SdkConfig from "../../../../../../src/SdkConfig" ;
24
- import { SettingLevel } from "../../../../../../src/settings/SettingLevel" ;
25
23
26
24
describe ( "<LabsUserSettingsTab />" , ( ) => {
27
25
const defaultProps = {
@@ -63,105 +61,4 @@ describe("<LabsUserSettingsTab />", () => {
63
61
const labsSections = container . getElementsByClassName ( "mx_SettingsSubsection" ) ;
64
62
expect ( labsSections ) . toHaveLength ( 10 ) ;
65
63
} ) ;
66
-
67
- describe ( "Rust crypto setting" , ( ) => {
68
- const SETTING_NAME = "Rust cryptography implementation" ;
69
-
70
- beforeEach ( ( ) => {
71
- SdkConfig . add ( { show_labs_settings : true } ) ;
72
- } ) ;
73
-
74
- describe ( "Not enabled in config" , ( ) => {
75
- // these tests only works if the feature is not enabled in the config by default?
76
- const copyOfGetValueAt = SettingsStore . getValueAt ;
77
-
78
- beforeEach ( ( ) => {
79
- SettingsStore . getValueAt = (
80
- level : SettingLevel ,
81
- name : string ,
82
- roomId ?: string ,
83
- isExplicit ?: boolean ,
84
- ) => {
85
- if ( level == SettingLevel . CONFIG && name === "feature_rust_crypto" ) return false ;
86
- return copyOfGetValueAt ( level , name , roomId , isExplicit ) ;
87
- } ;
88
- } ) ;
89
-
90
- afterEach ( ( ) => {
91
- SettingsStore . getValueAt = copyOfGetValueAt ;
92
- } ) ;
93
-
94
- it ( "can be turned on if not already" , async ( ) => {
95
- // By the time the settings panel is shown, `MatrixClientPeg.initClientCrypto` has saved the current
96
- // value to the settings store.
97
- await SettingsStore . setValue ( "feature_rust_crypto" , null , SettingLevel . DEVICE , false ) ;
98
-
99
- const rendered = render ( getComponent ( ) ) ;
100
- const toggle = rendered . getByRole ( "switch" , { name : SETTING_NAME } ) ;
101
- expect ( toggle . getAttribute ( "aria-disabled" ) ) . toEqual ( "false" ) ;
102
- expect ( toggle . getAttribute ( "aria-checked" ) ) . toEqual ( "false" ) ;
103
-
104
- const description = toggle . closest ( ".mx_SettingsFlag" ) ?. querySelector ( ".mx_SettingsFlag_microcopy" ) ;
105
- expect ( description ) . toHaveTextContent ( / T o d i s a b l e y o u w i l l n e e d t o l o g o u t a n d b a c k i n / ) ;
106
- } ) ;
107
-
108
- it ( "cannot be turned off once enabled" , async ( ) => {
109
- await SettingsStore . setValue ( "feature_rust_crypto" , null , SettingLevel . DEVICE , true ) ;
110
-
111
- const rendered = render ( getComponent ( ) ) ;
112
- const toggle = rendered . getByRole ( "switch" , { name : SETTING_NAME } ) ;
113
- expect ( toggle . getAttribute ( "aria-disabled" ) ) . toEqual ( "true" ) ;
114
- expect ( toggle . getAttribute ( "aria-checked" ) ) . toEqual ( "true" ) ;
115
-
116
- // Hover over the toggle to make it show the tooltip
117
- await userEvent . hover ( toggle ) ;
118
-
119
- await waitFor ( ( ) => {
120
- const tooltip = screen . getByRole ( "tooltip" ) ;
121
- expect ( tooltip ) . toHaveTextContent (
122
- "Once enabled, Rust cryptography can only be disabled by logging out and in again" ,
123
- ) ;
124
- } ) ;
125
- } ) ;
126
- } ) ;
127
-
128
- describe ( "Enabled in config" , ( ) => {
129
- beforeEach ( ( ) => {
130
- SdkConfig . add ( { features : { feature_rust_crypto : true } } ) ;
131
- } ) ;
132
-
133
- it ( "can be turned on if not already" , async ( ) => {
134
- // By the time the settings panel is shown, `MatrixClientPeg.initClientCrypto` has saved the current
135
- // value to the settings store.
136
- await SettingsStore . setValue ( "feature_rust_crypto" , null , SettingLevel . DEVICE , false ) ;
137
-
138
- const rendered = render ( getComponent ( ) ) ;
139
- const toggle = rendered . getByRole ( "switch" , { name : SETTING_NAME } ) ;
140
- expect ( toggle . getAttribute ( "aria-disabled" ) ) . toEqual ( "false" ) ;
141
- expect ( toggle . getAttribute ( "aria-checked" ) ) . toEqual ( "false" ) ;
142
-
143
- const description = toggle . closest ( ".mx_SettingsFlag" ) ?. querySelector ( ".mx_SettingsFlag_microcopy" ) ;
144
- expect ( description ) . toHaveTextContent ( / I t c a n n o t b e d i s a b l e d / ) ;
145
- } ) ;
146
-
147
- it ( "cannot be turned off once enabled" , async ( ) => {
148
- await SettingsStore . setValue ( "feature_rust_crypto" , null , SettingLevel . DEVICE , true ) ;
149
-
150
- const rendered = render ( getComponent ( ) ) ;
151
- const toggle = rendered . getByRole ( "switch" , { name : SETTING_NAME } ) ;
152
- expect ( toggle . getAttribute ( "aria-disabled" ) ) . toEqual ( "true" ) ;
153
- expect ( toggle . getAttribute ( "aria-checked" ) ) . toEqual ( "true" ) ;
154
-
155
- // Hover over the toggle to make it show the tooltip
156
- await userEvent . hover ( toggle ) ;
157
-
158
- await waitFor ( ( ) => {
159
- const tooltip = rendered . getByRole ( "tooltip" ) ;
160
- expect ( tooltip ) . toHaveTextContent (
161
- "Rust cryptography cannot be disabled on this deployment of BrandedClient" ,
162
- ) ;
163
- } ) ;
164
- } ) ;
165
- } ) ;
166
- } ) ;
167
64
} ) ;
0 commit comments