23-editor--template-modal.cy.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. context('TemplateModal', () => {
  2. const ssPrefix = 'template-modal-';
  3. beforeEach(() => {
  4. // login
  5. cy.fixture("user-admin.json").then(user => {
  6. cy.login(user.username, user.password);
  7. });
  8. });
  9. it("TemplateModal is shown and closed successfully", () => {
  10. cy.visit('/Sandbox/TemplateModal');
  11. cy.collapseSidebar(true, true);
  12. // move to edit mode
  13. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  14. cy.waitUntil(() => {
  15. // do
  16. cy.get('@pageEditorModeManager').within(() => {
  17. cy.get('button:nth-child(2)').click();
  18. });
  19. // until
  20. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  21. })
  22. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  23. // show TemplateModal
  24. cy.waitUntil(() => {
  25. // do
  26. cy.get('.navbar-editor > ul > li:nth-child(16) > button').click({force: true});
  27. // wait until
  28. return cy.getByTestid('template-modal').then($elem => $elem.is(':visible'));
  29. });
  30. // close TemplateModal
  31. cy.getByTestid('template-modal').should('be.visible').within(() => {
  32. cy.screenshot(`${ssPrefix}opened`);
  33. cy.get('button.close').click();
  34. });
  35. cy.screenshot(`${ssPrefix}close`);
  36. });
  37. it("Successfully select template and template locale", () => {
  38. cy.visit('/Sandbox/TemplateModal');
  39. cy.collapseSidebar(true, true);
  40. // move to edit mode
  41. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  42. cy.waitUntil(() => {
  43. // do
  44. cy.get('@pageEditorModeManager').within(() => {
  45. cy.get('button:nth-child(2)').click();
  46. });
  47. // until
  48. return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
  49. })
  50. cy.get('.grw-editor-navbar-bottom').should('be.visible');
  51. // show TemplateModal
  52. cy.waitUntil(() => {
  53. // do
  54. cy.get('.navbar-editor > ul > li:nth-child(16) > button').click({force: true});
  55. // wait until
  56. return cy.getByTestid('template-modal').then($elem => $elem.is(':visible'));
  57. });
  58. // select template and template locale
  59. cy.getByTestid('template-modal').should('be.visible').within(() => {
  60. // select first template
  61. cy.get('.list-group > .list-group-item:nth-child(1)').click();
  62. // check preview exist
  63. cy.get('.card-body > .page-editor-preview-body > .wiki').should('exist');
  64. cy.screenshot(`${ssPrefix}select-template`);
  65. // change template locale
  66. cy.get('.modal-body > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > .dropdown > button').click();
  67. cy.get('.modal-body > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > .dropdown > div > button:nth-child(2)').click();
  68. cy.screenshot(`${ssPrefix}select-template-locale`);
  69. // click insert button
  70. cy.get('.modal-footer > button:nth-child(2)').click();
  71. });
  72. // check show template on markdown
  73. cy.screenshot(`${ssPrefix}insert-template`);
  74. });
  75. });