Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Submit form using click handler #776

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cypress/e2e/NewLexemeForm.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ describe( 'NewLexemeForm', () => {
.type( '=Q456', { delay: 0 } );
cy.get( '.wbl-snl-lexical-category-lookup .wikit-OptionsMenu__item' ).click();

cy.get( '.wbl-snl-form' )
.submit();
cy.get( '.wbl-snl-form button' )
.click();

cy.get( '@alert' ).then( ( spy ) => {
expect( spy ).to.have.been.calledWith(
Expand Down Expand Up @@ -111,8 +111,8 @@ describe( 'NewLexemeForm', () => {
.type( 'en-ca', { delay: 0 } );
cy.get( '.wbl-snl-spelling-variant-lookup .wikit-OptionsMenu__item' ).click();

cy.get( '.wbl-snl-form' )
.submit();
cy.get( '.wbl-snl-form button' )
.click();

cy.get( '@alert' ).then( ( spy ) => {
expect( spy ).to.have.been.calledWith(
Expand Down Expand Up @@ -166,8 +166,8 @@ describe( 'NewLexemeForm', () => {
expect( $input ).to.have.value( 'Q456' );
} );

cy.get( '.wbl-snl-form' )
.submit();
cy.get( '.wbl-snl-form button' )
.click();

cy.get( '@alert' ).then( ( spy ) => {
expect( spy ).to.have.been.calledWith(
Expand Down
3 changes: 2 additions & 1 deletion src/components/NewLexemeForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export default {
</script>

<template>
<form class="wbl-snl-form" @submit.prevent="onSubmit">
<form class="wbl-snl-form">
<lemma-input
v-model="lemma"
/>
Expand Down Expand Up @@ -182,6 +182,7 @@ export default {
weight="primary"
type="submit"
:disabled="submitting"
@click.prevent="onSubmit"
>
{{ submitButtonText }}
</cdx-button>
Expand Down
14 changes: 7 additions & 7 deletions tests/integration/NewLexemeForm.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ describe( 'NewLexemeForm', () => {
const spellingVariantInput = wrapper.find( '.wbl-snl-spelling-variant-lookup input' );
expect( spellingVariantInput.exists() ).toBe( false );

await wrapper.trigger( 'submit' );
await wrapper.find( 'button' ).trigger( 'click' );
await flushPromises();

expect( createLexeme ).toHaveBeenCalledWith( 'foo', 'de', 'Q123', 'Q456' );
Expand Down Expand Up @@ -237,7 +237,7 @@ describe( 'NewLexemeForm', () => {
await spellingVariantInput.setValue( 'en' );
await wrapper.find( '.wbl-snl-spelling-variant-lookup .wikit-OptionsMenu__item' ).trigger( 'click' );

await wrapper.trigger( 'submit' );
await wrapper.find( 'button' ).trigger( 'click' );
await flushPromises();

expect( createLexeme ).toHaveBeenCalledWith( 'foo', 'en-gb', 'Q123', 'Q456' );
Expand Down Expand Up @@ -271,7 +271,7 @@ describe( 'NewLexemeForm', () => {
const spellingVariantInput = wrapper.find( '.wbl-snl-spelling-variant-lookup input' );
expect( spellingVariantInput.exists() ).toBe( false );

await wrapper.trigger( 'submit' );
await wrapper.find( 'button' ).trigger( 'click' );

const submitButton = wrapper.find( '.cdx-button' );
expect( submitButton.attributes( 'disabled' ) ).toBe( '' );
Expand Down Expand Up @@ -306,7 +306,7 @@ describe( 'NewLexemeForm', () => {
await selectLanguage( wrapper, '=Q123' );
await selectLexicalCategory( wrapper, '=Q456' );

await wrapper.trigger( 'submit' );
await wrapper.find( 'button' ).trigger( 'click' );

const lemmaInputWrapper = wrapper.get( '.wbl-snl-lemma-input' );
expect( lemmaInputWrapper.get( '.cdx-message--error' ).text() ).toBe( messagesPlugin.get( 'wikibaselexeme-newlexeme-lemma-empty-error' ) );
Expand Down Expand Up @@ -336,7 +336,7 @@ describe( 'NewLexemeForm', () => {
await setLemmaInput( wrapper, 'foo' );
await selectLanguage( wrapper, '=Q123' );

await wrapper.trigger( 'submit' );
await wrapper.find( 'button' ).trigger( 'click' );

const lexicalCategoryInputWrapper = wrapper.get( '.wbl-snl-lexical-category-lookup' );
expect( lexicalCategoryInputWrapper.get( '.wikit-ValidationMessage--error' ).text() )
Expand Down Expand Up @@ -366,7 +366,7 @@ describe( 'NewLexemeForm', () => {
await setLemmaInput( wrapper, 'foo' );
await selectLexicalCategory( wrapper, '=Q456' );

await wrapper.trigger( 'submit' );
await wrapper.find( 'button' ).trigger( 'click' );

const languageInputWrapper = wrapper.get( '.wbl-snl-language-lookup' );
expect( languageInputWrapper.get( '.wikit-ValidationMessage--error' ).text() )
Expand Down Expand Up @@ -403,7 +403,7 @@ describe( 'NewLexemeForm', () => {
await selectLanguage( wrapper );
await selectLexicalCategory( wrapper );

await wrapper.trigger( 'submit' );
await wrapper.find( 'button' ).trigger( 'click' );

const spellingVariantInputWrapper = wrapper.get( '.wbl-snl-spelling-variant-lookup' );
expect( spellingVariantInputWrapper.get( '.wikit-ValidationMessage--error' ).text() )
Expand Down