High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.
JavaScript campaigncampaign-managementemail-marketingemail-subscriptionlistmonkmailing-listnewsletternewsletter-managementnewsletter-softwareself-hostedsms-gatewaysmtptransactional-emails
Fix Codemirror Cypress tests in templates and form pages.
Kailash Nadh9de19ea28ccb
diff --git a/frontend/cypress/e2e/forms.cy.js b/frontend/cypress/e2e/forms.cy.jsindex ce2a2965..8823d86f 100644--- a/frontend/cypress/e2e/forms.cy.js+++ b/frontend/cypress/e2e/forms.cy.js@@ -12,19 +12,16 @@ describe('Forms', () => {.its('length').should('eq', 1);- cy.get('[data-cy=form] code-flask').should('not.exist');+ cy.get('[data-cy=form] [role=textbox]').should('not.exist');});it('Selects public list', () => {// Click the list checkbox.cy.get('ul[data-cy=lists] .checkbox').click();- // Make sure the <pre> form HTML has appeared.- cy.get('code-flask').shadow().find('pre').then(($pre) => {- // Check that the ID of the list in the checkbox appears in the HTML.- cy.get('ul[data-cy=lists] input').then(($inp) => {- cy.wrap($pre).contains($inp.val());- });+ // Check that the ID of the list in the checkbox appears in the HTML.+ cy.get('ul[data-cy=lists] input').then(($inp) => {+ cy.get('[role=textbox]').contains($inp.val());});// Click the list checkbox.diff --git a/frontend/cypress/e2e/settings.cy.js b/frontend/cypress/e2e/settings.cy.jsindex 4b243e80..1356b231 100644--- a/frontend/cypress/e2e/settings.cy.js+++ b/frontend/cypress/e2e/settings.cy.js@@ -27,9 +27,9 @@ describe('Settings', () => {cy.get('.modal button.is-primary').click();cy.get('[data-cy=btn-save]').click();+ cy.wait(500);cy.waitForBackend();- cy.wait(2000);});it('Verify settings change', () => {diff --git a/frontend/cypress/e2e/subscribers.cy.js b/frontend/cypress/e2e/subscribers.cy.jsindex b51eafe4..df37ed47 100644--- a/frontend/cypress/e2e/subscribers.cy.js+++ b/frontend/cypress/e2e/subscribers.cy.js@@ -263,6 +263,7 @@ describe('Domain blocklist', () => {});it('Try subscribing via public page', () => {+ cy.wait(1000);cy.visit(`${apiUrl}/subscription/form`);cy.get('input[name=email]').clear().type('[email protected]');cy.get('button[type=submit]').click();diff --git a/frontend/cypress/e2e/templates.cy.js b/frontend/cypress/e2e/templates.cy.jsindex 374f52c1..daad8cd3 100644--- a/frontend/cypress/e2e/templates.cy.js+++ b/frontend/cypress/e2e/templates.cy.js@@ -5,7 +5,7 @@ describe('Templates', () => {});it('Counts default templates', () => {- cy.get('tbody td[data-label=Name]').should('have.length', 3);+ cy.get('tbody td[data-label=Name]').should('have.length', 4);});it('Clones campaign template', () => {@@ -34,8 +34,9 @@ describe('Templates', () => {cy.get('tbody td.actions [data-cy=btn-edit]').first().click();cy.wait(250);cy.get('input[name=name]').clear().type('edited');- cy.get('code-flask').shadow().find('.codeflask textarea').invoke('val', '<span>test</span> {{ template "content" . }}')- .trigger('input');++ const htmlBody = '<span>test</span><div class="wrap">{{ template "content" . }}</div>';+ cy.get('[role="textbox"]').invoke('text', htmlBody);cy.get('.modal-card-foot button.is-primary').click();cy.wait(250);@@ -53,7 +54,8 @@ describe('Templates', () => {cy.get('.modal-card-foot button').click();// Cloned one should have the full template.- cy.get('tbody [data-cy=btn-preview').eq(3).click();+ cy.get('tbody').contains('a', 'cloned campaign').parents('tr').find('[data-cy=btn-preview]')+ .click();cy.wait(500);cy.get('.modal-card-body iframe').iframe(() => {cy.get('.wrap p').first().contains('Hi there');@@ -97,6 +99,6 @@ describe('Templates', () => {cy.wait(250);});- cy.get('tbody td.actions').should('have.length', 3);+ cy.get('tbody td.actions').should('have.length', 4);});});diff --git a/frontend/cypress/support/commands.js b/frontend/cypress/support/commands.jsindex 2d17d9a4..cbea4b54 100644--- a/frontend/cypress/support/commands.js+++ b/frontend/cypress/support/commands.js@@ -53,32 +53,27 @@ Cypress.Commands.add('iframe', { prevSubject: 'element' }, ($iframe, callback =.within({}, callback));Cypress.Commands.add('waitForBackend', () => {- // Intercept frontend's health checks to prevent test failures- cy.intercept({- method: 'GET',- url: '/*', // Update with actual polling endpoint- }, {- continueOnNetworkError: true, // Prevents Cypress from failing on network errors- });+ // Silence all network errors during wait+ cy.intercept('*', { continueOnNetworkError: true });+ // Keep trying until backend responds successfullycy.waitUntil(() => cy.request({- url: '/api/profile', // Same endpoint as frontend polls+ url: '/api/health',failOnStatusCode: false,- }).then((response) => response.status === 200),+ }).then((res) =>+ // Re-enable exception handling once backend is healthy+ res.status === 200),{- timeout: 10000, // Max wait time (10 seconds)- interval: 1000, // Check every 0.5 seconds+ timeout: 60000,+ interval: 2000,},);});Cypress.on('uncaught:exception', (err, runnable) => {if (err.hasOwnProperty('request')) {- const u = err.request.url;- if (u.includes('config') || u.includes('settings') || u.includes('events')) {- return false;- }+ return false;}return true;diff --git a/frontend/src/api/index.js b/frontend/src/api/index.jsindex e7a6b88f..9c9435df 100644--- a/frontend/src/api/index.js+++ b/frontend/src/api/index.js@@ -71,7 +71,7 @@ http.interceptors.response.use((resp) => {}let msg = '';- if (err.response.data && err.response.data.message) {+ if (err.response && err.response.data && err.response.data.message) {msg = err.response.data.message;} else {msg = err.toString();diff --git a/frontend/src/views/Settings.vue b/frontend/src/views/Settings.vueindex 2ea81851..df83856e 100644--- a/frontend/src/views/Settings.vue+++ b/frontend/src/views/Settings.vue@@ -198,7 +198,7 @@ export default Vue.extend({this.isLoading = true;this.$api.updateSettings(form).then((data) => {- if (data.needsRestart) {+ if (typeof data === 'object' && data !== null && data.needsRestart) {// There are running campaigns and the app didn't auto restart.// The UI will show a warning.this.$root.loadConfig();@@ -228,7 +228,13 @@ export default Vue.extend({getSettings() {this.isLoading = true;this.$api.getSettings().then((data) => {- const d = JSON.parse(JSON.stringify(data));+ let d = {};+ try {+ // Create a deep-copy of the settings hierarchy.+ d = JSON.parse(JSON.stringify(data));+ } catch (err) {+ return;+ }// Serialize the `email_headers` array map to display on the form.for (let i = 0; i < d.smtp.length; i += 1) {