mirror of
https://github.com/philomena-dev/philomena.git
synced 2025-01-19 22:27:59 +01:00
mocking out a test that actually compiles
This commit is contained in:
parent
b7733a2ae5
commit
204e48d05b
2 changed files with 20 additions and 3 deletions
|
@ -87,11 +87,11 @@ describe('Image upload form', () => {
|
|||
|
||||
<input id="image_sources_0_source" name="image[sources][0][source]" type="text" class="js-source-url" />
|
||||
<textarea id="image_tag_input" name="image[tag_input]" class="js-image-tags-input"></textarea>
|
||||
<div class="js-taginput" value="safe, pony, third tag"/>
|
||||
<div class="js-taginput" value="safe, pony"></div>
|
||||
<button id="tagsinput-save" type="button" class="button">Save</button>
|
||||
<textarea id="image_description" name="image[description]" class="js-image-descr-input"></textarea>
|
||||
<div class="actions">
|
||||
<button class="button" type="submit">Upload</button>
|
||||
<button class="button input--separate-top" type="submit">Upload</button>
|
||||
</div>
|
||||
</form>`,
|
||||
);
|
||||
|
@ -210,4 +210,21 @@ describe('Image upload form', () => {
|
|||
expect(scraperError.innerText).toEqual('Error 1 Error 2');
|
||||
});
|
||||
});
|
||||
|
||||
it('should prevent form submission if tag checks fail', async () => {
|
||||
await new Promise<void>(resolve => {
|
||||
form.addEventListener('submit', event => {
|
||||
event.preventDefault();
|
||||
resolve();
|
||||
});
|
||||
fireEvent.submit(form);
|
||||
});
|
||||
|
||||
const succeededUnloadEvent = new Event('beforeunload', { cancelable: true });
|
||||
expect(fireEvent(window, succeededUnloadEvent)).toBe(true);
|
||||
await waitFor(() => {
|
||||
assertSubmitButtonIsEnabled();
|
||||
expect(form.querySelectorAll('.help-block')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -238,7 +238,7 @@ function setupImageUpload() {
|
|||
}
|
||||
|
||||
function disableUploadButton() {
|
||||
const submitButton = $('.input--separate-top');
|
||||
const submitButton = $('.button.input--separate-top');
|
||||
if (submitButton !== null) {
|
||||
submitButton.disabled = true;
|
||||
submitButton.innerText = 'Please wait...';
|
||||
|
|
Loading…
Reference in a new issue