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

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