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

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