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

fix(editor): No need to add click emitting click events, VUE delegates the handler to the root element of the component #7182

Merged
merged 2 commits into from
Sep 15, 2023
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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