use-tools.spec.ts 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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 and closed successfully", () => {
  28. cy.visit('/');
  29. cy.getByTestid('newPageBtn').click();
  30. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  31. cy.screenshot(`${ssPrefix}new-page-modal-opened`);
  32. cy.get('button.close').click();
  33. });
  34. cy.screenshot(`${ssPrefix}page-create-modal-closed`, {capture: 'viewport'});
  35. });
  36. it("Successfully Create Today's page", () => {
  37. const pageName = 'abcdefg';
  38. cy.visit('/');
  39. cy.getByTestid('newPageBtn').click();
  40. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  41. cy.get('.page-today-input2').type(pageName);
  42. cy.screenshot(`${ssPrefix}today-add-page-name`);
  43. cy.getByTestid('btn-create-memo').click();
  44. });
  45. cy.getByTestid('page-editor').should('be.visible').screenshot(`${ssPrefix}create-today-page`);
  46. });
  47. it('Successfully create page under specific path', () => {
  48. const pageName = 'testtest';
  49. cy.visit('/');
  50. cy.getByTestid('newPageBtn').click();
  51. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  52. cy.get('.rbt-input-main').type(pageName);
  53. cy.screenshot(`${ssPrefix}under-path-add-page-name`);
  54. cy.getByTestid('btn-create-page-under-below').click();
  55. });
  56. cy.getByTestid('page-editor').should('be.visible').screenshot(`${ssPrefix}create-page-under-path`);
  57. });
  58. it('Successfully create a template page under the path', () => {
  59. const templatePath = 'testttttt';
  60. cy.visit('/');
  61. cy.getByTestid('newPageBtn').click();
  62. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  63. cy.get('.rbt-input-main').type(templatePath);
  64. cy.screenshot(`${ssPrefix}create-template-for-children-add-path`);
  65. cy.get('#template-type').click();
  66. cy.get('#template-type').next().find('button:eq(0)').click({force: true});
  67. cy.get('#dd-template-type').next().find('button').click({force: true});
  68. });
  69. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  70. cy.screenshot(`${ssPrefix}create-template-for-children-error`, {capture: 'viewport'});
  71. cy.get('.toast-error').should('be.visible').click();
  72. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  73. cy.get('.rbt-input-main').clear().type('/');
  74. cy.screenshot(`${ssPrefix}create-template-for-descendants-add-path`);
  75. cy.get('#template-type').click();
  76. cy.get('#template-type').next().find('button:eq(1)').click({force: true});
  77. cy.get('#dd-template-type').next().find('button').click({force: true});
  78. });
  79. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  80. cy.screenshot(`${ssPrefix}create-template-for-descendants-error`, {capture: 'viewport'});
  81. cy.get('.toast-error').should('be.visible').click();
  82. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  83. cy.get('button.close').click();
  84. });
  85. cy.screenshot(`${ssPrefix}create-template-close-modal`, {capture: 'viewport'});
  86. });
  87. it('PageDeleteModal is shown successfully', () => {
  88. cy.visit('/Sandbox/Bootstrap4');
  89. cy.get('#grw-subnav-container').within(() => {
  90. cy.getByTestid('open-page-item-control-btn').click();
  91. cy.getByTestid('open-page-delete-modal-btn').click();
  92. });
  93. cy.getByTestid('page-delete-modal').should('be.visible').screenshot(`${ssPrefix}-delete-bootstrap4`);
  94. });
  95. it('PageDuplicateModal is shown successfully', () => {
  96. cy.visit('/Sandbox/Bootstrap4', { });
  97. cy.get('#grw-subnav-container').within(() => {
  98. cy.getByTestid('open-page-item-control-btn').click();
  99. cy.getByTestid('open-page-duplicate-modal-btn').click();
  100. });
  101. cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
  102. });
  103. it('PageMoveRenameModal is shown successfully', () => {
  104. cy.visit('/Sandbox/Bootstrap4', { });
  105. cy.get('#grw-subnav-container').within(() => {
  106. cy.getByTestid('open-page-item-control-btn').click();
  107. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  108. });
  109. cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);
  110. });
  111. });
  112. context('Open presentation modal', () => {
  113. const ssPrefix = 'access-to-presentation-modal-';
  114. beforeEach(() => {
  115. // login
  116. cy.fixture("user-admin.json").then(user => {
  117. cy.login(user.username, user.password);
  118. });
  119. cy.collapseSidebar(true);
  120. });
  121. it('PresentationModal for "/" is shown successfully', () => {
  122. cy.visit('/');
  123. cy.get('#grw-subnav-container').within(() => {
  124. cy.getByTestid('open-page-item-control-btn').click({force: true});
  125. cy.getByTestid('open-presentation-modal-btn').click({force: true});
  126. });
  127. // eslint-disable-next-line cypress/no-unnecessary-waiting
  128. cy.wait(1500);
  129. cy.screenshot(`${ssPrefix}-open-top`);
  130. });
  131. });
  132. context('Page Accessories Modal', () => {
  133. const ssPrefix = 'access-to-page-accessories-modal';
  134. beforeEach(() => {
  135. // login
  136. cy.fixture("user-admin.json").then(user => {
  137. cy.login(user.username, user.password);
  138. });
  139. cy.collapseSidebar(true);
  140. });
  141. it('Page History is shown successfully', () => {
  142. cy.visit('/Sandbox/Bootstrap4', { });
  143. cy.get('#grw-subnav-container').within(() => {
  144. cy.getByTestid('open-page-item-control-btn').click();
  145. cy.getByTestid('open-page-accessories-modal-btn-with-history-tab').click();
  146. });
  147. cy.getByTestid('page-accessories-modal').should('be.visible')
  148. cy.getByTestid('page-history').should('be.visible')
  149. cy.screenshot(`${ssPrefix}-open-page-history-bootstrap4`);
  150. });
  151. it('Page Attachment Data is shown successfully', () => {
  152. cy.visit('/Sandbox/Bootstrap4', { });
  153. cy.get('#grw-subnav-container').within(() => {
  154. cy.getByTestid('open-page-item-control-btn').click();
  155. cy.getByTestid('open-page-accessories-modal-btn-with-attachment-data-tab').click();
  156. });
  157. cy.getByTestid('page-accessories-modal').should('be.visible')
  158. cy.getByTestid('page-attachment').should('be.visible')
  159. cy.screenshot(`${ssPrefix}-open-page-attachment-data-bootstrap4`);
  160. });
  161. it('Share Link Management is shown successfully', () => {
  162. cy.visit('/Sandbox/Bootstrap4', { });
  163. cy.get('#grw-subnav-container').within(() => {
  164. cy.getByTestid('open-page-item-control-btn').click();
  165. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').click();
  166. });
  167. cy.getByTestid('page-accessories-modal').should('be.visible');
  168. cy.getByTestid('share-link-management').should('be.visible');
  169. cy.screenshot(`${ssPrefix}-open-share-link-management-bootstrap4`);
  170. });
  171. });
  172. context('Tag Oprations', () =>{
  173. beforeEach(() => {
  174. // login
  175. cy.fixture("user-admin.json").then(user => {
  176. cy.login(user.username, user.password);
  177. });
  178. cy.collapseSidebar(true);
  179. });
  180. it('Successfully add new tag', () => {
  181. const ssPrefix = 'tag-operations-add-new-tag-'
  182. const tag = 'we';
  183. cy.visit('/');
  184. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click({force: true});
  185. cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
  186. cy.get('#edit-tag-modal').within(() => {
  187. cy.get('.rbt-input-main').type(tag, {force: true});
  188. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  189. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  190. cy.screenshot(`${ssPrefix}2-type-tag-name`);
  191. });
  192. cy.get('#edit-tag-modal').within(() => {
  193. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  194. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  195. cy.get('a#tag-typeahead-asynctypeahead-item-0').click({force: true})
  196. cy.screenshot(`${ssPrefix}3-insert-tag-name`, {capture: 'viewport'});
  197. });
  198. cy.get('#edit-tag-modal').within(() => {
  199. cy.get('div.modal-footer > button').click();
  200. });
  201. cy.get('.toast').should('be.visible').trigger('mouseover');
  202. cy.get('.grw-taglabels-container > form > a').contains(tag).should('exist');
  203. /* eslint-disable cypress/no-unnecessary-waiting */
  204. cy.wait(150); // wait for toastr to change its color occured by mouseover
  205. cy.screenshot(`${ssPrefix}4-click-done`, {capture: 'viewport'});
  206. });
  207. it('Successfully duplicate page by generated tag', () => {
  208. const ssPrefix = 'tag-operations-page-duplicate-';
  209. const tag = 'we';
  210. const newPageName = 'our';
  211. cy.visit('/');
  212. cy.get('.grw-taglabels-container > form > a').contains(tag).click();
  213. cy.getByTestid('search-result-base').should('be.visible');
  214. cy.getByTestid('search-result-list').should('be.visible');
  215. cy.getByTestid('search-result-content').should('be.visible');
  216. cy.get('#wiki').should('be.visible');
  217. cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
  218. cy.getByTestid('open-page-item-control-btn').first().click({force: true});
  219. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`, {capture: 'viewport'});
  220. cy.getByTestid('open-page-duplicate-modal-btn').first().click({force: true});
  221. cy.getByTestid('page-duplicate-modal').should('be.visible');
  222. cy.getByTestid('page-duplicate-modal').within(() => {
  223. cy.get('.rbt-input-main').type(newPageName, {force: true});
  224. }).screenshot(`${ssPrefix}3-duplicate-page`, {capture: 'viewport'});
  225. cy.getByTestid('page-duplicate-modal').within(() => {
  226. cy.get('.modal-footer > button.btn').click();
  227. });
  228. cy.visit(`/${newPageName}`);
  229. cy.get('#wiki').should('not.be.empty');
  230. cy.screenshot(`${ssPrefix}4-duplicated-page`, {capture: 'viewport'});
  231. });
  232. it('Successfully rename page from generated tag', () => {
  233. const ssPrefix = 'tag-operations-page-rename-';
  234. const tag = 'we';
  235. const oldPageName = '/our';
  236. const newPageName = '/ourus';
  237. cy.visit('/');
  238. cy.get('.grw-taglabels-container > form > a').contains(tag).click();
  239. cy.getByTestid('search-result-base').should('be.visible');
  240. cy.getByTestid('search-result-list').should('be.visible');
  241. cy.getByTestid('search-result-content').should('be.visible');
  242. cy.get('#wiki').should('be.visible');
  243. cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
  244. cy.getByTestid('search-result-list').within(() => {
  245. cy.get('.list-group-item').each(($row) => {
  246. if($row.find('a').text() === oldPageName){
  247. cy.wrap($row).within(() => {
  248. cy.getByTestid('open-page-item-control-btn').click();
  249. });
  250. }
  251. });
  252. });
  253. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`, {capture: 'viewport'});
  254. cy.getByTestid('search-result-list').within(() => {
  255. cy.get('.list-group-item').each(($row) => {
  256. if($row.find('a').text() === oldPageName){
  257. cy.wrap($row).within(() => {
  258. cy.getByTestid('open-page-move-rename-modal-btn').click();
  259. });
  260. }
  261. });
  262. });
  263. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  264. cy.get('.rbt-input-main').clear().type(newPageName,{force: true});
  265. }).screenshot(`${ssPrefix}3-insert-new-page-name`);
  266. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  267. cy.get('.modal-footer > button').click();
  268. });
  269. cy.visit(`/${newPageName}`);
  270. cy.getByTestid('grw-tag-labels').should('be.visible');
  271. cy.screenshot(`${ssPrefix}4-new-page-name-applied`, {capture: 'viewport'});
  272. });
  273. });