1- // Tests for the workspace search dialog local/global scope switch
2- // (ticket #426): inside a workspace the Workspace chip scopes the
3- // livesearch and the Enter results page to the workspace subtree by
4- // default; selecting "Intranet Portal" widens to a global search.
1+ // Tests for the workspace search dialog scope switch (tickets #426 and
2+ // #570): inside a workspace the Workspace chip scopes the livesearch
3+ // and the Enter results page to the workspace subtree by default; the
4+ // chip's dropdown offers "Everywhere" plus every workspace the user
5+ // can access. Result rows carry a location label, and an empty scoped
6+ // search offers a one-click "Search everywhere" escape.
57//
68// The AI parts ("Ask AI") are not covered here: the acceptance backend
79// has no LLM configured, so rag_available is false and the button is
810// hidden by design (graceful degradation).
911//
1012// The solr setup follows the style of search-persons.cy.js.
1113
12- context ( 'Workspace search dialog (local/global scope)' , ( ) => {
14+ context ( 'Workspace search dialog (scope dropdown )' , ( ) => {
1315 beforeEach ( ( ) => {
1416 // The solr connection parameters are provided by the COLLECTIVE_SOLR_*
1517 // environment variables (docker compose setup) or by the registry
@@ -28,7 +30,19 @@ context('Workspace search dialog (local/global scope)', () => {
2830 contentTitle : 'Vacation rules of the GreenCat team' ,
2931 path : '/greencat' ,
3032 } ) ;
31- // content outside the workspace, matching the same search term
33+ // a second workspace, to pick from the scope dropdown
34+ cy . createContent ( {
35+ contentType : 'Workspace' ,
36+ contentId : 'quantum' ,
37+ contentTitle : 'Quantum Workspace' ,
38+ } ) ;
39+ cy . createContent ( {
40+ contentType : 'WikiPage' ,
41+ contentId : 'vacation-quantum' ,
42+ contentTitle : 'Vacation policy of the Quantum group' ,
43+ path : '/quantum' ,
44+ } ) ;
45+ // content outside the workspaces, matching the same search term
3246 cy . createContent ( {
3347 contentType : 'Document' ,
3448 contentId : 'vacation-form' ,
@@ -42,7 +56,7 @@ context('Workspace search dialog (local/global scope)', () => {
4256 cy . clearSolr ( ) ;
4357 } ) ;
4458
45- it ( 'scopes the livesearch to the workspace and can widen to global ' , ( ) => {
59+ it ( 'scopes the livesearch to the workspace and can widen to everywhere ' , ( ) => {
4660 cy . visit ( '/greencat' ) ;
4761 cy . get ( '.header-search-button' ) . click ( ) ;
4862 cy . get ( '.header-search-input-row input' ) . type ( 'vacation' ) ;
@@ -56,14 +70,66 @@ context('Workspace search dialog (local/global scope)', () => {
5670 'Workspace: GreenCat Workspace' ,
5771 ) ;
5872
59- // switch the Workspace chip to Intranet Portal -> global results
73+ // the dropdown lists Everywhere plus all workspaces
74+ cy . get ( '.header-search-chip' ) . contains ( 'Workspace:' ) . click ( ) ;
75+ cy . get ( '.header-search-scope-menu' ) . contains ( 'Search in all areas' ) ;
76+ cy . get ( '.header-search-scope-menu' ) . contains ( 'GreenCat Workspace' ) ;
77+ cy . get ( '.header-search-scope-menu' ) . contains ( 'Quantum Workspace' ) ;
78+
79+ // switch to Everywhere -> global results with location labels
80+ cy . get ( '.header-search-scope-menu .react-aria-MenuItem' )
81+ . contains ( 'Everywhere' )
82+ . click ( ) ;
83+ cy . get ( '.header-search-result-title' ) . should ( 'have.length.at.least' , 3 ) ;
84+ cy . get ( '.header-search-chip' ) . contains ( 'Workspace: Everywhere' ) ;
85+ cy . contains ( '.header-search-result' , 'Vacation request form' )
86+ . find ( '.header-search-result-location' )
87+ . contains ( 'Intranet Portal' ) ;
88+ cy . contains ( '.header-search-result' , 'Vacation rules of the GreenCat team' )
89+ . find ( '.header-search-result-location' )
90+ . contains ( 'GreenCat Workspace' ) ;
91+ } ) ;
92+
93+ it ( 'scopes the livesearch to another workspace picked from the dropdown' , ( ) => {
94+ cy . visit ( '/greencat' ) ;
95+ cy . get ( '.header-search-button' ) . click ( ) ;
96+ cy . get ( '.header-search-input-row input' ) . type ( 'vacation' ) ;
97+ cy . get ( '.header-search-result-title' ) . should ( 'have.length' , 1 ) ;
98+
6099 cy . get ( '.header-search-chip' ) . contains ( 'Workspace:' ) . click ( ) ;
61- cy . get ( '.header-search-chip -menu .react-aria-MenuItem' )
62- . contains ( 'Intranet Portal ' )
100+ cy . get ( '.header-search-scope -menu .react-aria-MenuItem' )
101+ . contains ( 'Quantum Workspace ' )
63102 . click ( ) ;
64- cy . get ( '.header-search-result-title' ) . should ( 'have.length.at.least' , 2 ) ;
103+
104+ cy . get ( '.header-search-result-title' ) . should ( 'have.length' , 1 ) ;
105+ cy . get ( '.header-search-result-title' ) . contains (
106+ 'Vacation policy of the Quantum group' ,
107+ ) ;
108+ cy . get ( '.header-search-chip.is-active' ) . contains (
109+ 'Workspace: Quantum Workspace' ,
110+ ) ;
111+
112+ // Enter goes to the picked workspace's scoped results page
113+ cy . get ( '.header-search-input-row input' ) . type ( '{enter}' ) ;
114+ cy . url ( ) . should ( 'include' , '/quantum/@@search' ) ;
115+ cy . url ( ) . should ( 'include' , 'local=true' ) ;
116+ cy . contains ( 'Vacation policy of the Quantum group' ) ;
117+ cy . contains ( 'Vacation rules of the GreenCat team' ) . should ( 'not.exist' ) ;
118+ } ) ;
119+
120+ it ( 'offers "Search everywhere" when the scoped search is empty' , ( ) => {
121+ cy . visit ( '/greencat' ) ;
122+ cy . get ( '.header-search-button' ) . click ( ) ;
123+ // "request" only matches the portal document, not the workspace
124+ cy . get ( '.header-search-input-row input' ) . type ( 'request' ) ;
125+
126+ cy . get ( '.header-search-no-results' ) . contains (
127+ 'No results in “GreenCat Workspace”.' ,
128+ ) ;
129+ cy . get ( '.header-search-widen' ) . contains ( 'Search everywhere' ) . click ( ) ;
130+
65131 cy . get ( '.header-search-result-title' ) . contains ( 'Vacation request form' ) ;
66- cy . get ( '.header-search-chip' ) . contains ( 'Workspace: Intranet Portal ' ) ;
132+ cy . get ( '.header-search-chip' ) . contains ( 'Workspace: Everywhere ' ) ;
67133 } ) ;
68134
69135 it ( 'Enter opens the workspace-scoped results page without a local toggle' , ( ) => {
@@ -81,13 +147,13 @@ context('Workspace search dialog (local/global scope)', () => {
81147 cy . get ( '.search-localized' ) . should ( 'not.exist' ) ;
82148 } ) ;
83149
84- it ( 'Enter searches globally when Intranet Portal is selected' , ( ) => {
150+ it ( 'Enter searches globally when Everywhere is selected' , ( ) => {
85151 cy . visit ( '/greencat' ) ;
86152 cy . get ( '.header-search-button' ) . click ( ) ;
87153 cy . get ( '.header-search-input-row input' ) . type ( 'vacation' ) ;
88154 cy . get ( '.header-search-chip' ) . contains ( 'Workspace:' ) . click ( ) ;
89- cy . get ( '.header-search-chip -menu .react-aria-MenuItem' )
90- . contains ( 'Intranet Portal ' )
155+ cy . get ( '.header-search-scope -menu .react-aria-MenuItem' )
156+ . contains ( 'Everywhere ' )
91157 . click ( ) ;
92158 cy . get ( '.header-search-input-row input' ) . type ( '{enter}' ) ;
93159
0 commit comments