mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-09 22:24:05 -08:00
fix(editor): No need to add click emitting click events, VUE delegates the handler to the root element of the component (#7182)
This commit is contained in:
parent
c18ba370d5
commit
3c055e4d8d
|
@ -1,11 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<div :class="$style.container">
|
<div :class="$style.container">
|
||||||
<GoogleAuthButton v-if="isGoogleOAuthType" @click.stop="$emit('click')" />
|
<GoogleAuthButton v-if="isGoogleOAuthType" />
|
||||||
<n8n-button
|
<n8n-button
|
||||||
v-else
|
v-else
|
||||||
:label="$locale.baseText('credentialEdit.oAuthButton.connectMyAccount')"
|
:label="$locale.baseText('credentialEdit.oAuthButton.connectMyAccount')"
|
||||||
size="large"
|
size="large"
|
||||||
@click.stop="$emit('click')"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -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);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue