use-tools.spec.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  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.getByTestid('grw-sidebar-nav-primary-page-tree').click();
  13. // eslint-disable-next-line cypress/no-unnecessary-waiting
  14. cy.wait(1500);
  15. cy.screenshot(`${ssPrefix}-pagetree-after-load`);
  16. });
  17. });
  18. context('Modal for page operation', () => {
  19. const ssPrefix = 'modal-for-page-operation-';
  20. beforeEach(() => {
  21. // login
  22. cy.fixture("user-admin.json").then(user => {
  23. cy.login(user.username, user.password);
  24. });
  25. cy.collapseSidebar(true);
  26. });
  27. it("PageCreateModal is shown and closed successfully", () => {
  28. cy.visit('/');
  29. cy.waitUntilSkeletonDisappear();
  30. cy.getByTestid('newPageBtn').click();
  31. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  32. cy.screenshot(`${ssPrefix}new-page-modal-opened`);
  33. cy.get('button.close').click();
  34. });
  35. cy.screenshot(`${ssPrefix}page-create-modal-closed`);
  36. });
  37. it("Successfully Create Today's page", () => {
  38. const pageName = "Today's page";
  39. cy.visit('/');
  40. cy.waitUntilSkeletonDisappear();
  41. cy.getByTestid('newPageBtn').click();
  42. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  43. cy.get('.page-today-input2').type(pageName);
  44. cy.screenshot(`${ssPrefix}today-add-page-name`);
  45. cy.getByTestid('btn-create-memo').click();
  46. });
  47. cy.getByTestid('page-editor').should('be.visible');
  48. cy.getByTestid('save-page-btn').click();
  49. cy.get('.layout-root').should('not.have.class', 'editing');
  50. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  51. cy.waitUntilSkeletonDisappear();
  52. cy.screenshot(`${ssPrefix}create-today-page`);
  53. });
  54. it('Successfully create page under specific path', () => {
  55. const pageName = 'child';
  56. cy.visit('/SandBox');
  57. cy.waitUntilSkeletonDisappear();
  58. cy.getByTestid('newPageBtn').click();
  59. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  60. cy.get('.rbt-input-main').type(pageName);
  61. cy.screenshot(`${ssPrefix}under-path-add-page-name`);
  62. cy.getByTestid('btn-create-page-under-below').click();
  63. });
  64. cy.getByTestid('page-editor').should('be.visible');
  65. cy.getByTestid('save-page-btn').click();
  66. cy.get('.layout-root').should('not.have.class', 'editing');
  67. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  68. cy.waitUntilSkeletonDisappear();
  69. cy.screenshot(`${ssPrefix}create-page-under-specific-page`);
  70. });
  71. it('Trying to create template page under the root page fail', () => {
  72. cy.visit('/');
  73. cy.waitUntilSkeletonDisappear();
  74. cy.getByTestid('newPageBtn').click();
  75. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  76. cy.getByTestid('grw-page-create-modal-path-name').should('have.text', '/');
  77. cy.get('#template-type').click();
  78. cy.get('#template-type').next().find('button:eq(0)').click({force: true});
  79. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  80. });
  81. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  82. cy.screenshot(`${ssPrefix}create-template-for-children-error`);
  83. cy.get('.toast-error').should('be.visible').click();
  84. cy.get('.toast-error').should('not.exist');
  85. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  86. cy.get('#template-type').click();
  87. cy.get('#template-type').next().find('button:eq(1)').click({force: true});
  88. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  89. });
  90. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  91. cy.screenshot(`${ssPrefix}create-template-for-descendants-error`);
  92. });
  93. it('PageDeleteModal is shown successfully', () => {
  94. cy.visit('/Sandbox/Bootstrap4');
  95. cy.get('#grw-subnav-container').within(() => {
  96. cy.getByTestid('open-page-item-control-btn').click({force: true});
  97. cy.getByTestid('open-page-delete-modal-btn').click({force: true});
  98. });
  99. cy.getByTestid('page-delete-modal').should('be.visible').screenshot(`${ssPrefix}-delete-bootstrap4`);
  100. });
  101. it('PageDuplicateModal is shown successfully', () => {
  102. cy.visit('/Sandbox/Bootstrap4', { });
  103. cy.get('#grw-subnav-container').within(() => {
  104. cy.getByTestid('open-page-item-control-btn').click({force: true});
  105. cy.getByTestid('open-page-duplicate-modal-btn').click({force: true});
  106. });
  107. cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
  108. });
  109. it('PageMoveRenameModal 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-move-rename-modal-btn').click({force: true});
  115. });
  116. cy.getByTestid('grw-page-rename-button').should('be.disabled');
  117. cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);
  118. });
  119. });
  120. // TODO: Uncomment after https://redmine.weseek.co.jp/issues/103121 is resolved
  121. // context('Open presentation modal', () => {
  122. // const ssPrefix = 'access-to-presentation-modal-';
  123. // beforeEach(() => {
  124. // // login
  125. // cy.fixture("user-admin.json").then(user => {
  126. // cy.login(user.username, user.password);
  127. // });
  128. // cy.collapseSidebar(true);
  129. // });
  130. // it('PresentationModal for "/" is shown successfully', () => {
  131. // cy.visit('/');
  132. // cy.get('#grw-subnav-container').within(() => {
  133. // cy.getByTestid('open-page-item-control-btn').click({force: true});
  134. // cy.getByTestid('open-presentation-modal-btn').click({force: true});
  135. // });
  136. // // eslint-disable-next-line cypress/no-unnecessary-waiting
  137. // cy.wait(1500);
  138. // cy.screenshot(`${ssPrefix}-open-top`);
  139. // });
  140. // });
  141. context('Page Accessories Modal', () => {
  142. const ssPrefix = 'access-to-page-accessories-modal';
  143. beforeEach(() => {
  144. // login
  145. cy.fixture("user-admin.json").then(user => {
  146. cy.login(user.username, user.password);
  147. });
  148. cy.collapseSidebar(true);
  149. });
  150. it('Page History is shown successfully', () => {
  151. cy.visit('/Sandbox/Bootstrap4');
  152. cy.get('#grw-subnav-container').within(() => {
  153. cy.getByTestid('open-page-item-control-btn').within(() => {
  154. cy.get('button.btn-page-item-control').click({force: true});
  155. });
  156. cy.getByTestid('open-page-accessories-modal-btn-with-history-tab').click({force: true});
  157. });
  158. cy.getByTestid('page-history').should('be.visible')
  159. cy.screenshot(`${ssPrefix}-open-page-history-bootstrap4`);
  160. });
  161. it('Page Attachment Data is shown successfully', () => {
  162. cy.visit('/Sandbox/Bootstrap4');
  163. cy.waitUntilSkeletonDisappear();
  164. cy.get('#grw-subnav-container').within(() => {
  165. cy.getByTestid('open-page-item-control-btn').should('be.visible');
  166. cy.getByTestid('open-page-item-control-btn').within(() => {
  167. cy.get('button.btn-page-item-control').click({force: true});
  168. cy.getByTestid('page-item-control-menu').should('be.visible');
  169. cy.getByTestid('open-page-accessories-modal-btn-with-attachment-data-tab').click();
  170. });
  171. });
  172. cy.getByTestid('page-accessories-modal').should('be.visible')
  173. cy.getByTestid('page-attachment').should('be.visible')
  174. cy.screenshot(`${ssPrefix}-open-page-attachment-data-bootstrap4`);
  175. });
  176. it('Share Link Management is shown successfully', () => {
  177. cy.visit('/Sandbox/Bootstrap4', { });
  178. cy.get('#grw-subnav-container').within(() => {
  179. cy.getByTestid('open-page-item-control-btn').within(() => {
  180. cy.get('button.btn-page-item-control').click({force: true});
  181. });
  182. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').should('be.visible');
  183. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').click();
  184. });
  185. cy.getByTestid('page-accessories-modal').should('be.visible');
  186. cy.getByTestid('share-link-management').should('be.visible');
  187. cy.screenshot(`${ssPrefix}-open-share-link-management-bootstrap4`);
  188. });
  189. });
  190. context('Tag Oprations', { scrollBehavior: false }, () =>{
  191. beforeEach(() => {
  192. // login
  193. cy.fixture("user-admin.json").then(user => {
  194. cy.login(user.username, user.password);
  195. });
  196. cy.collapseSidebar(true);
  197. });
  198. it('Successfully add new tag', () => {
  199. const ssPrefix = 'tag-operations-add-new-tag-'
  200. const tag = 'we';
  201. cy.visit('/Sandbox');
  202. cy.waitUntilSkeletonDisappear();
  203. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').should('be.visible');
  204. // eslint-disable-next-line cypress/no-unnecessary-waiting
  205. cy.wait(200);
  206. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click();
  207. cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
  208. cy.get('#edit-tag-modal').within(() => {
  209. cy.get('.rbt-input-main').type(tag, {force: true});
  210. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  211. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  212. cy.screenshot(`${ssPrefix}2-type-tag-name`);
  213. });
  214. cy.get('#edit-tag-modal').within(() => {
  215. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  216. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  217. cy.get('a#tag-typeahead-asynctypeahead-item-0').click({force: true})
  218. cy.screenshot(`${ssPrefix}3-insert-tag-name`);
  219. });
  220. cy.get('#edit-tag-modal').within(() => {
  221. cy.get('div.modal-footer > button').click();
  222. });
  223. cy.get('.toast').should('be.visible').trigger('mouseover');
  224. cy.get('.grw-taglabels-container > .grw-tag-labels > a').contains(tag).should('exist');
  225. /* eslint-disable cypress/no-unnecessary-waiting */
  226. cy.wait(150); // wait for toastr to change its color occured by mouseover
  227. cy.screenshot(`${ssPrefix}4-click-done`);
  228. });
  229. it('Successfully duplicate page by generated tag', () => {
  230. const ssPrefix = 'tag-operations-page-duplicate-';
  231. const tag = 'we';
  232. const newPageName = 'our';
  233. cy.visit('/Sandbox');
  234. cy.waitUntilSkeletonDisappear();
  235. cy.get('.grw-taglabels-container').within(()=>{
  236. cy.get('.grw-tag-labels').within(()=>{
  237. cy.get('a').then(($el)=>{
  238. cy.wrap($el).contains(tag).click();
  239. });
  240. });
  241. });
  242. // Search result page
  243. cy.getByTestid('search-result-base').should('be.visible');
  244. cy.getByTestid('search-result-list').should('be.visible');
  245. cy.getByTestid('search-result-content').should('be.visible');
  246. cy.get('#revision-loader').should('be.visible');
  247. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  248. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  249. cy.screenshot(`${ssPrefix}1-click-tag-name`);
  250. cy.getByTestid('search-result-list').should('be.visible').then(($el)=>{
  251. cy.wrap($el).within(()=>{
  252. cy.getByTestid('open-page-item-control-btn').first().click();
  253. });
  254. // eslint-disable-next-line cypress/no-unnecessary-waiting
  255. cy.wait(1500); // for wait rendering pagelist info
  256. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`);
  257. cy.wrap($el).within(()=>{
  258. cy.getByTestid('open-page-item-control-btn').first().within(()=>{
  259. cy.getByTestid('open-page-duplicate-modal-btn').click();
  260. })
  261. });
  262. })
  263. cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
  264. cy.get('.rbt-input-main').type(`-${newPageName}`, {force: true});
  265. }).screenshot(`${ssPrefix}3-duplicate-page`);
  266. cy.getByTestid('page-duplicate-modal').within(() => {
  267. cy.get('.modal-footer > button.btn').click();
  268. });
  269. cy.visit(`Sandbox-${newPageName}`);
  270. cy.waitUntilSkeletonDisappear();
  271. cy.screenshot(`${ssPrefix}4-duplicated-page`);
  272. });
  273. it('Successfully rename page from generated tag', () => {
  274. const ssPrefix = 'tag-operations-page-rename-';
  275. const tag = 'we';
  276. const oldPageName = '/Sandbox-our';
  277. const newPageName = '/Sandbox-us';
  278. cy.visit('/Sandbox-our');
  279. cy.waitUntilSkeletonDisappear();
  280. // Search result page
  281. cy.get('.grw-tag-label').should('be.visible').contains(tag).click();
  282. cy.getByTestid('search-result-base').should('be.visible');
  283. cy.getByTestid('search-result-list').should('be.visible');
  284. cy.getByTestid('search-result-content').should('be.visible');
  285. cy.get('#revision-loader').should('be.visible');
  286. // eslint-disable-next-line cypress/no-unnecessary-waiting
  287. cy.wait(300);
  288. cy.screenshot(`${ssPrefix}1-click-tag-name`);
  289. cy.getByTestid('search-result-list').within(() => {
  290. cy.get('.list-group-item').each(($row) => {
  291. if($row.find('a').text() === oldPageName){
  292. cy.wrap($row).within(() => {
  293. cy.getByTestid('open-page-item-control-btn').first().click();
  294. cy.getByTestid('page-item-control-menu').should('have.class', 'show').then(() => {
  295. // empty sentence in page list empty: https://github.com/weseek/growi/pull/6880
  296. cy.getByTestid('revision-short-body-in-page-list-item-L').invoke('text', '');
  297. });
  298. cy.getByTestid('page-item-control-menu').within(()=>{
  299. cy.getByTestid('open-page-delete-modal-btn');
  300. cy.screenshot(`${ssPrefix}2-open-page-item-control-menu`);
  301. })
  302. });
  303. }
  304. });
  305. });
  306. cy.getByTestid('search-result-list').within(() => {
  307. cy.get('.list-group-item').each(($row) => {
  308. if($row.find('a').text() === oldPageName){
  309. cy.wrap($row).within(() => {
  310. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  311. });
  312. }
  313. });
  314. });
  315. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  316. cy.get('.rbt-input-main').clear().type(newPageName,{force: true});
  317. }).screenshot(`${ssPrefix}3-insert-new-page-name`);
  318. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  319. cy.get('.modal-footer > button').click();
  320. });
  321. cy.visit(newPageName);
  322. cy.waitUntilSkeletonDisappear();
  323. cy.getByTestid('grw-tag-labels').should('be.visible')
  324. cy.screenshot(`${ssPrefix}4-new-page-name-applied`);
  325. });
  326. });