mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-11 23:43:24 +09:00
refactor: form binding validation (#38832)
Make "form-fetch-action" highlight the invalid field as "error"
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import {execPseudoSelectorCommands, handleFetchActionSuccessJson} from './common-fetch-action.ts';
|
||||
import {execPseudoSelectorCommands, handleFetchActionErrorFields, handleFetchActionSuccessJson} from './common-fetch-action.ts';
|
||||
import {createElementFromHTML} from '../utils/dom.ts';
|
||||
import {normalizeTestHtml} from '../utils/testhelper.ts';
|
||||
|
||||
test('execPseudoSelectorCommands', () => {
|
||||
window.document.body.innerHTML = `
|
||||
@@ -57,3 +59,15 @@ test('handleFetchActionSuccessJson', async () => {
|
||||
expect(spyReload).toHaveBeenCalledTimes(1);
|
||||
vi.resetAllMocks();
|
||||
});
|
||||
|
||||
test('handleFetchActionErrorFields', () => {
|
||||
const elForm = createElementFromHTML<HTMLElement>(`<form>
|
||||
<div class="error field"></div>
|
||||
<div class="field"><input name="Foo_Bar[]"></div>
|
||||
</form>`);
|
||||
handleFetchActionErrorFields(elForm, ['foo-BAR', 'other']);
|
||||
expect(normalizeTestHtml(elForm.outerHTML)).toEqual(normalizeTestHtml(`<form>
|
||||
<div class="field"></div>
|
||||
<div class="field error"><input name="Foo_Bar[]"></div>
|
||||
</form>`));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user