use-tools.spec.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  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.waitUntilSkeletonDisappear();
  13. cy.getByTestid('grw-sidebar-nav-primary-page-tree').click();
  14. // eslint-disable-next-line cypress/no-unnecessary-waiting
  15. cy.wait(1500);
  16. cy.screenshot(`${ssPrefix}-pagetree-after-load`);
  17. });
  18. });
  19. context('Modal for page operation', () => {
  20. const ssPrefix = 'modal-for-page-operation-';
  21. beforeEach(() => {
  22. // login
  23. cy.fixture("user-admin.json").then(user => {
  24. cy.login(user.username, user.password);
  25. });
  26. cy.collapseSidebar(true);
  27. });
  28. it("PageCreateModal is shown and closed successfully", () => {
  29. cy.visit('/');
  30. cy.waitUntilSkeletonDisappear();
  31. cy.getByTestid('newPageBtn').click();
  32. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  33. cy.screenshot(`${ssPrefix}new-page-modal-opened`);
  34. cy.get('button.close').click();
  35. });
  36. cy.screenshot(`${ssPrefix}page-create-modal-closed`);
  37. });
  38. it("Successfully Create Today's page", () => {
  39. const pageName = "Today's page";
  40. cy.visit('/');
  41. cy.waitUntilSkeletonDisappear();
  42. cy.getByTestid('newPageBtn').click();
  43. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  44. cy.get('.page-today-input2').type(pageName);
  45. cy.screenshot(`${ssPrefix}today-add-page-name`);
  46. cy.getByTestid('btn-create-memo').click();
  47. });
  48. cy.getByTestid('page-editor').should('be.visible');
  49. cy.getByTestid('save-page-btn').click();
  50. cy.get('.layout-root').should('not.have.class', 'editing');
  51. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  52. // eslint-disable-next-line cypress/no-unnecessary-waiting
  53. cy.wait(300);
  54. // Do not use "cy.waitUntilSkeletonDisappear()"
  55. cy.get('.grw-skeleton').should('not.exist');
  56. cy.screenshot(`${ssPrefix}create-today-page`);
  57. });
  58. it('Successfully create page under specific path', () => {
  59. const pageName = 'child';
  60. cy.visit('/Sandbox');
  61. cy.waitUntilSkeletonDisappear();
  62. cy.getByTestid('newPageBtn').click();
  63. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  64. cy.get('.rbt-input-main').should('have.value', '/Sandbox/');
  65. cy.get('.rbt-input-main').type(pageName);
  66. cy.screenshot(`${ssPrefix}under-path-add-page-name`);
  67. cy.getByTestid('btn-create-page-under-below').click();
  68. });
  69. cy.getByTestid('page-editor').should('be.visible');
  70. cy.getByTestid('save-page-btn').click();
  71. cy.get('.layout-root').should('not.have.class', 'editing');
  72. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  73. // eslint-disable-next-line cypress/no-unnecessary-waiting
  74. cy.wait(300);
  75. // Do not use "cy.waitUntilSkeletonDisappear()"
  76. cy.get('.grw-skeleton').should('not.exist');
  77. cy.screenshot(`${ssPrefix}create-page-under-specific-page`);
  78. });
  79. it('Trying to create template page under the root page fail', () => {
  80. cy.visit('/');
  81. cy.waitUntilSkeletonDisappear();
  82. cy.getByTestid('newPageBtn').click();
  83. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  84. cy.getByTestid('grw-page-create-modal-path-name').should('have.text', '/');
  85. cy.get('#template-type').click();
  86. cy.get('#template-type').next().find('button:eq(0)').click({force: true});
  87. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  88. });
  89. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  90. cy.screenshot(`${ssPrefix}create-template-for-children-error`);
  91. cy.get('.toast-error').should('be.visible').click();
  92. cy.get('.toast-error').should('not.exist');
  93. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  94. cy.get('#template-type').click();
  95. cy.get('#template-type').next().find('button:eq(1)').click({force: true});
  96. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  97. });
  98. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  99. cy.screenshot(`${ssPrefix}create-template-for-descendants-error`);
  100. });
  101. it('PageDeleteModal is shown successfully', () => {
  102. cy.visit('/Sandbox/Bootstrap4');
  103. cy.waitUntilSkeletonDisappear();
  104. cy.get('#grw-subnav-container').within(() => {
  105. cy.getByTestid('open-page-item-control-btn').click({force: true});
  106. cy.getByTestid('open-page-delete-modal-btn').click({force: true});
  107. });
  108. cy.getByTestid('page-delete-modal').should('be.visible').screenshot(`${ssPrefix}-delete-bootstrap4`);
  109. });
  110. it('PageDuplicateModal is shown successfully', () => {
  111. cy.visit('/Sandbox/Bootstrap4');
  112. cy.waitUntilSkeletonDisappear();
  113. cy.get('#grw-subnav-container').within(() => {
  114. cy.getByTestid('open-page-item-control-btn').click({force: true});
  115. cy.getByTestid('open-page-duplicate-modal-btn').click({force: true});
  116. });
  117. cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
  118. });
  119. it('PageMoveRenameModal is shown successfully', () => {
  120. cy.visit('/Sandbox/Bootstrap4');
  121. cy.waitUntilSkeletonDisappear();
  122. cy.get('#grw-subnav-container').within(() => {
  123. cy.getByTestid('open-page-item-control-btn').click({force: true});
  124. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  125. });
  126. cy.getByTestid('grw-page-rename-button').should('be.disabled');
  127. cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);
  128. });
  129. });
  130. // TODO: Uncomment after https://redmine.weseek.co.jp/issues/103121 is resolved
  131. // context('Open presentation modal', () => {
  132. // const ssPrefix = 'access-to-presentation-modal-';
  133. // beforeEach(() => {
  134. // // login
  135. // cy.fixture("user-admin.json").then(user => {
  136. // cy.login(user.username, user.password);
  137. // });
  138. // cy.collapseSidebar(true);
  139. // });
  140. // it('PresentationModal for "/" is shown successfully', () => {
  141. // cy.visit('/');
  142. // cy.get('#grw-subnav-container').within(() => {
  143. // cy.getByTestid('open-page-item-control-btn').click({force: true});
  144. // cy.getByTestid('open-presentation-modal-btn').click({force: true});
  145. // });
  146. // // eslint-disable-next-line cypress/no-unnecessary-waiting
  147. // cy.wait(1500);
  148. // cy.screenshot(`${ssPrefix}-open-top`);
  149. // });
  150. // });
  151. context('Page Accessories Modal', () => {
  152. const ssPrefix = 'access-to-page-accessories-modal';
  153. beforeEach(() => {
  154. // login
  155. cy.fixture("user-admin.json").then(user => {
  156. cy.login(user.username, user.password);
  157. });
  158. cy.collapseSidebar(true);
  159. });
  160. it('Page History is shown successfully', () => {
  161. cy.visit('/Sandbox/Bootstrap4');
  162. cy.waitUntilSkeletonDisappear();
  163. cy.get('#grw-subnav-container').within(() => {
  164. cy.getByTestid('open-page-item-control-btn').within(() => {
  165. cy.get('button.btn-page-item-control').click({force: true});
  166. });
  167. cy.getByTestid('open-page-accessories-modal-btn-with-history-tab').click({force: true});
  168. });
  169. cy.getByTestid('page-history').should('be.visible')
  170. cy.screenshot(`${ssPrefix}-open-page-history-bootstrap4`);
  171. });
  172. it('Page Attachment Data is shown successfully', () => {
  173. cy.visit('/Sandbox/Bootstrap4');
  174. cy.waitUntilSkeletonDisappear();
  175. cy.get('#grw-subnav-container').within(() => {
  176. cy.getByTestid('open-page-item-control-btn').within(() => {
  177. cy.get('button.btn-page-item-control').click({force: true});
  178. });
  179. cy.getByTestid('open-page-accessories-modal-btn-with-attachment-data-tab').click({force: true});
  180. });
  181. cy.getByTestid('page-attachment').should('be.visible').contains('No attachments yet.');
  182. cy.screenshot(`${ssPrefix}-open-page-attachment-data-bootstrap4`);
  183. });
  184. it('Share Link Management is shown successfully', () => {
  185. cy.visit('/Sandbox/Bootstrap4');
  186. cy.waitUntilSkeletonDisappear();
  187. cy.get('#grw-subnav-container').within(() => {
  188. cy.getByTestid('open-page-item-control-btn').within(() => {
  189. cy.get('button.btn-page-item-control').click({force: true});
  190. });
  191. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').should('be.visible');
  192. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').click();
  193. });
  194. cy.getByTestid('page-accessories-modal').should('be.visible');
  195. cy.getByTestid('share-link-management').should('be.visible');
  196. cy.screenshot(`${ssPrefix}-open-share-link-management-bootstrap4`);
  197. });
  198. });
  199. context('Tag Oprations', { scrollBehavior: false }, () =>{
  200. beforeEach(() => {
  201. // login
  202. cy.fixture("user-admin.json").then(user => {
  203. cy.login(user.username, user.password);
  204. });
  205. cy.collapseSidebar(true);
  206. });
  207. it('Successfully add new tag', () => {
  208. const ssPrefix = 'tag-operations-add-new-tag-'
  209. const tag = 'we';
  210. cy.visit('/Sandbox');
  211. cy.waitUntilSkeletonDisappear();
  212. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').should('be.visible');
  213. // eslint-disable-next-line cypress/no-unnecessary-waiting
  214. cy.wait(200);
  215. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click();
  216. cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
  217. cy.get('#edit-tag-modal').within(() => {
  218. cy.get('.rbt-input-main').type(tag, {force: true});
  219. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  220. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  221. cy.screenshot(`${ssPrefix}2-type-tag-name`);
  222. });
  223. cy.get('#edit-tag-modal').within(() => {
  224. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  225. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  226. cy.get('a#tag-typeahead-asynctypeahead-item-0').click({force: true})
  227. cy.screenshot(`${ssPrefix}3-insert-tag-name`);
  228. });
  229. cy.get('#edit-tag-modal').within(() => {
  230. cy.get('div.modal-footer > button').click();
  231. });
  232. cy.get('.toast').should('be.visible').trigger('mouseover');
  233. cy.get('.grw-taglabels-container > .grw-tag-labels > a').contains(tag).should('exist');
  234. /* eslint-disable cypress/no-unnecessary-waiting */
  235. cy.wait(150); // wait for toastr to change its color occured by mouseover
  236. cy.screenshot(`${ssPrefix}4-click-done`);
  237. });
  238. it('Successfully duplicate page by generated tag', () => {
  239. const ssPrefix = 'tag-operations-page-duplicate-';
  240. const tag = 'we';
  241. const newPageName = 'our';
  242. cy.visit('/Sandbox');
  243. cy.waitUntilSkeletonDisappear();
  244. cy.get('.grw-taglabels-container').within(()=>{
  245. cy.get('.grw-tag-labels').within(()=>{
  246. cy.get('a').then(($el)=>{
  247. cy.wrap($el).contains(tag).click();
  248. });
  249. });
  250. });
  251. // Search result page
  252. cy.getByTestid('search-result-base').should('be.visible');
  253. cy.getByTestid('search-result-list').should('be.visible');
  254. cy.getByTestid('search-result-content').should('be.visible');
  255. cy.get('#revision-loader').should('be.visible').contains('Block Elements');
  256. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  257. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  258. cy.screenshot(`${ssPrefix}1-click-tag-name`);
  259. cy.getByTestid('search-result-list').should('be.visible').then(($el)=>{
  260. cy.wrap($el).within(()=>{
  261. cy.getByTestid('open-page-item-control-btn').first().click();
  262. });
  263. // eslint-disable-next-line cypress/no-unnecessary-waiting
  264. cy.wait(1500); // for wait rendering pagelist info
  265. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`);
  266. cy.wrap($el).within(()=>{
  267. cy.getByTestid('open-page-item-control-btn').first().within(()=>{
  268. cy.getByTestid('open-page-duplicate-modal-btn').click();
  269. })
  270. });
  271. })
  272. cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
  273. cy.get('.rbt-input-main').type(`-${newPageName}`, {force: true});
  274. }).screenshot(`${ssPrefix}3-duplicate-page`);
  275. cy.getByTestid('page-duplicate-modal').within(() => {
  276. cy.intercept('POST', '/_api/v3/pages/duplicate').as('duplicate');
  277. cy.get('.modal-footer > button.btn').click();
  278. // Wait for completion of request to '/_api/v3/pages/duplicate'
  279. cy.wait('@duplicate')
  280. });
  281. cy.visit(`Sandbox-${newPageName}`);
  282. cy.waitUntilSkeletonDisappear();
  283. cy.screenshot(`${ssPrefix}4-duplicated-page`);
  284. });
  285. it('Successfully rename page from generated tag', () => {
  286. const ssPrefix = 'tag-operations-page-rename-';
  287. const tag = 'we';
  288. const oldPageName = '/Sandbox-our';
  289. const newPageName = '/Sandbox-us';
  290. cy.visit(oldPageName);
  291. cy.waitUntilSkeletonDisappear();
  292. cy.get('.grw-tag-label').should('be.visible').contains(tag).click();
  293. // Search result page
  294. cy.getByTestid('search-result-base').should('be.visible');
  295. cy.getByTestid('search-result-list').should('be.visible');
  296. cy.getByTestid('search-result-content').should('be.visible');
  297. cy.get('#revision-loader').should('be.visible').contains('Block Elements');
  298. // eslint-disable-next-line cypress/no-unnecessary-waiting
  299. cy.wait(300);
  300. cy.screenshot(`${ssPrefix}1-click-tag-name`);
  301. cy.getByTestid('search-result-list').within(() => {
  302. cy.get('.list-group-item').each(($row) => {
  303. if($row.find('a').text() === oldPageName){
  304. cy.wrap($row).within(() => {
  305. cy.getByTestid('open-page-item-control-btn').first().click();
  306. cy.getByTestid('page-item-control-menu').should('have.class', 'show').then(() => {
  307. // empty sentence in page list empty: https://github.com/weseek/growi/pull/6880
  308. cy.getByTestid('revision-short-body-in-page-list-item-L').invoke('text', '');
  309. });
  310. cy.getByTestid('page-item-control-menu').within(()=>{
  311. cy.getByTestid('open-page-delete-modal-btn');
  312. cy.screenshot(`${ssPrefix}2-open-page-item-control-menu`);
  313. })
  314. });
  315. }
  316. });
  317. });
  318. cy.getByTestid('search-result-list').within(() => {
  319. cy.get('.list-group-item').each(($row) => {
  320. if($row.find('a').text() === oldPageName){
  321. cy.wrap($row).within(() => {
  322. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  323. });
  324. }
  325. });
  326. });
  327. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  328. cy.get('.rbt-input-main').clear().type(newPageName,{force: true});
  329. }).screenshot(`${ssPrefix}3-insert-new-page-name`);
  330. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  331. cy.intercept('PUT', '/_api/v3/pages/rename').as('rename');
  332. cy.getByTestid('grw-page-rename-button').should('not.be.disabled').click();
  333. // Wait for completion of request to '/_api/v3/pages/rename'
  334. cy.wait('@rename')
  335. });
  336. cy.visit(newPageName);
  337. cy.waitUntilSkeletonDisappear();
  338. cy.getByTestid('grw-tag-labels').should('be.visible')
  339. cy.screenshot(`${ssPrefix}4-new-page-name-applied`);
  340. });
  341. });