mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 11:49:59 +00:00
perf(core): Eliminate unnecessary license server calls (#17047)
This commit is contained in:
@@ -76,6 +76,15 @@ describe('LicenseService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('renewLicense', () => {
|
describe('renewLicense', () => {
|
||||||
|
test('should skip renewal for unlicensed user (Community plan)', async () => {
|
||||||
|
license.getPlanName.mockReturnValueOnce('Community');
|
||||||
|
|
||||||
|
await licenseService.renewLicense();
|
||||||
|
|
||||||
|
expect(license.renew).not.toHaveBeenCalled();
|
||||||
|
expect(eventService.emit).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
test('on success', async () => {
|
test('on success', async () => {
|
||||||
license.renew.mockResolvedValueOnce();
|
license.renew.mockResolvedValueOnce();
|
||||||
await licenseService.renewLicense();
|
await licenseService.renewLicense();
|
||||||
|
|||||||
@@ -120,6 +120,8 @@ export class LicenseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async renewLicense() {
|
async renewLicense() {
|
||||||
|
if (this.license.getPlanName() === 'Community') return; // unlicensed, nothing to renew
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.license.renew();
|
await this.license.renew();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ describe('POST /license/renew', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('errors out properly', async () => {
|
test('errors out properly', async () => {
|
||||||
|
License.prototype.getPlanName = jest.fn().mockReturnValue('Enterprise');
|
||||||
License.prototype.renew = jest.fn().mockImplementation(() => {
|
License.prototype.renew = jest.fn().mockImplementation(() => {
|
||||||
throw new Error(GENERIC_ERROR_MESSAGE);
|
throw new Error(GENERIC_ERROR_MESSAGE);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user