20-basic-features--use-tools.spec.ts 17 KB

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