use-tools.spec.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  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. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  33. cy.screenshot(`${ssPrefix}new-page-modal-opened`);
  34. cy.get('button.close').click();
  35. });
  36. cy.screenshot(`${ssPrefix}page-create-modal-closed`);
  37. });
  38. it("Successfully Create Today's page", () => {
  39. const pageName = "Today's page";
  40. cy.visit('/');
  41. cy.waitUntilSkeletonDisappear();
  42. cy.getByTestid('newPageBtn').click();
  43. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  44. cy.get('.page-today-input2').type(pageName);
  45. cy.screenshot(`${ssPrefix}today-add-page-name`);
  46. cy.getByTestid('btn-create-memo').click();
  47. });
  48. cy.getByTestid('page-editor').should('be.visible');
  49. cy.getByTestid('save-page-btn').click();
  50. cy.get('.layout-root').should('not.have.class', 'editing');
  51. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  52. // eslint-disable-next-line cypress/no-unnecessary-waiting
  53. cy.wait(300);
  54. // Do not use "cy.waitUntilSkeletonDisappear()"
  55. cy.get('.grw-skeleton').should('not.exist');
  56. cy.screenshot(`${ssPrefix}create-today-page`);
  57. });
  58. it('Successfully create page under specific path', () => {
  59. const pageName = 'child';
  60. cy.visit('/Sandbox');
  61. cy.waitUntilSkeletonDisappear();
  62. cy.getByTestid('newPageBtn').click();
  63. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  64. cy.get('.rbt-input-main').type(pageName);
  65. cy.screenshot(`${ssPrefix}under-path-add-page-name`);
  66. cy.getByTestid('btn-create-page-under-below').click();
  67. });
  68. cy.getByTestid('page-editor').should('be.visible');
  69. cy.getByTestid('save-page-btn').click();
  70. cy.get('.layout-root').should('not.have.class', 'editing');
  71. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  72. // eslint-disable-next-line cypress/no-unnecessary-waiting
  73. cy.wait(300);
  74. // Do not use "cy.waitUntilSkeletonDisappear()"
  75. cy.get('.grw-skeleton').should('not.exist');
  76. cy.screenshot(`${ssPrefix}create-page-under-specific-page`);
  77. });
  78. it('Trying to create template page under the root page fail', () => {
  79. cy.visit('/');
  80. cy.waitUntilSkeletonDisappear();
  81. cy.getByTestid('newPageBtn').click();
  82. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  83. cy.getByTestid('grw-page-create-modal-path-name').should('have.text', '/');
  84. cy.get('#template-type').click();
  85. cy.get('#template-type').next().find('button:eq(0)').click({force: true});
  86. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  87. });
  88. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  89. cy.screenshot(`${ssPrefix}create-template-for-children-error`);
  90. cy.get('.toast-error').should('be.visible').click();
  91. cy.get('.toast-error').should('not.exist');
  92. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  93. cy.get('#template-type').click();
  94. cy.get('#template-type').next().find('button:eq(1)').click({force: true});
  95. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  96. });
  97. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  98. cy.screenshot(`${ssPrefix}create-template-for-descendants-error`);
  99. });
  100. it('PageDeleteModal is shown successfully', () => {
  101. cy.visit('/Sandbox/Bootstrap4');
  102. cy.waitUntilSkeletonDisappear();
  103. cy.get('#grw-subnav-container').within(() => {
  104. cy.getByTestid('open-page-item-control-btn').click({force: true});
  105. cy.getByTestid('open-page-delete-modal-btn').click({force: true});
  106. });
  107. cy.getByTestid('page-delete-modal').should('be.visible').screenshot(`${ssPrefix}-delete-bootstrap4`);
  108. });
  109. it('PageDuplicateModal is shown successfully', () => {
  110. cy.visit('/Sandbox/Bootstrap4');
  111. cy.waitUntilSkeletonDisappear();
  112. cy.get('#grw-subnav-container').within(() => {
  113. cy.getByTestid('open-page-item-control-btn').click({force: true});
  114. cy.getByTestid('open-page-duplicate-modal-btn').click({force: true});
  115. });
  116. cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
  117. });
  118. it('PageMoveRenameModal is shown successfully', () => {
  119. cy.visit('/Sandbox/Bootstrap4');
  120. cy.waitUntilSkeletonDisappear();
  121. cy.get('#grw-subnav-container').within(() => {
  122. cy.getByTestid('open-page-item-control-btn').click({force: true});
  123. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  124. });
  125. cy.getByTestid('grw-page-rename-button').should('be.disabled');
  126. cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);
  127. });
  128. });
  129. // TODO: Uncomment after https://redmine.weseek.co.jp/issues/103121 is resolved
  130. // context('Open presentation modal', () => {
  131. // const ssPrefix = 'access-to-presentation-modal-';
  132. // beforeEach(() => {
  133. // // login
  134. // cy.fixture("user-admin.json").then(user => {
  135. // cy.login(user.username, user.password);
  136. // });
  137. // cy.collapseSidebar(true);
  138. // });
  139. // it('PresentationModal for "/" is shown successfully', () => {
  140. // cy.visit('/');
  141. // cy.get('#grw-subnav-container').within(() => {
  142. // cy.getByTestid('open-page-item-control-btn').click({force: true});
  143. // cy.getByTestid('open-presentation-modal-btn').click({force: true});
  144. // });
  145. // // eslint-disable-next-line cypress/no-unnecessary-waiting
  146. // cy.wait(1500);
  147. // cy.screenshot(`${ssPrefix}-open-top`);
  148. // });
  149. // });
  150. context('Page Accessories Modal', () => {
  151. const ssPrefix = 'access-to-page-accessories-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('Page History is shown successfully', () => {
  160. cy.visit('/Sandbox/Bootstrap4');
  161. cy.waitUntilSkeletonDisappear();
  162. cy.get('#grw-subnav-container').within(() => {
  163. cy.getByTestid('open-page-item-control-btn').within(() => {
  164. cy.get('button.btn-page-item-control').click({force: true});
  165. });
  166. cy.getByTestid('open-page-accessories-modal-btn-with-history-tab').click({force: true});
  167. });
  168. cy.getByTestid('page-history').should('be.visible')
  169. cy.screenshot(`${ssPrefix}-open-page-history-bootstrap4`);
  170. });
  171. it('Page Attachment Data is shown successfully', () => {
  172. cy.visit('/Sandbox/Bootstrap4');
  173. cy.waitUntilSkeletonDisappear();
  174. cy.get('#grw-subnav-container').within(() => {
  175. cy.getByTestid('open-page-item-control-btn').should('be.visible');
  176. cy.getByTestid('open-page-item-control-btn').within(() => {
  177. cy.get('button.btn-page-item-control').click({force: true});
  178. cy.getByTestid('page-item-control-menu').should('be.visible');
  179. cy.getByTestid('open-page-accessories-modal-btn-with-attachment-data-tab').click();
  180. });
  181. });
  182. cy.getByTestid('page-accessories-modal').should('be.visible')
  183. cy.getByTestid('page-attachment').should('be.visible')
  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-taglabels-container').within(()=>{
  247. cy.get('.grw-tag-labels').within(()=>{
  248. cy.get('a').then(($el)=>{
  249. cy.wrap($el).contains(tag).click();
  250. });
  251. });
  252. });
  253. // Search result page
  254. cy.getByTestid('search-result-base').should('be.visible');
  255. cy.getByTestid('search-result-list').should('be.visible');
  256. cy.getByTestid('search-result-content').should('be.visible');
  257. cy.get('#revision-loader').should('be.visible');
  258. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  259. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  260. cy.screenshot(`${ssPrefix}1-click-tag-name`);
  261. cy.getByTestid('search-result-list').should('be.visible').then(($el)=>{
  262. cy.wrap($el).within(()=>{
  263. cy.getByTestid('open-page-item-control-btn').first().click();
  264. });
  265. // eslint-disable-next-line cypress/no-unnecessary-waiting
  266. cy.wait(1500); // for wait rendering pagelist info
  267. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`);
  268. cy.wrap($el).within(()=>{
  269. cy.getByTestid('open-page-item-control-btn').first().within(()=>{
  270. cy.getByTestid('open-page-duplicate-modal-btn').click();
  271. })
  272. });
  273. })
  274. cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
  275. cy.get('.rbt-input-main').type(`-${newPageName}`, {force: true});
  276. }).screenshot(`${ssPrefix}3-duplicate-page`);
  277. cy.getByTestid('page-duplicate-modal').within(() => {
  278. cy.get('.modal-footer > button.btn').click();
  279. });
  280. cy.visit(`Sandbox-${newPageName}`);
  281. cy.waitUntilSkeletonDisappear();
  282. cy.screenshot(`${ssPrefix}4-duplicated-page`);
  283. });
  284. it('Successfully rename page from generated tag', () => {
  285. const ssPrefix = 'tag-operations-page-rename-';
  286. const tag = 'we';
  287. const oldPageName = '/Sandbox-our';
  288. const newPageName = '/Sandbox-us';
  289. cy.visit('/Sandbox-our');
  290. cy.waitUntilSkeletonDisappear();
  291. // Search result page
  292. cy.get('.grw-tag-label').should('be.visible').contains(tag).click();
  293. cy.getByTestid('search-result-base').should('be.visible');
  294. cy.getByTestid('search-result-list').should('be.visible');
  295. cy.getByTestid('search-result-content').should('be.visible');
  296. cy.get('#revision-loader').should('be.visible');
  297. // eslint-disable-next-line cypress/no-unnecessary-waiting
  298. cy.wait(300);
  299. cy.screenshot(`${ssPrefix}1-click-tag-name`);
  300. cy.getByTestid('search-result-list').within(() => {
  301. cy.get('.list-group-item').each(($row) => {
  302. if($row.find('a').text() === oldPageName){
  303. cy.wrap($row).within(() => {
  304. cy.getByTestid('open-page-item-control-btn').first().click();
  305. cy.getByTestid('page-item-control-menu').should('have.class', 'show').then(() => {
  306. // empty sentence in page list empty: https://github.com/weseek/growi/pull/6880
  307. cy.getByTestid('revision-short-body-in-page-list-item-L').invoke('text', '');
  308. });
  309. cy.getByTestid('page-item-control-menu').within(()=>{
  310. cy.getByTestid('open-page-delete-modal-btn');
  311. cy.screenshot(`${ssPrefix}2-open-page-item-control-menu`);
  312. })
  313. });
  314. }
  315. });
  316. });
  317. cy.getByTestid('search-result-list').within(() => {
  318. cy.get('.list-group-item').each(($row) => {
  319. if($row.find('a').text() === oldPageName){
  320. cy.wrap($row).within(() => {
  321. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  322. });
  323. }
  324. });
  325. });
  326. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  327. cy.get('.rbt-input-main').clear().type(newPageName,{force: true});
  328. }).screenshot(`${ssPrefix}3-insert-new-page-name`);
  329. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  330. cy.get('.modal-footer > button').click();
  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. });