@@ -31,36 +31,73 @@ describe('Admin theming set default apps', () => {
3131 cy . visit ( '/settings/admin/theming' )
3232
3333 cy . get ( '.settings-section' ) . contains ( 'Navigation bar settings' ) . should ( 'exist' )
34- cy . get ( '[data-cy-switch-default-app]' ) . should ( 'exist' )
35- cy . get ( '[data-cy-switch-default-app]' ) . scrollIntoView ( )
34+ getDefaultAppSwitch ( ) . should ( 'exist' )
35+ getDefaultAppSwitch ( ) . scrollIntoView ( )
3636 } )
3737
3838 it ( 'Toggle the "use custom default app" switch' , ( ) => {
39- cy . get ( '[data-cy-switch-default-app] input' ) . should ( 'not.be.checked' )
40- cy . get ( '[data-cy-switch-default-app] .checkbox-content' ) . click ( )
41- cy . get ( '[data-cy-switch-default-app] input' ) . should ( 'be.checked' )
39+ getDefaultAppSwitch ( ) . should ( 'not.be.checked' )
40+ cy . findByRole ( 'region' , { name : 'Global default app' } )
41+ . should ( 'not.exist' )
42+
43+ getDefaultAppSwitch ( ) . check ( { force : true } )
44+ getDefaultAppSwitch ( ) . should ( 'be.checked' )
45+ cy . findByRole ( 'region' , { name : 'Global default app' } )
46+ . should ( 'exist' )
47+ } )
48+
49+ it ( 'See the default app combobox' , ( ) => {
50+ cy . findByRole ( 'region' , { name : 'Global default app' } )
51+ . should ( 'exist' )
52+ . findByRole ( 'combobox' )
53+ . as ( 'defaultAppSelect' )
54+ . scrollIntoView ( )
55+
56+ cy . get ( '@defaultAppSelect' )
57+ . findByText ( 'Dashboard' )
58+ . should ( 'be.visible' )
59+ cy . get ( '@defaultAppSelect' )
60+ . findByText ( 'Files' )
61+ . should ( 'be.visible' )
4262 } )
4363
4464 it ( 'See the default app order selector' , ( ) => {
45- cy . get ( '[data-cy-app-order] [data-cy-app-order-element]' ) . then ( ( elements ) => {
46- const appIDs = elements . map ( ( idx , el ) => el . getAttribute ( 'data-cy-app-order-element' ) ) . get ( )
47- expect ( appIDs ) . to . deep . eq ( [ 'dashboard' , 'files' ] )
48- } )
65+ cy . findByRole ( 'region' , { name : 'Global default app' } )
66+ . should ( 'exist' )
67+ cy . findByRole ( 'list' , { name : 'Navigation bar app order' } )
68+ . should ( 'exist' )
69+ . findAllByRole ( 'listitem' )
70+ . should ( 'have.length' , 2 )
71+ . then ( ( elements ) => {
72+ const appIDs = elements . map ( ( idx , el ) => el . innerText . trim ( ) ) . get ( )
73+ expect ( appIDs ) . to . deep . eq ( [ 'Dashboard' , 'Files' ] )
74+ } )
4975 } )
5076
5177 it ( 'Change the default app' , ( ) => {
52- cy . get ( '[data-cy-app-order] [data-cy-app-order-element="files"]' ) . scrollIntoView ( )
53-
54- cy . get ( '[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]' ) . should ( 'be.visible' )
55- cy . get ( '[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]' ) . click ( )
56- cy . get ( '[data-cy-app-order] [data-cy-app-order-element="files"] [data-cy-app-order-button="up"]' ) . should ( 'not.be.visible' )
78+ cy . findByRole ( 'list' , { name : 'Navigation bar app order' } )
79+ . should ( 'exist' )
80+ . as ( 'appOrderSelector' )
81+ . scrollIntoView ( )
82+
83+ cy . get ( '@appOrderSelector' )
84+ . findAllByRole ( 'listitem' )
85+ . filter ( ( _ , e ) => ! ! e . innerText . match ( / F i l e s / i) )
86+ . findByRole ( 'button' , { name : 'Move up' } )
87+ . as ( 'moveFilesUpButton' )
88+
89+ cy . get ( '@moveFilesUpButton' ) . should ( 'be.visible' )
90+ cy . get ( '@moveFilesUpButton' ) . click ( )
91+ cy . get ( '@moveFilesUpButton' ) . should ( 'not.exist' )
5792 } )
5893
5994 it ( 'See the default app is changed' , ( ) => {
60- cy . get ( '[data-cy-app-order] [data-cy-app-order-element]' ) . then ( ( elements ) => {
61- const appIDs = elements . map ( ( idx , el ) => el . getAttribute ( 'data-cy-app-order-element' ) ) . get ( )
62- expect ( appIDs ) . to . deep . eq ( [ 'files' , 'dashboard' ] )
63- } )
95+ cy . findByRole ( 'list' , { name : 'Navigation bar app order' } )
96+ . findAllByRole ( 'listitem' )
97+ . then ( ( elements ) => {
98+ const appIDs = elements . map ( ( idx , el ) => el . innerText . trim ( ) ) . get ( )
99+ expect ( appIDs ) . to . deep . eq ( [ 'Files' , 'Dashboard' ] )
100+ } )
64101
65102 // Check the redirect to the default app works
66103 cy . request ( { url : '/' , followRedirect : false } ) . then ( ( response ) => {
@@ -72,14 +109,12 @@ describe('Admin theming set default apps', () => {
72109
73110 it ( 'Toggle the "use custom default app" switch back to reset the default apps' , ( ) => {
74111 cy . visit ( '/settings/admin/theming' )
75- cy . get ( '[data-cy-switch-default-app]' ) . scrollIntoView ( )
112+ getDefaultAppSwitch ( ) . scrollIntoView ( )
76113
77- cy . get ( '[data-cy-switch-default-app] input' ) . should ( 'be.checked' )
78- cy . get ( '[data-cy-switch-default-app] .checkbox-content' ) . click ( )
79- cy . get ( '[data-cy-switch-default-app] input' ) . should ( 'be.not.checked' )
80- } )
114+ getDefaultAppSwitch ( ) . should ( 'be.checked' )
115+ getDefaultAppSwitch ( ) . uncheck ( { force : true } )
116+ getDefaultAppSwitch ( ) . should ( 'be.not.checked' )
81117
82- it ( 'See the default app is changed back to default' , ( ) => {
83118 // Check the redirect to the default app works
84119 cy . request ( { url : '/' , followRedirect : false } ) . then ( ( response ) => {
85120 expect ( response . status ) . to . eq ( 302 )
@@ -88,3 +123,7 @@ describe('Admin theming set default apps', () => {
88123 } )
89124 } )
90125} )
126+
127+ function getDefaultAppSwitch ( ) {
128+ return cy . findByRole ( 'checkbox' , { name : 'Use custom default app' } )
129+ }
0 commit comments