Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixed signup card in post plaintext and email preheader #17163

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions ghost/core/test/integration/services/email-service/cards.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ const configUtils = require('../../../utils/configUtils');
const {sendEmail} = require('./utils');
const cheerio = require('cheerio');

/**
* Remove the preheader span from the email html and put it in a separate field called preheader
* @template {{html: string}} T
* @param {T} data
* @returns {asserts data is T & {preheader: string}}
*/
function splitPreheader(data) {
// Remove the preheader span from the email using cheerio
const $ = cheerio.load(data.html);
const preheader = $('.preheader');
// @ts-ignore
data.preheader = preheader.html();
preheader.remove();
data.html = $.html();
Expand Down Expand Up @@ -120,10 +127,8 @@ describe('Can send cards via email', function () {

// Check the plaintext does contain the paragraph, but doesn't contain the signup card
assert.ok(!data.html.includes('Sign up for Koenig Lexical'));

// This is a bug! The plaintext and preheader should not contain the signup card
//assert.ok(!data.plaintext.includes('Sign up for Koenig Lexical'));
//assert.ok(!data.preheader.includes('Sign up for Koenig Lexical'));
assert.ok(!data.plaintext.includes('Sign up for Koenig Lexical'));
assert.ok(!data.preheader.includes('Sign up for Koenig Lexical'));

assert.ok(data.html.includes('This is a paragraph'));
assert.ok(data.plaintext.includes('This is a paragraph'));
Expand Down
4 changes: 4 additions & 0 deletions ghost/core/test/integration/services/email-service/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ async function createPublishedPostEmail(agent, settings = {}, email_recipient_fi
}
let lastEmailModel;

/**
*
* @returns {Promise<{html: string, plaintext: string, emailModel: any, recipientData: any}>}
*/
async function sendEmail(agent, settings, email_recipient_filter) {
// Prepare a post and email model
const completedPromise = jobManager.awaitCompletion('batch-sending-service-job');
Expand Down
4 changes: 3 additions & 1 deletion ghost/html-to-plaintext/lib/html-to-plaintext.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ const loadConverters = () => {
// Don't output hrs
{selector: 'hr', format: 'skip'},
// Don't output > in blockquotes
{selector: 'blockquote', format: 'block'}
{selector: 'blockquote', format: 'block'},
// Don't include signup cards in excerpts
{selector: '.kg-signup-card', format: 'skip'}
]
});

Expand Down