Add fullstops to error messages (like Django) and remove unnecessary span elements.

pull/12063/head
Kyle Bayliss 2024-06-18 16:23:48 +01:00
rodzic 4d1de045e4
commit ae3d315364
11 zmienionych plików z 17 dodań i 17 usunięć

Wyświetl plik

@ -55,7 +55,7 @@ export class FieldBlock {
console.error(e);
this.setError({
messages: [
'This widget failed to render, please check the console for details',
'This widget failed to render, please check the console for details.',
],
});
return;

Wyświetl plik

@ -166,8 +166,8 @@ describe('telepath: wagtail.blocks.FieldBlock', () => {
test('setError() renders errors', () => {
boundBlock.setError({
messages: [
'Field must not contain the letter E',
'Field must contain a story about kittens',
'Field must not contain the letter E.',
'Field must contain a story about kittens.',
],
});
expect(document.body.innerHTML).toMatchSnapshot();

Wyświetl plik

@ -299,7 +299,7 @@ describe('telepath: wagtail.blocks.ListBlock', () => {
test('setError passes error messages to children', () => {
boundBlock.setError({
blockErrors: { 1: { messages: ['Not as good as the first one'] } },
blockErrors: { 1: { messages: ['Not as good as the first one.'] } },
});
expect(document.body.innerHTML).toMatchSnapshot();
});

Wyświetl plik

@ -318,7 +318,7 @@ describe('telepath: wagtail.blocks.StreamBlock', () => {
],
blockErrors: {
/* block error */
1: { messages: ['Not as good as the first one'] },
1: { messages: ['Not as good as the first one.'] },
},
});
expect(document.body.innerHTML).toMatchSnapshot();

Wyświetl plik

@ -170,7 +170,7 @@ describe('telepath: wagtail.blocks.StructBlock', () => {
test('setError passes error messages to children', () => {
boundBlock.setError({
blockErrors: {
size: { messages: ['This is too big'] },
size: { messages: ['This is too big.'] },
},
});
expect(document.body.innerHTML).toMatchSnapshot();
@ -178,7 +178,7 @@ describe('telepath: wagtail.blocks.StructBlock', () => {
test('setError shows non-block errors', () => {
boundBlock.setError({
messages: ['This is just generally wrong'],
messages: ['This is just generally wrong.'],
});
expect(document.body.innerHTML).toMatchSnapshot();
});

Wyświetl plik

@ -5,7 +5,7 @@ exports[`telepath: wagtail.blocks.FieldBlock catches widget render errors it ren
<div class="w-field w-field--char_field w-field--text_input w-field--error" data-field="">
<div class="w-field__errors" id="the-prefix-errors" data-field-errors="">
<svg class="icon icon-warning w-field__errors-icon" aria-hidden="true"><use href="#icon-warning"></use></svg>
<p class="error-message"><span>This widget failed to render, please check the console for details</span></p></div>
<p class="error-message">This widget failed to render, please check the console for details.</p></div>
<div class="w-field__help" id="the-prefix-helptext" data-field-help=""></div>
<div class="w-field__input" data-field-input="">
<div data-streamfield-widget=""></div>
@ -33,7 +33,7 @@ exports[`telepath: wagtail.blocks.FieldBlock setError() renders errors 1`] = `
<div class="w-field w-field--char_field w-field--text_input w-field--error" data-field="">
<div class="w-field__errors" id="the-prefix-errors" data-field-errors="">
<svg class="icon icon-warning w-field__errors-icon" aria-hidden="true"><use href="#icon-warning"></use></svg>
<p class="error-message"><span>Field must not contain the letter E</span><span>Field must contain a story about kittens</span></p></div>
<p class="error-message">Field must not contain the letter E. Field must contain a story about kittens.</p></div>
<div class="w-field__help" id="the-prefix-helptext" data-field-help=""><p class="help">drink <em>more</em> water</p></div>
<div class="w-field__input" data-field-input="">
<p name="the-prefix" id="the-prefix">The widget</p>

Wyświetl plik

@ -1075,7 +1075,7 @@ exports[`telepath: wagtail.blocks.ListBlock setError passes error messages to ch
<div class="w-field w-field--char_field w-field--admin_auto_height_text_input w-field--error" data-field="">
<div class="w-field__errors" id="the-prefix-1-value-errors" data-field-errors="">
<svg class="icon icon-warning w-field__errors-icon" aria-hidden="true"><use href="#icon-warning"></use></svg>
<p class="error-message"><span>Not as good as the first one</span></p></div>
<p class="error-message">Not as good as the first one.</p></div>
<div class="w-field__help" id="the-prefix-1-value-helptext" data-field-help=""></div>
<div class="w-field__input" data-field-input="">
<p name="the-prefix-1-value" id="the-prefix-1-value">The widget</p>

Wyświetl plik

@ -905,7 +905,7 @@ exports[`telepath: wagtail.blocks.StreamBlock setError renders error messages 1`
<div class="w-field w-field--char_field w-field--admin_auto_height_text_input w-field--error" data-field="">
<div class="w-field__errors" id="the-prefix-1-value-errors" data-field-errors="">
<svg class="icon icon-warning w-field__errors-icon" aria-hidden="true"><use href="#icon-warning"></use></svg>
<p class="error-message"><span>Not as good as the first one</span></p></div>
<p class="error-message">Not as good as the first one.</p></div>
<div class="w-field__help" id="the-prefix-1-value-helptext" data-field-help=""></div>
<div class="w-field__input" data-field-input="">
<p name="the-prefix-1-value" id="the-prefix-1-value">Block B widget</p>

Wyświetl plik

@ -64,7 +64,7 @@ exports[`telepath: wagtail.blocks.StructBlock setError passes error messages to
<div class="w-field w-field--choice_field w-field--select w-field--error" data-field="">
<div class="w-field__errors" id="the-prefix-size-errors" data-field-errors="">
<svg class="icon icon-warning w-field__errors-icon" aria-hidden="true"><use href="#icon-warning"></use></svg>
<p class="error-message"><span>This is too big</span></p></div>
<p class="error-message">This is too big.</p></div>
<div class="w-field__help" id="the-prefix-size-helptext" data-field-help=""></div>
<div class="w-field__input" data-field-input="">
<p name="the-prefix-size" id="the-prefix-size">Size widget</p>
@ -75,7 +75,7 @@ exports[`telepath: wagtail.blocks.StructBlock setError passes error messages to
`;
exports[`telepath: wagtail.blocks.StructBlock setError shows non-block errors 1`] = `
"<div class="struct-block"><p class="help-block help-critical">This is just generally wrong</p>
"<div class="struct-block"><p class="help-block help-critical">This is just generally wrong.</p>
<div class="c-sf-help">
<div class="help">

Wyświetl plik

@ -158,7 +158,7 @@ exports[`wagtail.contrib.typed_table_block.blocks.TypedTableBlock setError passe
<div class="w-field w-field--char_field w-field--admin_auto_height_text_input w-field--error" data-field="">
<div class="w-field__errors" id="mytable-cell-0-1-errors" data-field-errors="">
<svg class="icon icon-warning w-field__errors-icon" aria-hidden="true"><use href="#icon-warning"></use></svg>
<p class="error-message"><span>This is not enough cheese</span></p></div>
<p class="error-message">This is not enough cheese.</p></div>
<div class="w-field__help" id="mytable-cell-0-1-helptext" data-field-help=""></div>
<div class="w-field__input" data-field-input="">
<p name="mytable-cell-0-1" id="mytable-cell-0-1">Block B widget</p>
@ -213,7 +213,7 @@ exports[`wagtail.contrib.typed_table_block.blocks.TypedTableBlock setError passe
`;
exports[`wagtail.contrib.typed_table_block.blocks.TypedTableBlock setError shows non-block errors 1`] = `
"<div class="typed-table-block "><p class="help-block help-critical">This is just generally wrong</p>
"<div class="typed-table-block "><p class="help-block help-critical">This is just generally wrong.</p>
<div class="w-field__wrapper" data-field-wrapper="">
<label class="w-field__label" for="mytable-caption">
Caption

Wyświetl plik

@ -211,7 +211,7 @@ describe('wagtail.contrib.typed_table_block.blocks.TypedTableBlock', () => {
boundBlock.setError({
blockErrors: {
0: {
1: { messages: ['This is not enough cheese'] },
1: { messages: ['This is not enough cheese.'] },
},
},
});
@ -220,7 +220,7 @@ describe('wagtail.contrib.typed_table_block.blocks.TypedTableBlock', () => {
test('setError shows non-block errors', () => {
boundBlock.setError({
messages: ['This is just generally wrong'],
messages: ['This is just generally wrong.'],
});
expect(document.body.innerHTML).toMatchSnapshot();
});