20-basic-features--access-to-page.spec.ts 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. context('Access to page', () => {
  2. const ssPrefix = 'access-to-page-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. });
  9. it('/Sandbox is successfully loaded', () => {
  10. cy.visit('/Sandbox');
  11. cy.waitUntilSkeletonDisappear();
  12. // for check download toc data
  13. // https://redmine.weseek.co.jp/issues/111384
  14. // cy.get('.toc-link').should('be.visible');
  15. cy.collapseSidebar(true, true);
  16. cy.screenshot(`${ssPrefix}-sandbox`);
  17. });
  18. // TODO: https://redmine.weseek.co.jp/issues/109939
  19. it('/Sandbox with anchor hash is successfully loaded', () => {
  20. cy.visit('/Sandbox#Headers');
  21. cy.waitUntilSkeletonDisappear();
  22. // for check download toc data
  23. // https://redmine.weseek.co.jp/issues/111384
  24. // cy.get('.toc-link').should('be.visible');
  25. // hide fab
  26. cy.getByTestid('grw-fab-container').invoke('attr', 'style', 'display: none');
  27. // remove animation for screenshot
  28. // remove 'blink' class because ::after element cannot be operated
  29. // https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin/21709814#21709814
  30. cy.get('#mdcont-headers').invoke('removeClass', 'blink');
  31. cy.collapseSidebar(true);
  32. cy.screenshot(`${ssPrefix}-sandbox-headers`);
  33. });
  34. it('/Sandbox/Math is successfully loaded', () => {
  35. cy.visit('/Sandbox/Math');
  36. cy.waitUntilSkeletonDisappear();
  37. // for check download toc data
  38. // https://redmine.weseek.co.jp/issues/111384
  39. // cy.get('.toc-link').should('be.visible');
  40. cy.get('.math').should('be.visible');
  41. cy.collapseSidebar(true);
  42. cy.screenshot(`${ssPrefix}-sandbox-math`);
  43. });
  44. it('/Sandbox with edit is successfully loaded', () => {
  45. cy.visit('/Sandbox#edit');
  46. cy.waitUntilSkeletonDisappear();
  47. cy.getByTestid('navbar-editor').should('be.visible');
  48. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  49. cy.getByTestid('save-page-btn').should('be.visible');
  50. cy.get('.grw-grant-selector').should('be.visible');
  51. cy.collapseSidebar(true);
  52. cy.screenshot(`${ssPrefix}-Sandbox-edit-page`);
  53. })
  54. it('View and Edit contents are successfully loaded', () => {
  55. const body1 = 'hello';
  56. cy.visit('/Sandbox/testForUseEditingMarkdown');
  57. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  58. cy.waitUntil(() => {
  59. // do
  60. cy.get('@pageEditorModeManager').within(() => {
  61. cy.get('button:nth-child(2)').click();
  62. });
  63. // until
  64. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  65. })
  66. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  67. // check edited contents after save
  68. cy.get('.CodeMirror').type(body1);
  69. cy.get('.CodeMirror').contains(body1);
  70. cy.get('.page-editor-preview-body').contains(body1);
  71. cy.getByTestid('page-editor').should('be.visible');
  72. cy.getByTestid('save-page-btn').click();
  73. cy.get('.wiki').should('be.visible');
  74. cy.get('.wiki').children().first().should('have.text', body1);
  75. })
  76. it('Editing contents are successfully loaded with shortcut key', () => {
  77. const body2 = ' world!';
  78. const savePageShortcutKey = '{ctrl+s}';
  79. cy.visit('/Sandbox/testForUseEditingMarkdown');
  80. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  81. cy.waitUntil(() => {
  82. // do
  83. cy.get('@pageEditorModeManager').within(() => {
  84. cy.get('button:nth-child(2)').click();
  85. });
  86. // until
  87. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  88. })
  89. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  90. // check editing contents with shortcut key
  91. cy.get('. CodeMirror-line ').children().first().should(($elm) => {
  92. const text = $elm.text()
  93. cy.get('.CodeMirror').type(body2);
  94. cy.get('.CodeMirror').contains(text+body2);
  95. cy.get('.page-editor-preview-body').contains(text+body2);
  96. cy.get('.CodeMirror').type(savePageShortcutKey);
  97. cy.get('.CodeMirror').contains(text+body2);
  98. cy.get('.page-editor-preview-body').contains(text+body2);
  99. })
  100. })
  101. it('/user/admin is successfully loaded', () => {
  102. cy.visit('/user/admin');
  103. cy.waitUntilSkeletonDisappear();
  104. // for check download toc data
  105. // https://redmine.weseek.co.jp/issues/111384
  106. // cy.get('.toc-link').should('be.visible');
  107. // eslint-disable-next-line cypress/no-unnecessary-waiting
  108. cy.wait(2000); // wait for calcViewHeight and rendering
  109. cy.collapseSidebar(true);
  110. cy.screenshot(`${ssPrefix}-user-admin`);
  111. });
  112. });
  113. context('Access to /me page', () => {
  114. const ssPrefix = 'access-to-me-page-';
  115. beforeEach(() => {
  116. // login
  117. cy.fixture("user-admin.json").then(user => {
  118. cy.login(user.username, user.password);
  119. });
  120. });
  121. it('/me is successfully loaded', () => {
  122. cy.visit('/me');
  123. cy.getByTestid('grw-user-settings').should('be.visible');
  124. cy.collapseSidebar(true);
  125. cy.screenshot(`${ssPrefix}-me`);
  126. });
  127. // it('Draft page is successfully shown', () => {
  128. // cy.visit('/me/drafts');
  129. // cy.screenshot(`${ssPrefix}-draft-page`);
  130. // });
  131. });
  132. context('Access to special pages', () => {
  133. const ssPrefix = 'access-to-special-pages-';
  134. beforeEach(() => {
  135. // login
  136. cy.fixture("user-admin.json").then(user => {
  137. cy.login(user.username, user.password);
  138. });
  139. });
  140. it('/trash is successfully loaded', () => {
  141. cy.visit('/trash');
  142. cy.getByTestid('trash-page-list').contains('There are no pages under this page.');
  143. cy.collapseSidebar(true);
  144. cy.screenshot(`${ssPrefix}-trash`);
  145. });
  146. it('/tags is successfully loaded', { scrollBehavior: false } ,() => {
  147. // open sidebar
  148. // cy.collapseSidebar(false);
  149. cy.visit('/tags');
  150. // cy.getByTestid('grw-sidebar-content-tags').within(() => {
  151. // cy.getByTestid('grw-tags-list').should('be.visible');
  152. // cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  153. // })
  154. cy.getByTestid('tags-page').within(() => {
  155. cy.getByTestid('grw-tags-list').should('be.visible');
  156. cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  157. });
  158. cy.collapseSidebar(true);
  159. cy.screenshot(`${ssPrefix}-tags`);
  160. });
  161. });
  162. context('Access to Template Editing Mode', () => {
  163. const ssPrefix = 'access-to-modal-';
  164. beforeEach(() => {
  165. // login
  166. cy.fixture("user-admin.json").then(user => {
  167. cy.login(user.username, user.password);
  168. });
  169. });
  170. // TODO: 109057
  171. // it('Access to Template Editor mode for only child pages successfully', () => {
  172. // cy.visit('/Sandbox/Bootstrap4', { });
  173. // cy.waitUntilSkeletonDisappear();
  174. // cy.get('#grw-subnav-container').within(() => {
  175. // cy.getByTestid('open-page-item-control-btn').should('be.visible');
  176. // cy.getByTestid('open-page-item-control-btn').click();
  177. // cy.getByTestid('open-page-template-modal-btn').should('be.visible');
  178. // cy.getByTestid('open-page-template-modal-btn').click();
  179. // });
  180. // cy.getByTestid('page-template-modal').should('be.visible');
  181. // cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  182. // Todo: `@`alias may be changed. This code was made in an attempt to solve the error of element being dettached from the dom which couldn't be solved at this time.
  183. // Wait for Todo: 109057 is solved and fix or leave the code below for better test code.
  184. // cy.getByTestid('template-button-children').as('template-button-children');
  185. // cy.get('@template-button-children').should('be.visible').click();
  186. // cy.waitUntilSkeletonDisappear();
  187. // cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
  188. // cy.url().should('include', '/_template#edit');
  189. // cy.screenshot();
  190. // });
  191. // });
  192. // TODO: 109057
  193. // it('Access to Template Editor mode including decendants successfully', () => {
  194. // cy.visit('/Sandbox/Bootstrap4', { });
  195. // cy.waitUntilSkeletonDisappear();
  196. // cy.get('#grw-subnav-container').within(() => {
  197. // cy.getByTestid('open-page-item-control-btn').should('be.visible');
  198. // cy.getByTestid('open-page-item-control-btn').click();
  199. // cy.getByTestid('open-page-template-modal-btn').should('be.visible');
  200. // cy.getByTestid('open-page-template-modal-btn').click();
  201. // });
  202. // cy.getByTestid('page-template-modal').should('be.visible');
  203. // Todo: `@`alias may be changed. This code was made in an attempt to solve the error of element being dettached from the dom which couldn't be solved at this time.
  204. // Wait for Todo: 109057 is solved and fix or leave the code below for better test code.
  205. // cy.getByTestid('template-button-decendants').as('template-button-decendants');
  206. // cy.get('@template-button-decendants').should('be.visible').click();
  207. // cy.waitUntilSkeletonDisappear();
  208. // cy.getByTestid('navbar-editor').should('be.visible').then(()=>{
  209. // cy.url().should('include', '/__template#edit');
  210. // cy.screenshot();
  211. // });
  212. // });
  213. });
  214. context('Access to /me/all-in-app-notifications', () => {
  215. const ssPrefix = 'in-app-notifications-';
  216. beforeEach(() => {
  217. // login
  218. cy.fixture("user-admin.json").then(user => {
  219. cy.login(user.username, user.password);
  220. });
  221. });
  222. it('All In-App Notification list is successfully loaded', { scrollBehavior: false },() => {
  223. cy.visit('/');
  224. cy.get('.notification-wrapper').click();
  225. cy.get('.notification-wrapper > .dropdown-menu > a').click();
  226. cy.getByTestid('grw-in-app-notification-page').should('be.visible');
  227. cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
  228. cy.collapseSidebar(true);
  229. cy.screenshot(`${ssPrefix}-see-all`);
  230. cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
  231. cy.getByTestid('grw-in-app-notification-page-spinner').should('not.exist');
  232. cy.collapseSidebar(true);
  233. cy.screenshot(`${ssPrefix}-see-unread`);
  234. });
  235. })