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

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