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

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