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

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