search.spec.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  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.waitUntilSkeletonDisappear();
  77. cy.get('.rbt-input').click();
  78. cy.get('.rbt-menu.dropdown-menu.show').should('be.visible').within(() => {
  79. cy.screenshot(`${ssPrefix}1-search-input-focused`);
  80. })
  81. cy.get('.rbt-input-main').type(`${searchText}`);
  82. cy.screenshot(`${ssPrefix}2-insert-search-text`, { capture: 'viewport'});
  83. cy.get('.rbt-input-main').type('{enter}');
  84. cy.getByTestid('search-result-base').should('be.visible');
  85. cy.getByTestid('search-result-list').should('be.visible');
  86. cy.getByTestid('search-result-content').should('be.visible');
  87. cy.get('.wiki').should('be.visible');
  88. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  89. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  90. // for avoid mismatch by auto scrolling
  91. cy.get('.search-result-content-body-container').scrollTo('top');
  92. // eslint-disable-next-line cypress/no-unnecessary-waiting
  93. cy.wait(1500);
  94. cy.screenshot(`${ssPrefix}3-search-page-results`, { capture: 'viewport'});
  95. cy.getByTestid('open-page-item-control-btn').eq(1).click();
  96. cy.getByTestid('search-result-content').should('be.visible');
  97. cy.get('.wiki').should('be.visible');
  98. // for avoid mismatch by auto scrolling
  99. cy.get('.search-result-content-body-container').scrollTo('top');
  100. cy.screenshot(`${ssPrefix}4-click-three-dots-menu`, {capture: 'viewport'});
  101. //Add bookmark
  102. cy.getByTestid('add-remove-bookmark-btn').click({force: true});
  103. cy.get('.btn-bookmark.active').should('be.visible');
  104. cy.screenshot(`${ssPrefix}5-add-bookmark`, {capture: 'viewport'});
  105. // Duplicate page
  106. cy.getByTestid('open-page-duplicate-modal-btn').first().click({force: true});
  107. cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
  108. cy.screenshot(`${ssPrefix}6-duplicate-page`);
  109. });
  110. // Close Modal
  111. cy.get('body').type('{esc}');
  112. // Move / Rename Page
  113. cy.getByTestid('open-page-move-rename-modal-btn').first().click({force: true});
  114. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  115. cy.screenshot(`${ssPrefix}7-move-rename-page`);
  116. });
  117. // Close Modal
  118. cy.get('body').type('{esc}');
  119. // Delete page
  120. cy.getByTestid('open-page-delete-modal-btn').first().click({ force: true});
  121. cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
  122. cy.screenshot(`${ssPrefix}8-delete-page`);
  123. });
  124. });
  125. it(`Search all pages by tag is successfully loaded `, () => {
  126. const tag = 'help';
  127. const searchText = `tag:${tag}`;
  128. cy.visit('/');
  129. cy.waitUntilSkeletonDisappear();
  130. // Add tag
  131. cy.get('#edit-tags-btn-wrapper-for-tooltip').as('edit-tag-tooltip').should('be.visible');
  132. cy.get('@edit-tag-tooltip').within(()=>{
  133. cy.get('a').should('be.visible').click();
  134. })
  135. cy.get('#edit-tag-modal').as('tag-modal').should('be.visible');
  136. cy.get('@tag-modal').within(() => {
  137. cy.get('.rbt-input-main').type(tag);
  138. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  139. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  140. cy.get('a#tag-typeahead-asynctypeahead-item-0').click()
  141. });
  142. cy.get('#edit-tag-modal').within(() => {
  143. cy.get('div.modal-footer > button').click();
  144. });
  145. cy.visit('/');
  146. cy.waitUntilSkeletonDisappear();
  147. cy.get('.rbt-input').should('be.visible');
  148. cy.get('.rbt-input').click();
  149. cy.get('.rbt-input-main').type(`${searchText}`);
  150. cy.screenshot(`${ssPrefix}1-insert-search-text-with-tag`, { capture: 'viewport'});
  151. cy.get('.rbt-input-main').type('{enter}');
  152. cy.getByTestid('search-result-base').should('be.visible');
  153. cy.getByTestid('search-result-list').should('be.visible');
  154. cy.getByTestid('search-result-content').should('be.visible');
  155. cy.get('.wiki').should('be.visible');
  156. cy.waitUntilSpinnerDisappear();
  157. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  158. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  159. cy.screenshot(`${ssPrefix}2-search-with-tag-result`, {capture: 'viewport'});
  160. cy.getByTestid('search-result-content').should('be.visible');
  161. cy.get('.wiki').should('be.visible');
  162. cy.screenshot(`${ssPrefix}3-click-three-dots-menu-search-with-tag`, {capture: 'viewport'});
  163. });
  164. it('Successfully order page search results by tag', () => {
  165. const tag = 'help';
  166. cy.visit('/');
  167. cy.get('.grw-taglabels-container > div > a').contains(tag).click();
  168. cy.getByTestid('search-result-base').should('be.visible');
  169. cy.getByTestid('search-result-list').should('be.visible');
  170. cy.getByTestid('search-result-content').should('be.visible');
  171. cy.get('.wiki').should('be.visible');
  172. cy.waitUntilSpinnerDisappear();
  173. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  174. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  175. cy.screenshot(`${ssPrefix}1-tag-order-click-tag-name`, {capture: 'viewport'});
  176. cy.get('.grw-search-page-nav').within(() => {
  177. cy.get('button.dropdown-toggle').first().click({force: true});
  178. cy.get('.dropdown-menu-right').should('be.visible');
  179. cy.get('.dropdown-menu-right > button:nth-child(1)').click({force: true});
  180. });
  181. cy.getByTestid('search-result-base').should('be.visible');
  182. cy.getByTestid('search-result-list').should('be.visible');
  183. cy.getByTestid('search-result-content').should('be.visible');
  184. cy.get('.wiki').should('be.visible');
  185. cy.screenshot(`${ssPrefix}2-tag-order-by-relevance`);
  186. cy.get('.grw-search-page-nav').within(() => {
  187. cy.get('button.dropdown-toggle').first().click({force: true});
  188. cy.get('.dropdown-menu-right').should('be.visible');
  189. cy.get('.dropdown-menu-right > button:nth-child(2)').click({force: true});
  190. });
  191. cy.getByTestid('search-result-base').should('be.visible');
  192. cy.getByTestid('search-result-list').should('be.visible');
  193. cy.getByTestid('search-result-content').should('be.visible');
  194. cy.get('.wiki').should('be.visible');
  195. cy.screenshot(`${ssPrefix}3-tag-order-by-creation-date`);
  196. cy.get('.grw-search-page-nav').within(() => {
  197. cy.get('button.dropdown-toggle').first().click({force: true});
  198. cy.get('.dropdown-menu-right').should('be.visible');
  199. cy.get('.dropdown-menu-right > button:nth-child(3)').click({force: true});
  200. });
  201. cy.getByTestid('search-result-base').should('be.visible');
  202. cy.getByTestid('search-result-list').should('be.visible');
  203. cy.getByTestid('search-result-content').should('be.visible');
  204. cy.get('.wiki').should('be.visible');
  205. cy.waitUntilSpinnerDisappear();
  206. cy.screenshot(`${ssPrefix}4-tag-order-by-last-update-date`);
  207. });
  208. });
  209. context('Search current tree with "prefix":', () => {
  210. const ssPrefix = 'search-current-tree-';
  211. beforeEach(() => {
  212. // login
  213. cy.fixture("user-admin.json").then(user => {
  214. cy.login(user.username, user.password);
  215. });
  216. // collapse sidebar
  217. cy.collapseSidebar(true);
  218. });
  219. it(`Search current tree by word is successfully loaded`, () => {
  220. const searchText = 'help';
  221. cy.visit('/');
  222. cy.waitUntilSkeletonDisappear();
  223. cy.getByTestid('select-search-scope').click();
  224. cy.get('.input-group-prepend.show > div > button:nth-child(2)').click();
  225. cy.get('.rbt-input').click();
  226. cy.get('.rbt-menu.dropdown-menu.show').should('be.visible').within(() => {
  227. cy.screenshot(`${ssPrefix}1-search-input-focused`);
  228. })
  229. cy.get('.rbt-input').type(`${searchText}`);
  230. cy.screenshot(`${ssPrefix}2-insert-search-text`, { capture: 'viewport'});
  231. cy.get('.rbt-input').type('{enter}');
  232. cy.getByTestid('search-result-base').should('be.visible');
  233. cy.getByTestid('search-result-list').should('be.visible');
  234. cy.getByTestid('search-result-content').should('be.visible');
  235. cy.get('.wiki').should('be.visible');
  236. cy.waitUntilSpinnerDisappear();
  237. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  238. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  239. // for avoid mismatch by auto scrolling
  240. cy.get('.search-result-content-body-container').scrollTo('top');
  241. // eslint-disable-next-line cypress/no-unnecessary-waiting
  242. cy.wait(1500);
  243. cy.screenshot(`${ssPrefix}3-search-page-results`, { capture: 'viewport'});
  244. cy.getByTestid('search-result-list').within(() => {
  245. cy.getByTestid('open-page-item-control-btn').first().click();
  246. })
  247. // for avoid mismatch by auto scrolling
  248. cy.get('.search-result-content-body-container').scrollTo('top');
  249. // eslint-disable-next-line cypress/no-unnecessary-waiting
  250. cy.wait(1500);
  251. cy.screenshot(`${ssPrefix}4-click-three-dots-menu`, {capture: 'viewport'});
  252. });
  253. });