| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- context('TemplateModal', () => {
- const ssPrefix = 'template-modal-';
- beforeEach(() => {
- // login
- cy.fixture("user-admin.json").then(user => {
- cy.login(user.username, user.password);
- });
- });
- it("TemplateModal is shown and closed successfully", () => {
- cy.visit('/Sandbox/TemplateModal');
- cy.collapseSidebar(true, true);
- // move to edit mode
- cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
- cy.waitUntil(() => {
- // do
- cy.get('@pageEditorModeManager').within(() => {
- cy.get('button:nth-child(2)').click();
- });
- // until
- return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
- })
- cy.get('.grw-editor-navbar-bottom').should('be.visible');
- // show TemplateModal
- cy.waitUntil(() => {
- // do
- cy.get('.navbar-editor > ul > li:nth-child(16) > button').click({force: true});
- // wait until
- return cy.getByTestid('template-modal').then($elem => $elem.is(':visible'));
- });
- // close TemplateModal
- cy.getByTestid('template-modal').should('be.visible').within(() => {
- cy.screenshot(`${ssPrefix}opened`);
- cy.get('button.close').click();
- });
- cy.screenshot(`${ssPrefix}close`);
- });
- it("Successfully select template and template locale", () => {
- cy.visit('/Sandbox/TemplateModal');
- cy.collapseSidebar(true, true);
- // move to edit mode
- cy.get('#grw-page-editor-mode-manager').as('pageEditorModeManager').should('be.visible');
- cy.waitUntil(() => {
- // do
- cy.get('@pageEditorModeManager').within(() => {
- cy.get('button:nth-child(2)').click();
- });
- // until
- return cy.get('.layout-root').then($elem => $elem.hasClass('editing'));
- })
- cy.get('.grw-editor-navbar-bottom').should('be.visible');
- // show TemplateModal
- cy.waitUntil(() => {
- // do
- cy.get('.navbar-editor > ul > li:nth-child(16) > button').click({force: true});
- // wait until
- return cy.getByTestid('template-modal').then($elem => $elem.is(':visible'));
- });
- // select template and template locale
- cy.getByTestid('template-modal').should('be.visible').within(() => {
- // select first template
- cy.get('.list-group > .list-group-item:nth-child(1)').click();
- // check preview exist
- cy.get('.card-body > .page-editor-preview-body > .wiki').should('exist');
- cy.screenshot(`${ssPrefix}select-template`);
- // change template locale
- cy.get('.modal-body > div:nth-child(1) > div:nth-child(3) > div:nth-child(1) > div:nth-child(2) > .dropdown > button').click();
- 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();
- cy.screenshot(`${ssPrefix}select-template-locale`);
- // click insert button
- cy.get('.modal-footer > button:nth-child(2)').click();
- });
- // check show template on markdown
- cy.screenshot(`${ssPrefix}insert-template`);
- });
- });
|