mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
perf(core): Eliminate unnecessary license server calls (#17047)
This commit is contained in:
@@ -76,6 +76,15 @@ describe('LicenseService', () => {
|
||||
});
|
||||
|
||||
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 () => {
|
||||
license.renew.mockResolvedValueOnce();
|
||||
await licenseService.renewLicense();
|
||||
|
||||
@@ -120,6 +120,8 @@ export class LicenseService {
|
||||
}
|
||||
|
||||
async renewLicense() {
|
||||
if (this.license.getPlanName() === 'Community') return; // unlicensed, nothing to renew
|
||||
|
||||
try {
|
||||
await this.license.renew();
|
||||
} catch (e) {
|
||||
|
||||
@@ -101,6 +101,7 @@ describe('POST /license/renew', () => {
|
||||
});
|
||||
|
||||
test('errors out properly', async () => {
|
||||
License.prototype.getPlanName = jest.fn().mockReturnValue('Enterprise');
|
||||
License.prototype.renew = jest.fn().mockImplementation(() => {
|
||||
throw new Error(GENERIC_ERROR_MESSAGE);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user