access-to-page.spec.ts 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. // collapse sidebar
  9. cy.collapseSidebar(true);
  10. });
  11. it('/Sandbox is successfully loaded', () => {
  12. cy.visit('/Sandbox', { });
  13. cy.screenshot(`${ssPrefix}-sandbox`);
  14. });
  15. it('/Sandbox with anchor hash is successfully loaded', () => {
  16. cy.visit('/Sandbox#Headers');
  17. // hide fab // disable fab for sticky-events warning
  18. // cy.getByTestid('grw-fab-container').invoke('attr', 'style', 'display: none');
  19. // remove animation for screenshot
  20. // remove 'blink' class because ::after element cannot be operated
  21. // https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin/21709814#21709814
  22. cy.get('#mdcont-headers').invoke('removeClass', 'blink');
  23. cy.get('.grw-skelton').should('not.exist');
  24. cy.screenshot(`${ssPrefix}-sandbox-headers`);
  25. });
  26. it('/Sandbox/Math is successfully loaded', () => {
  27. cy.visit('/Sandbox/Math');
  28. // eslint-disable-next-line cypress/no-unnecessary-waiting
  29. cy.wait(2000); // wait for 2 seconds for MathJax.typesetPromise();
  30. cy.screenshot(`${ssPrefix}-sandbox-math`);
  31. });
  32. it('/Sandbox with edit is successfully loaded', () => {
  33. cy.visit('/Sandbox');
  34. cy.get('.grw-skelton', { timeout: 30000 }).should('not.exist');
  35. cy.get('#grw-subnav-container', { timeout: 30000 }).should('be.visible').within(()=>{
  36. cy.getByTestid('editor-button', { timeout: 30000 }).should('be.visible').click();
  37. })
  38. cy.getByTestid('navbar-editor', { timeout: 30000 }).should('be.visible');
  39. cy.screenshot(`${ssPrefix}-Sandbox-edit-page`);
  40. })
  41. it('/user/admin is successfully loaded', () => {
  42. cy.visit('/user/admin', { });
  43. cy.get('.grw-skelton').should('not.exist');
  44. // for check download toc data
  45. cy.get('.toc-link').should('be.visible');
  46. // eslint-disable-next-line cypress/no-unnecessary-waiting
  47. cy.wait(2000); // wait for calcViewHeight and rendering
  48. cy.screenshot(`${ssPrefix}-user-admin`);
  49. });
  50. });
  51. context('Access to /me page', () => {
  52. const ssPrefix = 'access-to-me-page-';
  53. beforeEach(() => {
  54. // login
  55. cy.fixture("user-admin.json").then(user => {
  56. cy.login(user.username, user.password);
  57. });
  58. // collapse sidebar
  59. cy.collapseSidebar(true);
  60. });
  61. it('/me is successfully loaded', () => {
  62. cy.visit('/me', { });
  63. // eslint-disable-next-line cypress/no-unnecessary-waiting
  64. cy.wait(500); // wait loading image
  65. cy.screenshot(`${ssPrefix}-me`);
  66. });
  67. // it('Draft page is successfully shown', () => {
  68. // cy.visit('/me/drafts');
  69. // cy.screenshot(`${ssPrefix}-draft-page`);
  70. // });
  71. });
  72. context('Access to special pages', () => {
  73. const ssPrefix = 'access-to-special-pages-';
  74. beforeEach(() => {
  75. // login
  76. cy.fixture("user-admin.json").then(user => {
  77. cy.login(user.username, user.password);
  78. });
  79. // collapse sidebar
  80. cy.collapseSidebar(true);
  81. });
  82. it('/trash is successfully loaded', () => {
  83. cy.visit('/trash', { });
  84. cy.getByTestid('trash-page-list').should('be.visible');
  85. cy.screenshot(`${ssPrefix}-trash`);
  86. });
  87. it('/tags is successfully loaded', () => {
  88. // open sidebar
  89. cy.collapseSidebar(false);
  90. cy.visit('/tags');
  91. // select tags
  92. cy.getByTestid('grw-sidebar-nav-primary-tags').click();
  93. cy.getByTestid('grw-sidebar-content-tags').should('be.visible');
  94. cy.getByTestid('grw-tags-list').should('be.visible');
  95. cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  96. cy.getByTestid('tags-page').should('be.visible');
  97. cy.screenshot(`${ssPrefix}-tags`);
  98. });
  99. });
  100. context('Access to Template Editing Mode', () => {
  101. const ssPrefix = 'access-to-modal-';
  102. beforeEach(() => {
  103. // login
  104. cy.fixture("user-admin.json").then(user => {
  105. cy.login(user.username, user.password);
  106. });
  107. // collapse sidebar
  108. cy.collapseSidebar(true);
  109. });
  110. it('Access to Template Editor mode for only child pages successfully', () => {
  111. cy.visit('/Sandbox/Bootstrap4', { });
  112. cy.get('#grw-subnav-container').within(() => {
  113. cy.getByTestid('open-page-item-control-btn').click();
  114. cy.getByTestid('open-page-template-modal-btn').click();
  115. });
  116. cy.getByTestid('page-template-modal').should('be.visible')
  117. cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  118. cy.getByTestid('template-button-children').click();
  119. cy.url().should('include', '/_template#edit');
  120. cy.screenshot();
  121. });
  122. it('Access to Template Editor mode including decendants successfully', () => {
  123. cy.visit('/Sandbox/Bootstrap4', { });
  124. cy.get('#grw-subnav-container').within(() => {
  125. cy.getByTestid('open-page-item-control-btn').click();
  126. cy.getByTestid('open-page-template-modal-btn').click();
  127. });
  128. cy.getByTestid('page-template-modal').should('be.visible')
  129. // cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  130. cy.getByTestid('template-button-decendants').click();
  131. cy.url().should('include', '/__template#edit');
  132. cy.screenshot();
  133. });
  134. });
  135. context('Access to /me/all-in-app-notifications', () => {
  136. const ssPrefix = 'in-app-notifications-';
  137. beforeEach(() => {
  138. // login
  139. cy.fixture("user-admin.json").then(user => {
  140. cy.login(user.username, user.password);
  141. });
  142. // collapse sidebar
  143. cy.collapseSidebar(true);
  144. });
  145. it('All In-App Notification list is successfully loaded', () => {
  146. cy.visit('/');
  147. cy.get('.notification-wrapper > a').click();
  148. cy.get('.notification-wrapper > .dropdown-menu > a').click();
  149. cy.screenshot(`${ssPrefix}-see-all`, { capture: 'viewport' });
  150. cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
  151. cy.screenshot(`${ssPrefix}-see-unread`, { capture: 'viewport' });
  152. });
  153. })