Skip to content

Commit

Permalink
fix(editor): No need to add click emitting click events, VUE delegate…
Browse files Browse the repository at this point in the history
…s the handler to the root element of the component (#7182)
  • Loading branch information
cstuncsik committed Sep 15, 2023
1 parent c18ba37 commit 3c055e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
@@ -1,11 +1,10 @@
<template>
<div :class="$style.container">
<GoogleAuthButton v-if="isGoogleOAuthType" @click.stop="$emit('click')" />
<GoogleAuthButton v-if="isGoogleOAuthType" />
<n8n-button
v-else
:label="$locale.baseText('credentialEdit.oAuthButton.connectMyAccount')"
size="large"
@click.stop="$emit('click')"
/>
</div>
</template>
Expand Down
@@ -0,0 +1,24 @@
import userEvent from '@testing-library/user-event';
import { createTestingPinia } from '@pinia/testing';
import { createComponentRenderer } from '@/__tests__/render';
import OauthButton from '@/components/CredentialEdit/OauthButton.vue';

const renderComponent = createComponentRenderer(OauthButton, {
pinia: createTestingPinia(),
});

describe('OauthButton', () => {
test.each([
['GoogleAuthButton', true],
['n8n-button', false],
])('should emit click event only once when %s is clicked', async (name, isGoogleOAuthType) => {
const { emitted, getByRole } = renderComponent({
props: { isGoogleOAuthType },
});

const button = getByRole('button');
await userEvent.click(button);

expect(emitted().click).toHaveLength(1);
});
});

0 comments on commit 3c055e4

Please sign in to comment.