use-tools.spec.ts 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. context('Switch Sidebar content', () => {
  2. const ssPrefix = 'switch-sidebar-content';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. });
  9. it('PageTree is successfully shown', () => {
  10. cy.collapseSidebar(false);
  11. cy.visit('/page');
  12. cy.getByTestid('grw-sidebar-nav-primary-page-tree').click();
  13. // eslint-disable-next-line cypress/no-unnecessary-waiting
  14. cy.wait(1500);
  15. cy.screenshot(`${ssPrefix}-pagetree-after-load`, { capture: 'viewport' });
  16. });
  17. });
  18. context('Modal for page operation', () => {
  19. const ssPrefix = 'modal-for-page-operation-';
  20. beforeEach(() => {
  21. // login
  22. cy.fixture("user-admin.json").then(user => {
  23. cy.login(user.username, user.password);
  24. });
  25. cy.collapseSidebar(true);
  26. });
  27. it("PageCreateModal is shown successfully", () => {
  28. cy.visit('/me');
  29. cy.getByTestid('newPageBtn').click();
  30. cy.getByTestid('page-create-modal').should('be.visible').screenshot(`${ssPrefix}-open`);
  31. cy.getByTestid('row-create-page-under-below').find('input.form-control').clear().type('/new-page');
  32. cy.getByTestid('btn-create-page-under-below').click();
  33. cy.getByTestid('page-editor').should('be.visible');
  34. cy.screenshot(`${ssPrefix}-create-clicked`, {capture: 'viewport'});
  35. });
  36. it('PageDeleteModal is shown successfully', () => {
  37. cy.visit('/Sandbox/Bootstrap4');
  38. cy.get('#grw-subnav-container').within(() => {
  39. cy.getByTestid('open-page-item-control-btn').click();
  40. cy.getByTestid('open-page-delete-modal-btn').click();
  41. });
  42. cy.getByTestid('page-delete-modal').should('be.visible').screenshot(`${ssPrefix}-delete-bootstrap4`);
  43. });
  44. it('PageDuplicateModal is shown successfully', () => {
  45. cy.visit('/Sandbox/Bootstrap4', { });
  46. cy.get('#grw-subnav-container').within(() => {
  47. cy.getByTestid('open-page-item-control-btn').click();
  48. cy.getByTestid('open-page-duplicate-modal-btn').click();
  49. });
  50. cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
  51. });
  52. it('PageMoveRenameModal is shown successfully', () => {
  53. cy.visit('/Sandbox/Bootstrap4', { });
  54. cy.get('#grw-subnav-container').within(() => {
  55. cy.getByTestid('open-page-item-control-btn').click();
  56. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  57. });
  58. cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);
  59. });
  60. });
  61. context('Open presentation modal', () => {
  62. const ssPrefix = 'access-to-presentation-modal-';
  63. beforeEach(() => {
  64. // login
  65. cy.fixture("user-admin.json").then(user => {
  66. cy.login(user.username, user.password);
  67. });
  68. cy.collapseSidebar(true);
  69. });
  70. it('PresentationModal for "/" is shown successfully', () => {
  71. cy.visit('/');
  72. cy.get('#grw-subnav-container').within(() => {
  73. cy.getByTestid('open-page-item-control-btn').click({force: true});
  74. cy.getByTestid('open-presentation-modal-btn').click({force: true});
  75. });
  76. // eslint-disable-next-line cypress/no-unnecessary-waiting
  77. cy.wait(1500);
  78. cy.screenshot(`${ssPrefix}-open-top`);
  79. });
  80. });
  81. context('Page Accessories Modal', () => {
  82. const ssPrefix = 'access-to-page-accessories-modal';
  83. beforeEach(() => {
  84. // login
  85. cy.fixture("user-admin.json").then(user => {
  86. cy.login(user.username, user.password);
  87. });
  88. cy.collapseSidebar(true);
  89. });
  90. it('Page History is shown successfully', () => {
  91. cy.visit('/Sandbox/Bootstrap4', { });
  92. cy.get('#grw-subnav-container').within(() => {
  93. cy.getByTestid('open-page-item-control-btn').click();
  94. cy.getByTestid('open-page-accessories-modal-btn-with-history-tab').click();
  95. });
  96. cy.getByTestid('page-accessories-modal').should('be.visible')
  97. cy.getByTestid('page-history').should('be.visible')
  98. cy.screenshot(`${ssPrefix}-open-page-history-bootstrap4`);
  99. });
  100. it('Page Attachment Data is shown successfully', () => {
  101. cy.visit('/Sandbox/Bootstrap4', { });
  102. cy.get('#grw-subnav-container').within(() => {
  103. cy.getByTestid('open-page-item-control-btn').click();
  104. cy.getByTestid('open-page-accessories-modal-btn-with-attachment-data-tab').click();
  105. });
  106. cy.getByTestid('page-accessories-modal').should('be.visible')
  107. cy.getByTestid('page-attachment').should('be.visible')
  108. cy.screenshot(`${ssPrefix}-open-page-attachment-data-bootstrap4`);
  109. });
  110. it('Share Link Management is shown successfully', () => {
  111. cy.visit('/Sandbox/Bootstrap4', { });
  112. cy.get('#grw-subnav-container').within(() => {
  113. cy.getByTestid('open-page-item-control-btn').click();
  114. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').click();
  115. });
  116. cy.getByTestid('page-accessories-modal').should('be.visible');
  117. cy.getByTestid('share-link-management').should('be.visible');
  118. cy.screenshot(`${ssPrefix}-open-share-link-management-bootstrap4`);
  119. });
  120. });
  121. context('Tag Oprations', () =>{
  122. beforeEach(() => {
  123. // login
  124. cy.fixture("user-admin.json").then(user => {
  125. cy.login(user.username, user.password);
  126. });
  127. cy.collapseSidebar(true);
  128. });
  129. it('Successfully add new tag', () => {
  130. const ssPrefix = 'tag-operations-add-new-tag-'
  131. const tag = 'we';
  132. cy.visit('/');
  133. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click({force: true});
  134. cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
  135. cy.get('#edit-tag-modal').within(() => {
  136. cy.get('.rbt-input-main').type(tag, {force: true});
  137. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  138. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  139. cy.screenshot(`${ssPrefix}2-type-tag-name`);
  140. });
  141. cy.get('#edit-tag-modal').within(() => {
  142. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  143. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  144. cy.get('a#tag-typeahead-asynctypeahead-item-0').click({force: true})
  145. cy.screenshot(`${ssPrefix}3-insert-tag-name`, {capture: 'viewport'});
  146. });
  147. cy.get('#edit-tag-modal').within(() => {
  148. cy.get('div.modal-footer > button').click();
  149. });
  150. cy.get('.toast').should('be.visible').trigger('mouseover');
  151. cy.get('.grw-taglabels-container > form > a').contains(tag).should('exist');
  152. /* eslint-disable cypress/no-unnecessary-waiting */
  153. cy.wait(150); // wait for toastr to change its color occured by mouseover
  154. cy.screenshot(`${ssPrefix}4-click-done`, {capture: 'viewport'});
  155. });
  156. it('Successfully duplicate page by generated tag', () => {
  157. const ssPrefix = 'tag-operations-page-duplicate-';
  158. const tag = 'we';
  159. const newPageName = 'our';
  160. cy.visit('/');
  161. cy.get('.grw-taglabels-container > form > a').contains(tag).click();
  162. cy.getByTestid('search-result-base').should('be.visible');
  163. cy.getByTestid('search-result-list').should('be.visible');
  164. cy.get('#wiki').should('be.visible');
  165. cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
  166. cy.getByTestid('open-page-item-control-btn').first().click({force: true});
  167. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`, {capture: 'viewport'});
  168. cy.getByTestid('open-page-duplicate-modal-btn').first().click({force: true});
  169. cy.getByTestid('page-duplicate-modal').should('be.visible');
  170. cy.getByTestid('page-duplicate-modal').within(() => {
  171. cy.get('.rbt-input-main').type(newPageName, {force: true});
  172. }).screenshot(`${ssPrefix}3-duplicate-page`, {capture: 'viewport'});
  173. cy.getByTestid('page-duplicate-modal').within(() => {
  174. cy.get('.modal-footer > button.btn').click();
  175. });
  176. cy.visit(`/${newPageName}`);
  177. cy.get('#wiki').should('not.be.empty');
  178. cy.screenshot(`${ssPrefix}4-duplicated-page`, {capture: 'viewport'});
  179. });
  180. it('Successfully rename page from generated tag', () => {
  181. const ssPrefix = 'tag-operations-page-rename-';
  182. const tag = 'we';
  183. const oldPageName = '/our';
  184. const newPageName = '/ourus';
  185. cy.visit('/');
  186. cy.get('.grw-taglabels-container > form > a').contains(tag).click();
  187. cy.getByTestid('search-result-base').should('be.visible');
  188. cy.getByTestid('search-result-list').should('be.visible');
  189. cy.getByTestid('search-result-content').should('be.visible');
  190. cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
  191. cy.getByTestid('search-result-list').within(() => {
  192. cy.get('.list-group-item').each(($row) => {
  193. if($row.find('a').text() === oldPageName){
  194. cy.wrap($row).within(() => {
  195. cy.getByTestid('open-page-item-control-btn').click();
  196. });
  197. }
  198. });
  199. });
  200. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`, {capture: 'viewport'});
  201. cy.getByTestid('search-result-list').within(() => {
  202. cy.get('.list-group-item').each(($row) => {
  203. if($row.find('a').text() === oldPageName){
  204. cy.wrap($row).within(() => {
  205. cy.getByTestid('open-page-move-rename-modal-btn').click();
  206. });
  207. }
  208. });
  209. });
  210. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  211. cy.get('.rbt-input-main').clear().type(newPageName,{force: true});
  212. }).screenshot(`${ssPrefix}3-insert-new-page-name`);
  213. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  214. cy.get('.modal-footer > button').click();
  215. });
  216. cy.visit(`/${newPageName}`);
  217. cy.getByTestid('grw-tag-labels').should('be.visible');
  218. cy.screenshot(`${ssPrefix}4-new-page-name-applied`, {capture: 'viewport'});
  219. });
  220. });