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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  1. context('Modal for page operation', () => {
  2. const ssPrefix = 'modal-for-page-operation-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. });
  9. it("PageCreateModal is shown and closed successfully", () => {
  10. cy.visit('/');
  11. cy.waitUntil(() => {
  12. // do
  13. cy.getByTestid('newPageBtn').click({force: true});
  14. // wait until
  15. return cy.getByTestid('page-create-modal').then($elem => $elem.is(':visible'));
  16. });
  17. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  18. cy.screenshot(`${ssPrefix}new-page-modal-opened`);
  19. cy.get('button.close').click();
  20. });
  21. cy.collapseSidebar(true, true);
  22. cy.screenshot(`${ssPrefix}page-create-modal-closed`);
  23. });
  24. it("Successfully Create Today's page", () => {
  25. const pageName = "Today's page";
  26. cy.visit('/');
  27. cy.waitUntil(() => {
  28. // do
  29. cy.getByTestid('newPageBtn').click({force: true});
  30. // wait until
  31. return cy.getByTestid('page-create-modal').then($elem => $elem.is(':visible'));
  32. });
  33. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  34. cy.get('.page-today-input2').type(pageName);
  35. cy.screenshot(`${ssPrefix}today-add-page-name`);
  36. cy.getByTestid('btn-create-memo').click();
  37. });
  38. cy.getByTestid('page-editor').should('be.visible');
  39. cy.waitUntil(() => {
  40. // do
  41. cy.getByTestid('save-page-btn').should('be.visible').click();
  42. // wait until
  43. return Cypress.$('.layout-root').hasClass('editing');
  44. });
  45. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  46. cy.collapseSidebar(true);
  47. cy.waitUntilSkeletonDisappear();
  48. cy.screenshot(`${ssPrefix}create-today-page`);
  49. });
  50. it('Successfully create page under specific path', () => {
  51. const pageName = 'child';
  52. cy.visit('/foo/bar');
  53. cy.waitUntil(() => {
  54. // do
  55. cy.getByTestid('newPageBtn').click({force: true});
  56. // wait until
  57. return cy.getByTestid('page-create-modal').then($elem => $elem.is(':visible'));
  58. });
  59. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  60. cy.get('.rbt-input-main').should('have.value', '/foo/bar/');
  61. cy.get('.rbt-input-main').type(pageName);
  62. cy.screenshot(`${ssPrefix}under-path-add-page-name`);
  63. cy.getByTestid('btn-create-page-under-below').click();
  64. });
  65. cy.getByTestid('page-editor').should('be.visible');
  66. cy.getByTestid('save-page-btn').click();
  67. cy.get('.layout-root').should('not.have.class', 'editing');
  68. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  69. cy.waitUntilSkeletonDisappear();
  70. cy.collapseSidebar(true);
  71. cy.screenshot(`${ssPrefix}create-page-under-specific-page`);
  72. });
  73. it('Trying to create template page under the root page fail', () => {
  74. cy.visit('/');
  75. cy.waitUntil(() => {
  76. // do
  77. cy.getByTestid('newPageBtn').click({force: true});
  78. // wait until
  79. return cy.getByTestid('page-create-modal').then($elem => $elem.is(':visible'));
  80. });
  81. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  82. cy.getByTestid('grw-page-create-modal-path-name').should('have.text', '/');
  83. cy.get('#template-type').click();
  84. cy.get('#template-type').next().find('button:eq(0)').click({force: true});
  85. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  86. });
  87. cy.get('.toast-error').should('be.visible').invoke('attr', 'style', 'opacity: 1');
  88. cy.collapseSidebar(true);
  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.collapseSidebar(true);
  99. cy.screenshot(`${ssPrefix}create-template-for-descendants-error`);
  100. });
  101. it('Page Deletion and PutBack is executed successfully', { scrollBehavior: false }, () => {
  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-delete-modal-btn').click({force: true});
  106. });
  107. cy.getByTestid('page-delete-modal').should('be.visible').within(() => {
  108. cy.screenshot(`${ssPrefix}-delete-modal`);
  109. cy.getByTestid('delete-page-button').click();
  110. });
  111. cy.getByTestid('trash-page-alert').should('be.visible');
  112. cy.collapseSidebar(true);
  113. cy.screenshot(`${ssPrefix}-bootstrap4-is-in-garbage-box`);
  114. cy.getByTestid('put-back-button').click();
  115. cy.getByTestid('put-back-page-modal').should('be.visible').within(() => {
  116. cy.screenshot(`${ssPrefix}-put-back-modal`);
  117. cy.getByTestid('put-back-execution-button').should('be.visible').click();
  118. });
  119. cy.collapseSidebar(true);
  120. cy.screenshot(`${ssPrefix}-put-backed-bootstrap4-page`);
  121. });
  122. it('PageDuplicateModal is shown successfully', () => {
  123. cy.visit('/Sandbox/Bootstrap4');
  124. cy.waitUntilSkeletonDisappear();
  125. cy.get('#grw-subnav-container').within(() => {
  126. cy.getByTestid('open-page-item-control-btn').click({force: true});
  127. cy.getByTestid('open-page-duplicate-modal-btn').click({force: true});
  128. });
  129. cy.getByTestid('page-duplicate-modal').should('be.visible').screenshot(`${ssPrefix}-duplicate-bootstrap4`);
  130. });
  131. it('PageMoveRenameModal is shown successfully', () => {
  132. cy.visit('/Sandbox/Bootstrap4');
  133. cy.waitUntilSkeletonDisappear();
  134. cy.get('#grw-subnav-container').within(() => {
  135. cy.getByTestid('open-page-item-control-btn').click({force: true});
  136. cy.getByTestid('open-page-move-rename-modal-btn').click({force: true});
  137. });
  138. cy.getByTestid('grw-page-rename-button').should('be.disabled');
  139. cy.getByTestid('page-rename-modal').should('be.visible').screenshot(`${ssPrefix}-rename-bootstrap4`);
  140. });
  141. });
  142. // TODO: Uncomment after https://redmine.weseek.co.jp/issues/103121 is resolved
  143. // context('Open presentation modal', () => {
  144. // const ssPrefix = 'access-to-presentation-modal-';
  145. // beforeEach(() => {
  146. // // login
  147. // cy.fixture("user-admin.json").then(user => {
  148. // cy.login(user.username, user.password);
  149. // });
  150. // cy.collapseSidebar(true);
  151. // });
  152. // it('PresentationModal for "/" is shown successfully', () => {
  153. // cy.visit('/');
  154. // cy.get('#grw-subnav-container').within(() => {
  155. // cy.getByTestid('open-page-item-control-btn').click({force: true});
  156. // cy.getByTestid('open-presentation-modal-btn').click({force: true});
  157. // });
  158. // // eslint-disable-next-line cypress/no-unnecessary-waiting
  159. // cy.wait(1500);
  160. // cy.screenshot(`${ssPrefix}-open-top`);
  161. // });
  162. // });
  163. context('Page Accessories Modal', () => {
  164. const ssPrefix = 'access-to-page-accessories-modal';
  165. beforeEach(() => {
  166. // login
  167. cy.fixture("user-admin.json").then(user => {
  168. cy.login(user.username, user.password);
  169. });
  170. cy.visit('/');
  171. cy.waitUntil(() => {
  172. // do
  173. cy.getByTestid('grw-contextual-sub-nav').should('be.visible').within(() => {
  174. cy.getByTestid('open-page-item-control-btn').find('button').first().as('btn').click();
  175. });
  176. // wait until
  177. return cy.get('body').within(() => {
  178. return Cypress.$('.dropdown-menu.show').is(':visible');
  179. });
  180. });
  181. });
  182. it('Page History is shown successfully', () => {
  183. cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  184. cy.getByTestid('open-page-accessories-modal-btn-with-history-tab').click({force: true});
  185. });
  186. cy.getByTestid('page-history').should('be.visible');
  187. cy.collapseSidebar(true, true);
  188. cy.waitUntilSpinnerDisappear();
  189. cy.screenshot(`${ssPrefix}-open-page-history-bootstrap4`);
  190. });
  191. it('Page Attachment Data is shown successfully', () => {
  192. cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  193. cy.getByTestid('open-page-accessories-modal-btn-with-attachment-data-tab').click({force: true});
  194. });
  195. cy.waitUntilSpinnerDisappear();
  196. cy.getByTestid('page-attachment').should('be.visible').contains('No attachments yet.');
  197. cy.collapseSidebar(true);
  198. cy.screenshot(`${ssPrefix}-open-page-attachment-data-bootstrap4`);
  199. });
  200. it('Share Link Management is shown successfully', () => {
  201. cy.get('.dropdown-menu.show').should('be.visible').within(() => {
  202. cy.getByTestid('open-page-accessories-modal-btn-with-share-link-management-data-tab').click({force: true});
  203. });
  204. cy.waitUntilSpinnerDisappear();
  205. cy.getByTestid('page-accessories-modal').should('be.visible');
  206. cy.getByTestid('share-link-management').should('be.visible');
  207. cy.collapseSidebar(true);
  208. cy.screenshot(`${ssPrefix}-open-share-link-management-bootstrap4`);
  209. });
  210. });
  211. context('Tag Oprations', { scrollBehavior: false }, () =>{
  212. beforeEach(() => {
  213. // login
  214. cy.fixture("user-admin.json").then(user => {
  215. cy.login(user.username, user.password);
  216. });
  217. });
  218. it('Successfully add new tag', () => {
  219. const ssPrefix = 'tag-operations-add-new-tag-'
  220. const tag = 'we';
  221. cy.visit('/Sandbox/Bootstrap4');
  222. // Add tag
  223. cy.get('#edit-tags-btn-wrapper-for-tooltip').as('edit-tag-tooltip').should('be.visible');
  224. // open Edit Tags Modal
  225. cy.waitUntil(() => {
  226. // do
  227. cy.get('@edit-tag-tooltip').find('a').click({force: true});
  228. // wait until
  229. return cy.get('#edit-tag-modal').then($elem => $elem.is(':visible'));
  230. });
  231. cy.collapseSidebar(true);
  232. cy.get('#edit-tag-modal').should('be.visible').screenshot(`${ssPrefix}1-edit-tag-input`);
  233. cy.get('#edit-tag-modal').should('be.visible').within(() => {
  234. cy.get('.rbt-input-main').type(tag);
  235. cy.get('#tag-typeahead-asynctypeahead').should('be.visible');
  236. cy.get('#tag-typeahead-asynctypeahead-item-0').should('be.visible');
  237. // select
  238. cy.get('a#tag-typeahead-asynctypeahead-item-0').click();
  239. // save
  240. cy.get('div.modal-footer > button').click();
  241. });
  242. cy.get('.toast').should('be.visible').trigger('mouseover');
  243. cy.get('.grw-taglabels-container > .grw-tag-labels > a').contains(tag).should('exist');
  244. cy.screenshot(`${ssPrefix}2-click-done`);
  245. });
  246. });
  247. context('Shortcuts', () => {
  248. const ssPrefix = 'shortcuts';
  249. beforeEach(() => {
  250. // login
  251. cy.fixture("user-admin.json").then(user => {
  252. cy.login(user.username, user.password);
  253. });
  254. });
  255. it('Successfully updating a page using a shortcut on a previously created page', { scrollBehavior: false }, () => {
  256. const body1 = 'hello';
  257. const body2 = ' world!';
  258. const savePageShortcutKey = '{ctrl+s}';
  259. cy.visit('/Sandbox/child');
  260. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  261. cy.waitUntil(() => {
  262. // do
  263. cy.get('@pageEditorModeManager').within(() => {
  264. cy.get('button:nth-child(2)').click();
  265. });
  266. // until
  267. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  268. })
  269. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  270. // 1st
  271. cy.get('.CodeMirror').type(body1);
  272. cy.get('.CodeMirror').contains(body1);
  273. cy.get('.page-editor-preview-body').contains(body1);
  274. cy.get('.CodeMirror').type(savePageShortcutKey);
  275. cy.get('.Toastify__toast').should('be.visible').within(() => {
  276. cy.get('.Toastify__close-button').should('be.visible').click();
  277. cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
  278. });
  279. cy.screenshot(`${ssPrefix}-update-page-1`);
  280. cy.get('.Toastify').should('not.be.visible');
  281. // 2nd
  282. cy.get('.CodeMirror').type(body2);
  283. cy.get('.CodeMirror').contains(body2);
  284. cy.get('.page-editor-preview-body').contains(body2);
  285. cy.get('.CodeMirror').type(savePageShortcutKey);
  286. cy.get('.Toastify__toast').should('be.visible').within(() => {
  287. cy.get('.Toastify__close-button').should('be.visible').click();
  288. cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
  289. });
  290. cy.screenshot(`${ssPrefix}-update-page-2`);
  291. });
  292. });