access-to-page.spec.ts 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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
  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('#Headers').invoke('removeClass', 'blink');
  23. cy.screenshot(`${ssPrefix}-sandbox-headers`);
  24. });
  25. it('/Sandbox/Math is successfully loaded', () => {
  26. cy.visit('/Sandbox/Math');
  27. cy.get('mjx-container').should('be.visible');
  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#edit');
  34. cy.screenshot(`${ssPrefix}-sandbox-edit-page`);
  35. })
  36. it('/user/admin is successfully loaded', () => {
  37. cy.visit('/user/admin', { });
  38. // eslint-disable-next-line cypress/no-unnecessary-waiting
  39. cy.wait(1000); // wait for loading
  40. cy.screenshot(`${ssPrefix}-user-admin`);
  41. });
  42. });
  43. context('Access to /me page', () => {
  44. const ssPrefix = 'access-to-me-page-';
  45. beforeEach(() => {
  46. // login
  47. cy.fixture("user-admin.json").then(user => {
  48. cy.login(user.username, user.password);
  49. });
  50. // collapse sidebar
  51. cy.collapseSidebar(true);
  52. });
  53. it('/me is successfully loaded', () => {
  54. cy.visit('/me', { });
  55. // eslint-disable-next-line cypress/no-unnecessary-waiting
  56. cy.wait(500); // wait loading image
  57. cy.screenshot(`${ssPrefix}-me`);
  58. });
  59. it('Draft page is successfully shown', () => {
  60. cy.visit('/me/drafts');
  61. cy.screenshot(`${ssPrefix}-draft-page`);
  62. });
  63. });
  64. context('Access to special pages', () => {
  65. const ssPrefix = 'access-to-special-pages-';
  66. beforeEach(() => {
  67. // login
  68. cy.fixture("user-admin.json").then(user => {
  69. cy.login(user.username, user.password);
  70. });
  71. // collapse sidebar
  72. cy.collapseSidebar(true);
  73. });
  74. it('/trash is successfully loaded', () => {
  75. cy.visit('/trash', { });
  76. cy.getByTestid('trash-page-list').should('be.visible');
  77. cy.screenshot(`${ssPrefix}-trash`);
  78. });
  79. it('/tags is successfully loaded', () => {
  80. cy.visit('/tags');
  81. // open sidebar
  82. cy.collapseSidebar(false);
  83. // select tags
  84. cy.getByTestid('grw-sidebar-nav-primary-tags').click();
  85. cy.getByTestid('grw-sidebar-content-tags').should('be.visible');
  86. cy.getByTestid('grw-tags-list').should('be.visible');
  87. cy.getByTestid('grw-tags-list').contains('You have no tag, You can set tags on pages');
  88. cy.getByTestid('tags-page').should('be.visible');
  89. cy.screenshot(`${ssPrefix}-tags`);
  90. });
  91. });
  92. context('Access to Template Editing Mode', () => {
  93. const ssPrefix = 'access-to-modal-';
  94. beforeEach(() => {
  95. // login
  96. cy.fixture("user-admin.json").then(user => {
  97. cy.login(user.username, user.password);
  98. });
  99. // collapse sidebar
  100. cy.collapseSidebar(true);
  101. });
  102. it('Access to Template Editor mode for only child pages successfully', () => {
  103. cy.visit('/Sandbox/Bootstrap4', { });
  104. cy.get('#grw-subnav-container').within(() => {
  105. cy.getByTestid('open-page-item-control-btn').click();
  106. cy.getByTestid('open-page-template-modal-btn').click();
  107. });
  108. cy.getByTestid('page-template-modal').should('be.visible')
  109. cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  110. cy.getByTestid('template-button-children').click();
  111. cy.url().should('include', '/_template#edit');
  112. cy.screenshot();
  113. });
  114. it('Access to Template Editor mode including decendants successfully', () => {
  115. cy.visit('/Sandbox/Bootstrap4', { });
  116. cy.get('#grw-subnav-container').within(() => {
  117. cy.getByTestid('open-page-item-control-btn').click();
  118. cy.getByTestid('open-page-template-modal-btn').click();
  119. });
  120. cy.getByTestid('page-template-modal').should('be.visible')
  121. // cy.screenshot(`${ssPrefix}-open-page-template-bootstrap4`);
  122. cy.getByTestid('template-button-decendants').click();
  123. cy.url().should('include', '/__template#edit');
  124. cy.screenshot();
  125. });
  126. });
  127. context('Access to /me/all-in-app-notifications', () => {
  128. const ssPrefix = 'in-app-notifications-';
  129. beforeEach(() => {
  130. // login
  131. cy.fixture("user-admin.json").then(user => {
  132. cy.login(user.username, user.password);
  133. });
  134. // collapse sidebar
  135. cy.collapseSidebar(true);
  136. });
  137. it('All In-App Notification list is successfully loaded', () => {
  138. cy.visit('/');
  139. cy.get('.notification-wrapper > a').click();
  140. cy.get('.notification-wrapper > .dropdown-menu > a').click();
  141. cy.screenshot(`${ssPrefix}-see-all`, { capture: 'viewport' });
  142. cy.get('.grw-custom-nav-tab > div > ul > li:nth-child(2) > a').click();
  143. cy.screenshot(`${ssPrefix}-see-unread`, { capture: 'viewport' });
  144. });
  145. })