use-tools.spec.ts 12 KB

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