use-tools.spec.ts 14 KB

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