Skip to content

Commit 93e64fe

Browse files
committed
refactor: remove the elements for showing errors from DOM when there is no errors
This also should simplify our integration tests because now they can wait only for element presence. Previously they also had to wait for an error message. Relate to #1411
1 parent 75fd26c commit 93e64fe

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/main/frontend/src/components/AddCommentForm.js

+12-11
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,13 @@ class AddCommentFormView extends React.PureComponent {
9898
aria-label={ l10n['t_add_comment'] || 'Add a comment' }
9999
className={ `form-horizontal ${hasValidationErrors ? 'has-error' : ''}` }
100100
onSubmit={ handleSubmit }>
101-
<div
102-
id="add-comment-failed-msg"
103-
role="alert"
104-
className={ `alert alert-danger text-center col-sm-8 col-sm-offset-2 ${hasServerError ? '' : 'hidden'}` }>
105-
{ l10n['t_server_error'] || 'Server error' }
106-
</div>
101+
{ hasServerError &&
102+
<div id="add-comment-failed-msg"
103+
role="alert"
104+
className="alert alert-danger text-center col-sm-8 col-sm-offset-2">
105+
{ l10n['t_server_error'] || 'Server error' }
106+
</div>
107+
}
107108
<div className="form-group form-group-sm">
108109
<label htmlFor="new-comment" className="control-label col-sm-3 required-field">
109110
{ l10n['t_comment'] || 'Comment' }
@@ -120,11 +121,11 @@ class AddCommentFormView extends React.PureComponent {
120121
</div>
121122
</div>
122123
<div className="col-sm-offset-3 col-sm-4">
123-
<span
124-
id="new-comment.errors"
125-
className={ `help-block ${hasValidationErrors ? '' : 'hidden'}` }>
126-
{ validationErrors.join(', ') }
127-
</span>
124+
{ hasValidationErrors &&
125+
<span id="new-comment.errors" className="help-block">
126+
{ validationErrors.join(', ') }
127+
</span>
128+
}
128129
<button
129130
type="submit"
130131
className="btn btn-primary btn-sm"

src/main/frontend/src/components/AddCommentForm.test.js

-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ describe('AddCommentFormView', () => {
4141
// then
4242
const alert = screen.getByRole('alert');
4343
expect(alert).toHaveTextContent('Server error');
44-
expect(alert).not.toHaveClass('hidden');
4544
});
4645

4746
it('the comment field', () => {
@@ -58,7 +57,6 @@ describe('AddCommentFormView', () => {
5857
// @todo #1489 Use toHaveErrorMessage() or toHaveDescription() for checking error messages
5958
const fieldErrors = container.querySelector('#new-comment\\.errors');
6059
expect(fieldErrors).not.toBeNull();
61-
expect(fieldErrors).not.toHaveClass('hidden');
6260
expect(fieldErrors).toHaveTextContent('err1, err2');
6361
});
6462
});

src/main/java/ru/mystamps/web/feature/site/ResourceUrl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public final class ResourceUrl {
3232
public static final String STATIC_RESOURCES_URL = "https://stamps.filezz.ru";
3333

3434
// MUST be updated when any of our resources were modified
35-
public static final String RESOURCES_VERSION = "v0.4.5.3";
35+
public static final String RESOURCES_VERSION = "v0.4.5.4";
3636

3737
// CheckStyle: ignore LineLength for next 16 lines
3838
private static final String CATALOG_UTILS_JS = "/public/js/" + RESOURCES_VERSION + "/CatalogUtils.min.js";

0 commit comments

Comments
 (0)