23-editor--saving.cy.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. context('PageCreateButton', () => {
  2. const ssPrefix = 'page-create-modal-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. });
  9. it("DropendMenu is shown successfully", () => {
  10. cy.visit('/');
  11. cy.collapseSidebar(true, true);
  12. cy.getByTestid('grw-page-create-button').trigger('mouseover');
  13. cy.waitUntil(() => {
  14. // do
  15. cy.getByTestid('grw-page-create-button-dropend-toggle').click({force: true});
  16. // wait until
  17. return cy.getByTestid('grw-page-create-button-dropend-menu').then($elem => $elem.is(':visible'));
  18. });
  19. cy.screenshot(`${ssPrefix}page-create-button-dropend-menu-shown`);
  20. });
  21. it("Successfully Create Today's page", () => {
  22. cy.visit('/');
  23. cy.collapseSidebar(true);
  24. cy.getByTestid('grw-page-create-button').trigger('mouseover');
  25. cy.waitUntil(() => {
  26. // do
  27. cy.getByTestid('grw-page-create-button-dropend-toggle').click({force: true});
  28. // wait until
  29. return cy.getByTestid('grw-page-create-button-dropend-menu').then($elem => $elem.is(':visible'));
  30. });
  31. cy.getByTestid('grw-page-create-button-dropend-menu').should('be.visible').within(() => {
  32. cy.get('button').eq(1).click();
  33. });
  34. cy.getByTestid('page-editor').should('be.visible');
  35. cy.getByTestid('save-page-btn').as('save-page-btn').should('be.visible');
  36. cy.waitUntil(() => {
  37. // do
  38. cy.get('@save-page-btn').click();
  39. // wait until
  40. return cy.get('@save-page-btn').then($elem => $elem.is(':disabled'));
  41. });
  42. cy.get('.layout-root').should('not.have.class', 'editing');
  43. cy.waitUntilSkeletonDisappear();
  44. cy.screenshot(`${ssPrefix}create-today-page`);
  45. });
  46. it.skip('Successfully create page under specific path', () => {
  47. const pageName = 'child';
  48. cy.visit('/foo/bar');
  49. cy.collapseSidebar(true);
  50. cy.waitUntil(() => {
  51. // do
  52. cy.getByTestid('newPageBtn').click({force: true});
  53. // wait until
  54. return cy.get('body').within(() => {
  55. return Cypress.$('[data-testid=page-create-modal]').is(':visible');
  56. });
  57. });
  58. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  59. cy.get('.rbt-input-main').should('have.value', '/foo/bar/');
  60. cy.get('.rbt-input-main').type(pageName);
  61. cy.screenshot(`${ssPrefix}under-path-add-page-name`);
  62. cy.getByTestid('btn-create-page-under-below').click();
  63. });
  64. cy.getByTestid('page-editor').should('be.visible');
  65. cy.getByTestid('save-page-btn').as('save-page-btn').should('be.visible');
  66. cy.waitUntil(() => {
  67. // do
  68. cy.get('@save-page-btn').click();
  69. // wait until
  70. return cy.get('@save-page-btn').then($elem => $elem.is(':disabled'));
  71. });
  72. cy.get('.layout-root').should('not.have.class', 'editing');
  73. cy.getByTestid('grw-contextual-sub-nav').should('be.visible');
  74. cy.waitUntilSkeletonDisappear();
  75. cy.screenshot(`${ssPrefix}create-page-under-specific-page`);
  76. });
  77. it.skip('Trying to create template page under the root page fail', () => {
  78. cy.visit('/');
  79. cy.collapseSidebar(true);
  80. cy.waitUntil(() => {
  81. // do
  82. cy.getByTestid('newPageBtn').click({force: true});
  83. // wait until
  84. return cy.getByTestid('page-create-modal').then($elem => $elem.is(':visible'));
  85. });
  86. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  87. cy.getByTestid('grw-page-create-modal-path-name').should('have.text', '/');
  88. cy.get('#template-type').click();
  89. cy.get('#template-type').next().find('button:eq(0)').click({force: true});
  90. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  91. });
  92. cy.get('.Toastify__toast').should('be.visible');
  93. cy.screenshot(`${ssPrefix}create-template-for-children-error`);
  94. cy.get('.Toastify__toast').should('be.visible').within(() => {
  95. cy.get('.Toastify__close-button').should('be.visible').click();
  96. cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
  97. });
  98. cy.getByTestid('page-create-modal').should('be.visible').within(() => {
  99. cy.get('#template-type').click();
  100. cy.get('#template-type').next().find('button:eq(1)').click({force: true});
  101. cy.getByTestid('grw-btn-edit-page').should('be.visible').click();
  102. });
  103. cy.get('.Toastify__toast').should('be.visible');
  104. cy.screenshot(`${ssPrefix}create-template-for-descendants-error`);
  105. });
  106. });
  107. context.skip('Shortcuts', () => {
  108. const ssPrefix = 'shortcuts';
  109. beforeEach(() => {
  110. // login
  111. cy.fixture("user-admin.json").then(user => {
  112. cy.login(user.username, user.password);
  113. });
  114. });
  115. it('Successfully updating a page using a shortcut on a previously created page', { scrollBehavior: false }, () => {
  116. const body1 = 'hello';
  117. const body2 = ' world!';
  118. const savePageShortcutKey = '{ctrl+s}';
  119. cy.visit('/Sandbox/child');
  120. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  121. cy.waitUntil(() => {
  122. // do
  123. cy.get('@pageEditorModeManager').within(() => {
  124. cy.get('button:nth-child(2)').click();
  125. });
  126. // until
  127. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  128. })
  129. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  130. // 1st
  131. cy.get('.CodeMirror').type(body1);
  132. cy.get('.CodeMirror').contains(body1);
  133. cy.get('.page-editor-preview-body').contains(body1);
  134. cy.get('.CodeMirror').type(savePageShortcutKey);
  135. cy.get('.Toastify__toast').should('be.visible').within(() => {
  136. cy.get('.Toastify__close-button').should('be.visible').click();
  137. cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
  138. });
  139. cy.screenshot(`${ssPrefix}-update-page-1`);
  140. cy.get('.Toastify').should('not.be.visible');
  141. // 2nd
  142. cy.get('.CodeMirror').type(body2);
  143. cy.get('.CodeMirror').contains(body2);
  144. cy.get('.page-editor-preview-body').contains(body2);
  145. cy.get('.CodeMirror').type(savePageShortcutKey);
  146. cy.get('.Toastify__toast').should('be.visible').within(() => {
  147. cy.get('.Toastify__close-button').should('be.visible').click();
  148. cy.get('.Toastify__progress-bar').invoke('attr', 'style', 'display: none')
  149. });
  150. cy.screenshot(`${ssPrefix}-update-page-2`);
  151. });
  152. });