@@ -36,64 +36,70 @@ describe("Registration", () => {
3636 it ( "registers an account and lands on the home screen" , ( ) => {
3737 cy . injectAxe ( ) ;
3838
39- cy . get ( ".mx_ServerPicker_change ", { timeout : 15000 } ) . click ( ) ;
40- cy . get ( ".mx_ServerPickerDialog_continue" ) . should ( "be.visible" ) ;
39+ cy . findByRole ( "button ", { name : "Edit" , timeout : 15000 } ) . click ( ) ;
40+ cy . findByRole ( "button" , { name : "Continue" } ) . should ( "be.visible" ) ;
4141 // Only snapshot the server picker otherwise in the background `matrix.org` may or may not be available
4242 cy . get ( ".mx_Dialog" ) . percySnapshotElement ( "Server Picker" , { widths : [ 516 ] } ) ;
4343 cy . checkA11y ( ) ;
4444
45- cy . get ( ".mx_ServerPickerDialog_otherHomeserver" ) . type ( homeserver . baseUrl ) ;
46- cy . get ( ".mx_ServerPickerDialog_continue" ) . click ( ) ;
45+ cy . findByRole ( "textbox" , { name : "Other homeserver" } ) . type ( homeserver . baseUrl ) ;
46+ cy . findByRole ( "button" , { name : "Continue" } ) . click ( ) ;
4747 // wait for the dialog to go away
4848 cy . get ( ".mx_ServerPickerDialog" ) . should ( "not.exist" ) ;
4949
50- cy . get ( "#mx_RegistrationForm_username" ) . should ( "be.visible" ) ;
50+ cy . findByRole ( "textbox" , { name : "Username" } ) . should ( "be.visible" ) ;
5151 // Hide the server text as it contains the randomly allocated Homeserver port
5252 const percyCSS = ".mx_ServerPicker_server { visibility: hidden !important; }" ;
5353 cy . percySnapshot ( "Registration" , { percyCSS } ) ;
5454 cy . checkA11y ( ) ;
5555
56- cy . get ( "#mx_RegistrationForm_username" ) . type ( "alice" ) ;
57- cy . get ( "#mx_RegistrationForm_password ") . type ( "totally a great password" ) ;
58- cy . get ( "#mx_RegistrationForm_passwordConfirm ") . type ( "totally a great password" ) ;
59- cy . get ( ".mx_Login_submit" ) . click ( ) ;
56+ cy . findByRole ( "textbox" , { name : "Username" } ) . type ( "alice" ) ;
57+ cy . findByPlaceholderText ( "Password ") . type ( "totally a great password" ) ;
58+ cy . findByPlaceholderText ( "Confirm password ") . type ( "totally a great password" ) ;
59+ cy . findByRole ( "button" , { name : "Register" } ) . click ( ) ;
6060
6161 cy . get ( ".mx_RegistrationEmailPromptDialog" ) . should ( "be.visible" ) ;
6262 cy . percySnapshot ( "Registration email prompt" , { percyCSS } ) ;
6363 cy . checkA11y ( ) ;
64- cy . get ( ".mx_RegistrationEmailPromptDialog button.mx_Dialog_primary" ) . click ( ) ;
64+ cy . get ( ".mx_RegistrationEmailPromptDialog" ) . within ( ( ) => {
65+ cy . findByRole ( "button" , { name : "Continue" } ) . click ( ) ;
66+ } ) ;
6567
6668 cy . get ( ".mx_InteractiveAuthEntryComponents_termsPolicy" ) . should ( "be.visible" ) ;
6769 cy . percySnapshot ( "Registration terms prompt" , { percyCSS } ) ;
6870 cy . checkA11y ( ) ;
6971
70- cy . get ( ".mx_InteractiveAuthEntryComponents_termsPolicy input" ) . click ( ) ;
71- cy . get ( ".mx_InteractiveAuthEntryComponents_termsSubmit" ) . click ( ) ;
72+ cy . get ( ".mx_InteractiveAuthEntryComponents_termsPolicy" ) . within ( ( ) => {
73+ cy . findByRole ( "checkbox" ) . click ( ) ; // Click the checkbox before privacy policy anchor link
74+ cy . findByLabelText ( "Privacy Policy" ) . should ( "be.visible" ) ;
75+ } ) ;
76+
77+ cy . findByRole ( "button" , { name : "Accept" } ) . click ( ) ;
7278
7379 cy . get ( ".mx_UseCaseSelection_skip" , { timeout : 30000 } ) . should ( "exist" ) ;
7480 cy . percySnapshot ( "Use-case selection screen" ) ;
7581 cy . checkA11y ( ) ;
76- cy . get ( ".mx_UseCaseSelection_skip .mx_AccessibleButton" ) . click ( ) ;
82+ cy . findByRole ( "button" , { name : "Skip" } ) . click ( ) ;
7783
7884 cy . url ( ) . should ( "contain" , "/#/home" ) ;
7985
80- cy . get ( '[aria-label=" User menu"]' ) . click ( ) ;
81- cy . get ( '[aria-label=" Security & Privacy"]' ) . click ( ) ;
86+ cy . findByRole ( "button" , { name : " User menu" } ) . click ( ) ;
87+ cy . findByRole ( "menuitem" , { name : " Security & Privacy" } ) . click ( ) ;
8288 cy . get ( ".mx_DevicesPanel_myDevice .mx_DevicesPanel_deviceTrust .mx_E2EIcon" ) . should (
8389 "have.class" ,
8490 "mx_E2EIcon_verified" ,
8591 ) ;
8692 } ) ;
8793
8894 it ( "should require username to fulfil requirements and be available" , ( ) => {
89- cy . get ( ".mx_ServerPicker_change ", { timeout : 15000 } ) . click ( ) ;
90- cy . get ( ".mx_ServerPickerDialog_continue" ) . should ( "be.visible" ) ;
91- cy . get ( ".mx_ServerPickerDialog_otherHomeserver" ) . type ( homeserver . baseUrl ) ;
92- cy . get ( ".mx_ServerPickerDialog_continue" ) . click ( ) ;
95+ cy . findByRole ( "button ", { name : "Edit" , timeout : 15000 } ) . click ( ) ;
96+ cy . findByRole ( "button" , { name : "Continue" } ) . should ( "be.visible" ) ;
97+ cy . findByRole ( "textbox" , { name : "Other homeserver" } ) . type ( homeserver . baseUrl ) ;
98+ cy . findByRole ( "button" , { name : "Continue" } ) . click ( ) ;
9399 // wait for the dialog to go away
94100 cy . get ( ".mx_ServerPickerDialog" ) . should ( "not.exist" ) ;
95101
96- cy . get ( "#mx_RegistrationForm_username" ) . should ( "be.visible" ) ;
102+ cy . findByRole ( "textbox" , { name : "Username" } ) . should ( "be.visible" ) ;
97103
98104 cy . intercept ( "**/_matrix/client/*/register/available?username=_alice" , {
99105 statusCode : 400 ,
@@ -105,7 +111,7 @@ describe("Registration", () => {
105111 error : "User ID may not begin with _" ,
106112 } ,
107113 } ) ;
108- cy . get ( "#mx_RegistrationForm_username" ) . type ( "_alice" ) ;
114+ cy . findByRole ( "textbox" , { name : "Username" } ) . type ( "_alice" ) ;
109115 cy . get ( ".mx_Field_tooltip" )
110116 . should ( "have.class" , "mx_Tooltip_visible" )
111117 . should ( "contain.text" , "Some characters not allowed" ) ;
@@ -120,12 +126,12 @@ describe("Registration", () => {
120126 error : "The desired username is already taken" ,
121127 } ,
122128 } ) ;
123- cy . get ( "#mx_RegistrationForm_username" ) . type ( "{selectAll}{backspace}bob" ) ;
129+ cy . findByRole ( "textbox" , { name : "Username" } ) . type ( "{selectAll}{backspace}bob" ) ;
124130 cy . get ( ".mx_Field_tooltip" )
125131 . should ( "have.class" , "mx_Tooltip_visible" )
126132 . should ( "contain.text" , "Someone already has that username" ) ;
127133
128- cy . get ( "#mx_RegistrationForm_username" ) . type ( "{selectAll}{backspace}foobar" ) ;
134+ cy . findByRole ( "textbox" , { name : "Username" } ) . type ( "{selectAll}{backspace}foobar" ) ;
129135 cy . get ( ".mx_Field_tooltip" ) . should ( "not.have.class" , "mx_Tooltip_visible" ) ;
130136 } ) ;
131137} ) ;
0 commit comments