access-to-page.spec.ts 5.3 KB

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