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

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