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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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.getByTestid('editor-button').click();
  15. cy.getByTestid('grw-editor-navbar-bottom').should('be.visible');
  16. // open TemplateModal
  17. cy.getByTestid('open-template-button').click();
  18. cy.getByTestid('template-modal').should('be.visible');
  19. cy.screenshot(`${ssPrefix}opened`);
  20. // close TemplateModal
  21. cy.getByTestid('template-modal').should('be.visible').within(() => {
  22. cy.get('.btn-close').click();
  23. });
  24. cy.screenshot(`${ssPrefix}close`);
  25. });
  26. it("Successfully select template and template locale", () => {
  27. cy.visit('/Sandbox/TemplateModal');
  28. cy.collapseSidebar(true, true);
  29. // move to edit mode
  30. cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
  31. cy.getByTestid('editor-button').click();
  32. cy.getByTestid('grw-editor-navbar-bottom').should('be.visible');
  33. // open TemplateModal
  34. cy.getByTestid('open-template-button').click();
  35. cy.getByTestid('template-modal').should('be.visible');
  36. // select template and template locale
  37. cy.getByTestid('template-modal').should('be.visible').within(() => {
  38. // select first template
  39. cy.get('.list-group > .list-group-item:nth-child(1)').click();
  40. // check preview exist
  41. cy.get('.card-body').should('be.visible');
  42. cy.screenshot(`${ssPrefix}select-template`);
  43. // change template locale
  44. cy.get('.modal-body > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > .dropdown > button').click();
  45. 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();
  46. cy.screenshot(`${ssPrefix}select-template-locale`);
  47. // click insert button
  48. cy.get('.modal-footer > button:nth-child(2)').click();
  49. });
  50. // check show template on markdown
  51. cy.screenshot(`${ssPrefix}insert-template`);
  52. });
  53. });