perf(core): Eliminate unnecessary license server calls (#17047)

This commit is contained in:
Iván Ovejero
2025-07-07 10:55:40 +02:00
committed by GitHub
parent d3330b6bcc
commit 6efff79d72
3 changed files with 12 additions and 0 deletions

View File

@@ -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();

View File

@@ -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) {

View File

@@ -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);
});