23-editor--with-navigation.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. context('Editor while navigation', () => {
  2. const ssPrefix = 'editor-while-navigation-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. });
  9. // for https://redmine.weseek.co.jp/issues/115285
  10. it('Successfully updating the page body', { scrollBehavior: false }, () => {
  11. const page1Path = '/Sandbox/for-115285/page1';
  12. const page2Path = '/Sandbox/for-115285/page2';
  13. cy.visit(page1Path);
  14. // open editor
  15. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  16. cy.waitUntil(() => {
  17. // do
  18. cy.get('@pageEditorModeManager').within(() => {
  19. cy.get('button:nth-child(2)').click();
  20. });
  21. // until
  22. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  23. })
  24. // page1
  25. const bodyHello = 'hello';
  26. cy.get('.CodeMirror').type(bodyHello);
  27. cy.get('.CodeMirror').should('contain.text', bodyHello);
  28. cy.get('.page-editor-preview-body').should('contain.text', bodyHello);
  29. cy.getByTestid('page-editor').should('be.visible');
  30. cy.get('.CodeMirror').screenshot(`${ssPrefix}-editor-for-page1`);
  31. // save page1
  32. cy.getByTestid('save-page-btn').click();
  33. // open duplicate modal
  34. cy.waitUntil(() => {
  35. // do
  36. cy.get('#grw-subnav-container').within(() => {
  37. cy.getByTestid('open-page-item-control-btn').find('button').click({force: true});
  38. });
  39. // wait until
  40. return cy.getByTestid('page-item-control-menu').then($elem => $elem.is(':visible'))
  41. });
  42. cy.getByTestid('open-page-duplicate-modal-btn').filter(':visible').click({force: true});
  43. // duplicate and navigate to page1
  44. cy.getByTestid('page-duplicate-modal').should('be.visible').within(() => {
  45. cy.get('input.form-control').clear();
  46. cy.get('input.form-control').type(page2Path);
  47. cy.getByTestid('btn-duplicate').click();
  48. })
  49. // open editor
  50. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  51. cy.waitUntil(() => {
  52. // do
  53. cy.get('@pageEditorModeManager').within(() => {
  54. cy.get('button:nth-child(2)').click();
  55. });
  56. // until
  57. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  58. })
  59. cy.get('.CodeMirror').screenshot(`${ssPrefix}-editor-for-page2`);
  60. // type (without save)
  61. const bodyWorld = ' world!!'
  62. cy.get('.CodeMirror').type(`${bodyWorld}`);
  63. cy.get('.CodeMirror').should('contain.text', `${bodyHello}${bodyWorld}`);
  64. cy.get('.page-editor-preview-body').should('contain.text', `${bodyHello}${bodyWorld}`);
  65. cy.get('.CodeMirror').screenshot(`${ssPrefix}-editor-for-page2-modified`);
  66. // create a link to page1
  67. cy.get('.CodeMirror').type('\n\n[page1](./page1)');
  68. // go to page1
  69. cy.get('.page-editor-preview-body').within(() => {
  70. cy.get("a:contains('page1')").click();
  71. });
  72. // open editor
  73. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  74. cy.waitUntil(() => {
  75. // do
  76. cy.get('@pageEditorModeManager').within(() => {
  77. cy.get('button:nth-child(2)').click();
  78. });
  79. // until
  80. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  81. })
  82. cy.get('.CodeMirror').screenshot(`${ssPrefix}-editor-for-page1-returned`);
  83. // expect
  84. cy.get('.CodeMirror').should('contain.text', bodyHello);
  85. cy.get('.CodeMirror').should('not.contain.text', bodyWorld); // text that added to page2
  86. cy.get('.CodeMirror').should('not.contain.text', 'page1'); // text that added to page2
  87. });
  88. });