mirror of
https://github.com/n8n-io/n8n.git
synced 2026-05-29 15:57:00 +02:00
fix(editor): Ensure license activation modal works when used without EULA (#21681)
This commit is contained in:
parent
9e240d6d74
commit
4e70050ab2
|
|
@ -123,6 +123,34 @@ describe('SettingsUsageAndPlan', () => {
|
|||
expect(container.querySelector('.n8n-badge')).toHaveTextContent('Registered');
|
||||
});
|
||||
|
||||
it('should correctly call activateLicense on non-eula acceptance', async () => {
|
||||
usageStore.isLoading = false;
|
||||
usageStore.planName = 'Community';
|
||||
usersStore.currentUser = {
|
||||
globalScopes: ['license:manage'],
|
||||
} as IUser;
|
||||
rbacStore.setGlobalScopes(['license:manage']);
|
||||
usageStore.activateLicense.mockImplementation(async () => {});
|
||||
|
||||
const { getByRole } = renderComponent();
|
||||
|
||||
await userEvent.click(getByRole('button', { name: /activation/i }));
|
||||
const input = document.querySelector('input') as HTMLInputElement;
|
||||
await userEvent.type(input, 'test-key-123');
|
||||
await userEvent.click(getByRole('button', { name: /activate/i }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(usageStore.activateLicense).toHaveBeenCalledTimes(1);
|
||||
expect(usageStore.activateLicense).toHaveBeenLastCalledWith('test-key-123', undefined);
|
||||
});
|
||||
|
||||
expect(mockToast.showMessage).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
type: 'success',
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
describe('License activation with EULA', () => {
|
||||
it('should show EULA modal when activation fails with 400 error and eulaUrl', async () => {
|
||||
usageStore.isLoading = false;
|
||||
|
|
@ -249,7 +277,7 @@ describe('SettingsUsageAndPlan', () => {
|
|||
await userEvent.click(getByRole('button', { name: /activate/i }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(mockToast.showError).toHaveBeenCalledWith(error, expect.any(String));
|
||||
expect(mockToast.showError).toHaveBeenCalledWith(error, 'Activation failed');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ const isEulaError = (error: unknown): error is EulaErrorResponse => {
|
|||
|
||||
const onLicenseActivation = async (eulaUri?: string) => {
|
||||
try {
|
||||
await usageStore.activateLicense(activationKey.value, eulaUri);
|
||||
await usageStore.activateLicense(activationKey.value.trim(), eulaUri?.trim());
|
||||
activationKeyModal.value = false;
|
||||
eulaModal.value = false;
|
||||
activationKey.value = '';
|
||||
|
|
@ -321,7 +321,7 @@ const openCommunityRegisterModal = () => {
|
|||
<N8nButton type="secondary" @click="activationKeyModal = false">
|
||||
{{ locale.baseText('settings.usageAndPlan.dialog.activation.cancel') }}
|
||||
</N8nButton>
|
||||
<N8nButton :disabled="!activationKey" @click="onLicenseActivation">
|
||||
<N8nButton :disabled="!activationKey" @click="() => onLicenseActivation()">
|
||||
{{ locale.baseText('settings.usageAndPlan.dialog.activation.activate') }}
|
||||
</N8nButton>
|
||||
</template>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user