mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-23 03:42:27 +03:00
Error copy updates for Newsletter settings (#20559)
Fixes https://linear.app/tryghost/issue/DES-550/mechanical-error-message-in-newsletter-detail-modal Errors in the newsletter detail modal sounded mechanical and were inconsistent with other error messages. That is now fixed, and they sound more human.
This commit is contained in:
parent
dfb0f93c06
commit
0aef3d3bee
@ -39,7 +39,7 @@ const AddNewsletterModal: React.FC<RoutingModalProps> = () => {
|
||||
const newErrors: Record<string, string> = {};
|
||||
|
||||
if (!formState.name) {
|
||||
newErrors.name = 'Name is required';
|
||||
newErrors.name = 'A name is required for your newsletter';
|
||||
}
|
||||
|
||||
return newErrors;
|
||||
|
@ -546,17 +546,17 @@ const NewsletterDetailModalContent: React.FC<{newsletter: Newsletter; onlyOne: b
|
||||
const newErrors: Record<string, string> = {};
|
||||
|
||||
if (!formState.name) {
|
||||
newErrors.name = 'Name is required';
|
||||
newErrors.name = 'A name is required for your newsletter';
|
||||
}
|
||||
|
||||
if (formState.sender_email && !validator.isEmail(formState.sender_email)) {
|
||||
newErrors.sender_email = 'Invalid email';
|
||||
newErrors.sender_email = 'Enter a valid email address';
|
||||
} else if (formState.sender_email && hasSendingDomain(config) && formState.sender_email.split('@')[1] !== sendingDomain(config)) {
|
||||
newErrors.sender_email = `Email must end with @${sendingDomain(config)}`;
|
||||
newErrors.sender_email = `Email address must end with @${sendingDomain(config)}`;
|
||||
}
|
||||
|
||||
if (formState.sender_reply_to && !validator.isEmail(formState.sender_reply_to) && !['newsletter', 'support'].includes(formState.sender_reply_to)) {
|
||||
newErrors.sender_reply_to = 'Invalid email';
|
||||
newErrors.sender_reply_to = 'Enter a valid email address';
|
||||
}
|
||||
|
||||
return newErrors;
|
||||
|
@ -27,7 +27,7 @@ test.describe('Newsletter settings', async () => {
|
||||
const modal = page.getByTestId('add-newsletter-modal');
|
||||
await modal.getByRole('button', {name: 'Create'}).click();
|
||||
|
||||
await expect(modal).toHaveText(/Name is required/);
|
||||
await expect(modal).toHaveText(/A name is required for your newsletter/);
|
||||
|
||||
// Shouldn't be necessary, but without these Playwright doesn't click Create the second time for some reason
|
||||
await modal.getByRole('button', {name: 'Cancel'}).click();
|
||||
@ -69,7 +69,7 @@ test.describe('Newsletter settings', async () => {
|
||||
await modal.getByPlaceholder('Weekly Roundup').fill('');
|
||||
await modal.getByRole('button', {name: 'Save'}).click();
|
||||
|
||||
await expect(modal).toHaveText(/Name is required/);
|
||||
await expect(modal).toHaveText(/A name is required for your newsletter/);
|
||||
|
||||
await modal.getByPlaceholder('Weekly Roundup').fill('Updated newsletter');
|
||||
|
||||
@ -114,7 +114,7 @@ test.describe('Newsletter settings', async () => {
|
||||
await modal.getByLabel('Sender email').fill('not-an-email');
|
||||
await modal.getByRole('button', {name: 'Save'}).click();
|
||||
|
||||
await expect(modal).toHaveText(/Invalid email/);
|
||||
await expect(modal).toHaveText(/Enter a valid email address/);
|
||||
|
||||
await modal.getByLabel('Sender email').fill('test@test.com');
|
||||
await modal.getByRole('button', {name: 'Save'}).click();
|
||||
@ -191,7 +191,7 @@ test.describe('Newsletter settings', async () => {
|
||||
await replyToEmail.fill('not-an-email');
|
||||
await modal.getByRole('button', {name: 'Save'}).click();
|
||||
|
||||
await expect(modal).toHaveText(/Invalid email/);
|
||||
await expect(modal).toHaveText(/Enter a valid email address/);
|
||||
|
||||
await replyToEmail.fill('test@test.com');
|
||||
await modal.getByRole('button', {name: 'Save'}).click();
|
||||
@ -237,12 +237,12 @@ test.describe('Newsletter settings', async () => {
|
||||
// Error case #1: add invalid email address
|
||||
await senderEmail.fill('Harry Potter');
|
||||
await modal.getByRole('button', {name: 'Save'}).click();
|
||||
await expect(modal).toHaveText(/Invalid email/);
|
||||
await expect(modal).toHaveText(/Enter a valid email address/);
|
||||
|
||||
// Error case #2: the sender email address doesn't match the custom sending domain
|
||||
await senderEmail.fill('harry@potter.com');
|
||||
await modal.getByRole('button', {name: 'Save'}).click();
|
||||
await expect(modal).toHaveText(/Email must end with @customdomain.com/);
|
||||
await expect(modal).toHaveText(/Email address must end with @customdomain.com/);
|
||||
|
||||
// But can have any address on the same domain, without verification
|
||||
await senderEmail.fill('harry@customdomain.com');
|
||||
|
Loading…
Reference in New Issue
Block a user