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

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