use-tools.spec.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  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`, { capture: 'viewport' });
  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`, {capture: 'viewport'});
  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`, {capture: 'viewport'});
  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`, {capture: 'viewport'});
  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. context('Open presentation modal', () => {
  121. const ssPrefix = 'access-to-presentation-modal-';
  122. beforeEach(() => {
  123. // login
  124. cy.fixture("user-admin.json").then(user => {
  125. cy.login(user.username, user.password);
  126. });
  127. cy.collapseSidebar(true);
  128. });
  129. it('PresentationModal for "/" is shown successfully', () => {
  130. cy.visit('/');
  131. cy.get('#grw-subnav-container').within(() => {
  132. cy.getByTestid('open-page-item-control-btn').click({force: true});
  133. cy.getByTestid('open-presentation-modal-btn').click({force: true});
  134. });
  135. // eslint-disable-next-line cypress/no-unnecessary-waiting
  136. cy.wait(1500);
  137. cy.screenshot(`${ssPrefix}-open-top`);
  138. });
  139. });
  140. context('Page Accessories Modal', () => {
  141. const ssPrefix = 'access-to-page-accessories-modal';
  142. beforeEach(() => {
  143. // login
  144. cy.fixture("user-admin.json").then(user => {
  145. cy.login(user.username, user.password);
  146. });
  147. cy.collapseSidebar(true);
  148. });
  149. it('Page History is shown successfully', () => {
  150. cy.visit('/Sandbox/Bootstrap4');
  151. cy.get('#grw-subnav-container').within(() => {
  152. cy.getByTestid('open-page-item-control-btn').within(() => {
  153. cy.get('button.btn-page-item-control').click({force: true});
  154. });
  155. cy.getByTestid('open-page-accessories-modal-btn-with-history-tab').click({force: true});
  156. });
  157. cy.getByTestid('page-history').should('be.visible')
  158. cy.screenshot(`${ssPrefix}-open-page-history-bootstrap4`);
  159. });
  160. it('Page Attachment Data is shown successfully', () => {
  161. cy.visit('/Sandbox/Bootstrap4', { });
  162. cy.get('#grw-subnav-container').within(() => {
  163. cy.getByTestid('open-page-item-control-btn').within(() => {
  164. cy.getByTestid('open-page-item-control-btn').should('be.visible');
  165. cy.get('button.btn-page-item-control').click({force: true});
  166. });
  167. cy.getByTestid('open-page-accessories-modal-btn-with-attachment-data-tab').click();
  168. });
  169. cy.getByTestid('page-accessories-modal').should('be.visible')
  170. cy.getByTestid('page-attachment').should('be.visible')
  171. cy.screenshot(`${ssPrefix}-open-page-attachment-data-bootstrap4`);
  172. });
  173. it('Share Link Management is shown successfully', () => {
  174. cy.visit('/Sandbox/Bootstrap4', { });
  175. cy.get('#grw-subnav-container').within(() => {
  176. cy.getByTestid('open-page-item-control-btn').within(() => {
  177. cy.get('button.btn-page-item-control').click({force: true});
  178. });
  179. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').should('be.visible');
  180. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').click();
  181. });
  182. cy.getByTestid('page-accessories-modal').should('be.visible');
  183. cy.getByTestid('share-link-management').should('be.visible');
  184. cy.screenshot(`${ssPrefix}-open-share-link-management-bootstrap4`);
  185. });
  186. });
  187. context('Tag Oprations', { scrollBehavior: false }, () =>{
  188. beforeEach(() => {
  189. // login
  190. cy.fixture("user-admin.json").then(user => {
  191. cy.login(user.username, user.password);
  192. });
  193. cy.collapseSidebar(true);
  194. });
  195. it('Successfully add new tag', () => {
  196. const ssPrefix = 'tag-operations-add-new-tag-'
  197. const tag = 'we';
  198. cy.visit('/Sandbox');
  199. cy.waitUntilSkeletonDisappear();
  200. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').should('be.visible');
  201. // eslint-disable-next-line cypress/no-unnecessary-waiting
  202. cy.wait(200);
  203. cy.get('#edit-tags-btn-wrapper-for-tooltip > a').click();
  204. cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
  205. cy.get('#edit-tag-modal').within(() => {
  206. cy.get('.rbt-input-main').type(tag, {force: true});
  207. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  208. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  209. cy.screenshot(`${ssPrefix}2-type-tag-name`);
  210. });
  211. cy.get('#edit-tag-modal').within(() => {
  212. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  213. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  214. cy.get('a#tag-typeahead-asynctypeahead-item-0').click({force: true})
  215. cy.screenshot(`${ssPrefix}3-insert-tag-name`, {capture: 'viewport'});
  216. });
  217. cy.get('#edit-tag-modal').within(() => {
  218. cy.get('div.modal-footer > button').click();
  219. });
  220. cy.get('.toast').should('be.visible').trigger('mouseover');
  221. cy.get('.grw-taglabels-container > .grw-tag-labels > a', { timeout: 10000 }).contains(tag).should('exist');
  222. /* eslint-disable cypress/no-unnecessary-waiting */
  223. cy.wait(150); // wait for toastr to change its color occured by mouseover
  224. cy.screenshot(`${ssPrefix}4-click-done`, {capture: 'viewport'});
  225. });
  226. it('Successfully duplicate page by generated tag', () => {
  227. const ssPrefix = 'tag-operations-page-duplicate-';
  228. const tag = 'we';
  229. const newPageName = 'our';
  230. cy.visit('/Sandbox');
  231. cy.waitUntilSkeletonDisappear();
  232. cy.get('.grw-taglabels-container').within(()=>{
  233. cy.get('.grw-tag-labels').within(()=>{
  234. cy.get('a').then(($el)=>{
  235. cy.wrap($el).contains(tag).click();
  236. });
  237. });
  238. });
  239. // Search result page
  240. cy.getByTestid('search-result-base').should('be.visible');
  241. cy.getByTestid('search-result-list').should('be.visible');
  242. cy.getByTestid('search-result-content').should('be.visible');
  243. cy.get('#revision-loader').should('be.visible');
  244. // force to add 'active' to pass VRT: https://github.com/weseek/growi/pull/6603
  245. cy.getByTestid('page-list-item-L').first().invoke('addClass', 'active');
  246. cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
  247. cy.getByTestid('search-result-list').should('be.visible').then(($el)=>{
  248. cy.wrap($el).within(()=>{
  249. cy.getByTestid('open-page-item-control-btn').first().click();
  250. });
  251. // eslint-disable-next-line cypress/no-unnecessary-waiting
  252. cy.wait(1500); // for wait rendering pagelist info
  253. cy.screenshot(`${ssPrefix}2-click-three-dots-menu`, {capture: 'viewport'});
  254. cy.wrap($el).within(()=>{
  255. cy.getByTestid('open-page-item-control-btn').first().within(()=>{
  256. cy.getByTestid('open-page-duplicate-modal-btn').click();
  257. })
  258. });
  259. })
  260. cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
  261. cy.get('.rbt-input-main').type(`-${newPageName}`, {force: true});
  262. }).screenshot(`${ssPrefix}3-duplicate-page`, {capture: 'viewport'});
  263. cy.getByTestid('page-duplicate-modal').within(() => {
  264. cy.get('.modal-footer > button.btn').click();
  265. });
  266. cy.visit(`Sandbox-${newPageName}`);
  267. cy.waitUntilSkeletonDisappear();
  268. cy.screenshot(`${ssPrefix}4-duplicated-page`, {capture: 'viewport'});
  269. });
  270. it('Successfully rename page from generated tag', () => {
  271. const ssPrefix = 'tag-operations-page-rename-';
  272. const tag = 'we';
  273. const oldPageName = '/Sandbox-our';
  274. const newPageName = '/Sandbox-us';
  275. cy.visit('/Sandbox-our');
  276. cy.waitUntilSkeletonDisappear();
  277. // Search result page
  278. cy.get('.grw-tag-label').should('be.visible').contains(tag).click();
  279. cy.getByTestid('search-result-base').should('be.visible');
  280. cy.getByTestid('search-result-list').should('be.visible');
  281. cy.getByTestid('search-result-content').should('be.visible');
  282. cy.get('#revision-loader').should('be.visible');
  283. // eslint-disable-next-line cypress/no-unnecessary-waiting
  284. cy.wait(300);
  285. cy.screenshot(`${ssPrefix}1-click-tag-name`, {capture: 'viewport'});
  286. cy.getByTestid('search-result-list').within(() => {
  287. cy.get('.list-group-item').each(($row) => {
  288. if($row.find('a').text() === oldPageName){
  289. cy.wrap($row).within(() => {
  290. cy.getByTestid('open-page-item-control-btn').first().click();
  291. cy.getByTestid('page-item-control-menu').should('have.class', 'show').then(() => {
  292. // empty sentence in page list empty: https://github.com/weseek/growi/pull/6880
  293. cy.getByTestid('revision-short-body-in-page-list-item-L').invoke('text', '');
  294. });
  295. cy.getByTestid('page-item-control-menu').within(()=>{
  296. cy.getByTestid('open-page-delete-modal-btn');
  297. cy.screenshot(`${ssPrefix}2-open-page-item-control-menu`);
  298. })
  299. });
  300. }
  301. });
  302. });
  303. cy.getByTestid('search-result-list').within(() => {
  304. cy.get('.list-group-item').each(($row) => {
  305. if($row.find('a').text() === oldPageName){
  306. cy.wrap($row).within(() => {
  307. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  308. });
  309. }
  310. });
  311. });
  312. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  313. cy.get('.rbt-input-main').clear().type(newPageName,{force: true});
  314. }).screenshot(`${ssPrefix}3-insert-new-page-name`);
  315. cy.getByTestid('page-rename-modal').should('be.visible').within(() => {
  316. cy.get('.modal-footer > button').click();
  317. });
  318. cy.visit(newPageName);
  319. cy.waitUntilSkeletonDisappear();
  320. cy.getByTestid('grw-tag-labels').should('be.visible')
  321. cy.screenshot(`${ssPrefix}4-new-page-name-applied`, {capture: 'viewport'});
  322. });
  323. });