search.spec.ts 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  1. context('Access to search result page', () => {
  2. const ssPrefix = 'access-to-result-page-directly-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. // collapse sidebar
  9. cy.collapseSidebar(true);
  10. });
  11. it('/_search with "q" param is successfully loaded', () => {
  12. cy.visit('/_search', { qs: { q: 'labels alerts cards blocks' } });
  13. cy.getByTestid('search-result-base').should('be.visible');
  14. cy.getByTestid('search-result-list').should('be.visible');
  15. cy.getByTestid('search-result-content').should('be.visible');
  16. cy.get('.wiki').should('be.visible');
  17. // for avoid mismatch by auto scrolling
  18. cy.get('.search-result-content-body-container').scrollTo('top');
  19. cy.screenshot(`${ssPrefix}with-q`);
  20. });
  21. it('checkboxes behaviors', () => {
  22. cy.visit('/_search', { qs: { q: 'labels alerts cards blocks' } });
  23. cy.getByTestid('search-result-base').should('be.visible');
  24. cy.getByTestid('search-result-list').should('be.visible');
  25. cy.getByTestid('search-result-content').should('be.visible');
  26. cy.get('.wiki').should('be.visible');
  27. // for avoid mismatch by auto scrolling
  28. cy.get('.search-result-content-body-container').scrollTo('top');
  29. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  30. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  31. cy.getByTestid('cb-select').first().click({force: true});
  32. cy.screenshot(`${ssPrefix}the-first-checkbox-on`);
  33. cy.getByTestid('cb-select').first().click({force: true});
  34. cy.screenshot(`${ssPrefix}the-first-checkbox-off`);
  35. // click select all checkbox
  36. cy.getByTestid('cb-select-all').click({force: true});
  37. cy.screenshot(`${ssPrefix}the-select-all-checkbox-1`);
  38. cy.getByTestid('cb-select').first().click({force: true});
  39. cy.screenshot(`${ssPrefix}the-select-all-checkbox-2`);
  40. cy.getByTestid('cb-select').first().click({force: true});
  41. cy.screenshot(`${ssPrefix}the-select-all-checkbox-3`);
  42. cy.getByTestid('cb-select-all').click({force: true});
  43. cy.screenshot(`${ssPrefix}the-select-all-checkbox-4`);
  44. });
  45. });
  46. context('Access to legacy private pages', () => {
  47. const ssPrefix = 'access-to-legacy-private-pages-directly-';
  48. beforeEach(() => {
  49. // login
  50. cy.fixture("user-admin.json").then(user => {
  51. cy.login(user.username, user.password);
  52. });
  53. // collapse sidebar
  54. cy.collapseSidebar(true);
  55. });
  56. it('/_private-legacy-pages is successfully loaded', () => {
  57. cy.visit('/_private-legacy-pages');
  58. cy.getByTestid('search-result-base').should('be.visible');
  59. cy.getByTestid('search-result-private-legacy-pages').should('be.visible');
  60. cy.screenshot(`${ssPrefix}shown`);
  61. });
  62. });
  63. context('Search all pages', () => {
  64. const ssPrefix = 'search-all-pages-';
  65. beforeEach(() => {
  66. // login
  67. cy.fixture("user-admin.json").then(user => {
  68. cy.login(user.username, user.password);
  69. });
  70. // collapse sidebar
  71. cy.collapseSidebar(true);
  72. });
  73. it(`Search all pages by word is successfully loaded`, () => {
  74. const searchText = 'help';
  75. cy.visit('/');
  76. cy.get('.rbt-input').click();
  77. cy.get('.rbt-menu.dropdown-menu.show').should('be.visible').within(() => {
  78. cy.screenshot(`${ssPrefix}1-search-input-focused`);
  79. })
  80. cy.get('.rbt-input-main').type(`${searchText}`);
  81. cy.screenshot(`${ssPrefix}2-insert-search-text`, { capture: 'viewport'});
  82. cy.get('.rbt-input-main').type('{enter}');
  83. cy.getByTestid('search-result-base').should('be.visible');
  84. cy.getByTestid('search-result-list').should('be.visible');
  85. cy.getByTestid('search-result-content').should('be.visible');
  86. cy.get('.wiki').should('be.visible');
  87. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  88. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  89. // for avoid mismatch by auto scrolling
  90. cy.get('.search-result-content-body-container').scrollTo('top');
  91. // eslint-disable-next-line cypress/no-unnecessary-waiting
  92. cy.wait(1500);
  93. cy.screenshot(`${ssPrefix}3-search-page-results`, { capture: 'viewport'});
  94. cy.getByTestid('open-page-item-control-btn').eq(1).click();
  95. cy.getByTestid('search-result-content').should('be.visible');
  96. cy.get('.wiki').should('be.visible');
  97. // for avoid mismatch by auto scrolling
  98. cy.get('.search-result-content-body-container').scrollTo('top');
  99. cy.screenshot(`${ssPrefix}4-click-three-dots-menu`, {capture: 'viewport'});
  100. //Add bookmark
  101. cy.getByTestid('add-remove-bookmark-btn').click({force: true});
  102. cy.get('.btn-bookmark.active').should('be.visible');
  103. cy.screenshot(`${ssPrefix}5-add-bookmark`, {capture: 'viewport'});
  104. // Duplicate page
  105. cy.getByTestid('open-page-duplicate-modal-btn').first().click({force: true});
  106. cy.getByTestid('page-duplicate-modal').should('be.visible');
  107. cy.screenshot(`${ssPrefix}6-duplicate-page`, {capture: 'viewport'});
  108. // Close Modal
  109. cy.get('body').type('{esc}');
  110. // Move / Rename Page
  111. cy.getByTestid('open-page-move-rename-modal-btn').first().click({force: true});
  112. cy.getByTestid('page-rename-modal').should('be.visible');
  113. cy.screenshot(`${ssPrefix}7-move-rename-page`, {capture: 'viewport'});
  114. // Close Modal
  115. cy.get('body').type('{esc}');
  116. // Delete page
  117. cy.getByTestid('open-page-delete-modal-btn').first().click({ force: true});
  118. cy.getByTestid('page-delete-modal').should('be.visible');
  119. cy.screenshot(`${ssPrefix}8-delete-page`, {capture: 'viewport'});
  120. });
  121. it(`Search all pages by tag is successfully loaded `, () => {
  122. const tag = 'help';
  123. const searchText = `tag:${tag}`;
  124. cy.visit('/');
  125. // Add tag
  126. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click({force: true});
  127. cy.get('#edit-tag-modal').should('be.visible');
  128. cy.get('#edit-tag-modal').within(() => {
  129. cy.get('.rbt-input-main').type(tag);
  130. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  131. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  132. cy.get('a#tag-typeahead-asynctypeahead-item-0').click({force: true})
  133. });
  134. cy.get('#edit-tag-modal').within(() => {
  135. cy.get('div.modal-footer > button').click();
  136. });
  137. cy.visit('/');
  138. cy.get('.rbt-input').click({force: true});
  139. cy.get('.rbt-input-main').type(`${searchText}`);
  140. cy.screenshot(`${ssPrefix}1-insert-search-text-with-tag`, { capture: 'viewport'});
  141. cy.get('.rbt-input-main').type('{enter}');
  142. cy.getByTestid('search-result-base').should('be.visible');
  143. cy.getByTestid('search-result-list').should('be.visible');
  144. cy.getByTestid('search-result-content').should('be.visible');
  145. cy.get('.wiki').should('be.visible');
  146. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  147. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  148. cy.screenshot(`${ssPrefix}2-search-with-tag-result`, {capture: 'viewport'});
  149. cy.getByTestid('open-page-item-control-btn').first().click();
  150. cy.getByTestid('search-result-content').should('be.visible');
  151. cy.get('.wiki').should('be.visible');
  152. cy.screenshot(`${ssPrefix}3-click-three-dots-menu-search-with-tag`, {capture: 'viewport'});
  153. });
  154. it('Successfully order page search results by tag', () => {
  155. const tag = 'help';
  156. cy.visit('/');
  157. cy.get('.grw-taglabels-container > div > a').contains(tag).click();
  158. cy.getByTestid('search-result-base').should('be.visible');
  159. cy.getByTestid('search-result-list').should('be.visible');
  160. cy.getByTestid('search-result-content').should('be.visible');
  161. cy.get('.wiki').should('be.visible');
  162. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  163. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  164. cy.screenshot(`${ssPrefix}1-tag-order-click-tag-name`, {capture: 'viewport'});
  165. cy.get('.grw-search-page-nav').within(() => {
  166. cy.get('button.dropdown-toggle').first().click({force: true});
  167. cy.get('.dropdown-menu-right').should('be.visible');
  168. cy.get('.dropdown-menu-right > button:nth-child(1)').click({force: true});
  169. });
  170. cy.getByTestid('search-result-base').should('be.visible');
  171. cy.getByTestid('search-result-list').should('be.visible');
  172. cy.getByTestid('search-result-content').should('be.visible');
  173. cy.get('.wiki').should('be.visible');
  174. cy.screenshot(`${ssPrefix}2-tag-order-by-relevance`);
  175. cy.get('.grw-search-page-nav').within(() => {
  176. cy.get('button.dropdown-toggle').first().click({force: true});
  177. cy.get('.dropdown-menu-right').should('be.visible');
  178. cy.get('.dropdown-menu-right > button:nth-child(2)').click({force: true});
  179. });
  180. cy.getByTestid('search-result-base').should('be.visible');
  181. cy.getByTestid('search-result-list').should('be.visible');
  182. cy.getByTestid('search-result-content').should('be.visible');
  183. cy.get('.wiki').should('be.visible');
  184. cy.screenshot(`${ssPrefix}3-tag-order-by-creation-date`);
  185. cy.get('.grw-search-page-nav').within(() => {
  186. cy.get('button.dropdown-toggle').first().click({force: true});
  187. cy.get('.dropdown-menu-right').should('be.visible');
  188. cy.get('.dropdown-menu-right > button:nth-child(3)').click({force: true});
  189. });
  190. cy.getByTestid('search-result-base').should('be.visible');
  191. cy.getByTestid('search-result-list').should('be.visible');
  192. cy.getByTestid('search-result-content').should('be.visible');
  193. cy.get('.wiki').should('be.visible');
  194. cy.screenshot(`${ssPrefix}4-tag-order-by-last-update-date`);
  195. });
  196. });
  197. context('Search current tree with "prefix":', () => {
  198. const ssPrefix = 'search-current-tree-';
  199. beforeEach(() => {
  200. // login
  201. cy.fixture("user-admin.json").then(user => {
  202. cy.login(user.username, user.password);
  203. });
  204. // collapse sidebar
  205. cy.collapseSidebar(true);
  206. });
  207. it(`Search current tree by word is successfully loaded`, () => {
  208. const searchText = 'help';
  209. cy.visit('/');
  210. cy.getByTestid('select-search-scope').first().click({force: true});
  211. cy.get('.input-group-prepend.show > div > button:nth-child(2)').click({force: true});
  212. cy.get('.rbt-input').click();
  213. cy.get('.rbt-menu.dropdown-menu.show').should('be.visible').within(() => {
  214. cy.screenshot(`${ssPrefix}1-search-input-focused`);
  215. })
  216. cy.get('.rbt-input').type(`${searchText}`);
  217. cy.screenshot(`${ssPrefix}2-insert-search-text`, { capture: 'viewport'});
  218. cy.get('.rbt-input').type('{enter}');
  219. cy.getByTestid('search-result-base').should('be.visible');
  220. cy.getByTestid('search-result-list').should('be.visible');
  221. cy.getByTestid('search-result-content').should('be.visible');
  222. cy.get('.wiki').should('be.visible');
  223. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  224. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  225. // for avoid mismatch by auto scrolling
  226. cy.get('.search-result-content-body-container').scrollTo('top');
  227. // eslint-disable-next-line cypress/no-unnecessary-waiting
  228. cy.wait(1500);
  229. cy.screenshot(`${ssPrefix}3-search-page-results`, { capture: 'viewport'});
  230. cy.getByTestid('open-page-item-control-btn').first().click();
  231. cy.getByTestid('search-result-content').should('be.visible');
  232. cy.get('.wiki').should('be.visible');
  233. // for avoid mismatch by auto scrolling
  234. cy.get('.search-result-content-body-container').scrollTo('top');
  235. cy.screenshot(`${ssPrefix}4-click-three-dots-menu`, {capture: 'viewport'});
  236. });
  237. });