@@ -10,6 +10,7 @@ import {
1010 assertedVersionsCompatible ,
1111 clearAssertedVersions ,
1212} from '../../utils/version' ;
13+ import { LICENSE_KEY_PLACEHOLDER } from './const' ;
1314import {
1415 parseLicenseKey ,
1516 setLicenseCheckSkipCondition ,
@@ -294,9 +295,11 @@ describe('license check', () => {
294295 const TOKEN_UNSUPPORTED_VERSION = 'ewogICJmb3JtYXQiOiAyLAogICJjdXN0b21lcklkIjogImIxMTQwYjQ2LWZkZTEtNDFiZC1hMjgwLTRkYjlmOGU3ZDliZCIsCiAgIm1heFZlcnNpb25BbGxvd2VkIjogMjMxCn0=.tTBymZMROsYyMiP6ldXFqGurbzqjhSQIu/pjyEUJA3v/57VgToomYl7FVzBj1asgHpadvysyTUiX3nFvPxbp166L3+LB3Jybw9ueMnwePu5vQOO0krqKLBqRq+TqHKn7k76uYRbkCIo5UajNfzetHhlkin3dJf3x2K/fcwbPW5A=' ;
295296
296297 let trialPanelSpy = jest . spyOn ( trialPanel , 'renderTrialPanel' ) ;
298+ let consoleWarnSpy = jest . spyOn ( console , 'warn' ) ;
297299
298300 beforeEach ( ( ) => {
299301 jest . spyOn ( errors , 'log' ) . mockImplementation ( ( ) => { } ) ;
302+ consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
300303 trialPanelSpy = jest . spyOn ( trialPanel , 'renderTrialPanel' ) ;
301304 setLicenseCheckSkipCondition ( false ) ;
302305 } ) ;
@@ -309,10 +312,11 @@ describe('license check', () => {
309312 { token : '' , version : '1.0.3' } ,
310313 { token : null , version : '1.0.4' } ,
311314 { token : undefined , version : '1.0.50' } ,
312- ] ) ( 'W0019 error should be logged if license is empty' , ( { token, version } ) => {
315+ { token : LICENSE_KEY_PLACEHOLDER , version : '1.0.3' } ,
316+ ] ) ( 'Warning should be logged with no-key message if license is empty' , ( { token, version } ) => {
313317 validateLicense ( token as string , version ) ;
314- expect ( errors . log ) . toHaveBeenCalledTimes ( 1 ) ;
315- expect ( errors . log ) . toHaveBeenCalledWith ( 'W0019' ) ;
318+ expect ( consoleWarnSpy ) . toHaveBeenCalledTimes ( 2 ) ;
319+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'devextreme-license generated key has not been specified' ) ) ;
316320 } ) ;
317321
318322 test . each ( [
@@ -322,52 +326,29 @@ describe('license check', () => {
322326 { token : '' , version : '1.0.0' } ,
323327 { token : null , version : '1.2.4-preview' } ,
324328 { token : undefined , version : '1.2' } ,
329+ { token : LICENSE_KEY_PLACEHOLDER , version : '1.0.3' } ,
330+ { token : LICENSE_KEY_PLACEHOLDER , version : '1.0.0' } ,
325331 ] ) ( 'trial panel should be displayed if license is empty, preview or not' , ( { token, version } ) => {
326332 validateLicense ( token as string , version ) ;
327333 expect ( trialPanelSpy ) . toHaveBeenCalledTimes ( 1 ) ;
328334 } ) ;
329335
330- test . each ( [
331- { token : '' , version : '1.0' } ,
332- { token : null , version : '1.0.' } ,
333- { token : undefined , version : '1.0.0' } ,
334- { token : TOKEN_23_1 , version : '23.1.0' } ,
335- { token : TOKEN_23_1 , version : '12.3.1' } ,
336- { token : TOKEN_23_2 , version : '23.1.2' } ,
337- { token : TOKEN_23_2 , version : '23.2.3-preview' } ,
338- { token : TOKEN_23_1 , version : '23.2.0' } ,
339- { token : TOKEN_23_2 , version : '42.4.3-alfa' } ,
340- { token : TOKEN_UNVERIFIED , version : '1.2.0' } ,
341- { token : TOKEN_INVALID_JSON , version : '1.2.1' } ,
342- { token : TOKEN_INVALID_BASE64 , version : '1.2.2' } ,
343- { token : TOKEN_MISSING_FIELD_1 , version : '1.2' } ,
344- { token : TOKEN_MISSING_FIELD_2 , version : '1.2.4-preview' } ,
345- { token : TOKEN_MISSING_FIELD_3 , version : '1.2.' } ,
346- { token : TOKEN_UNSUPPORTED_VERSION , version : '1.2.abc' } ,
347- { token : 'Another' , version : '1.2.0' } ,
348- { token : '3.2.1' , version : '1.2.1' } ,
349- { token : TOKEN_23_1 , version : '123' } ,
350- ] ) ( 'W0022 error should be logged if version is preview [%#]' , ( { token, version } ) => {
351- validateLicense ( token as string , version ) ;
352- expect ( errors . log ) . toHaveBeenCalledWith ( 'W0022' ) ;
353- } ) ;
354-
355336 test . each ( [
356337 { token : TOKEN_23_1 , version : '23.1.3' } ,
357338 { token : TOKEN_23_1 , version : '12.3.4' } ,
358339 { token : TOKEN_23_2 , version : '23.1.5' } ,
359340 { token : TOKEN_23_2 , version : '23.2.6' } ,
360- ] ) ( 'No messages should be logged if license is valid ' , ( { token, version } ) => {
341+ ] ) ( 'Old format license within version range should not trigger warnings ' , ( { token, version } ) => {
361342 validateLicense ( token , version ) ;
362- expect ( errors . log ) . not . toHaveBeenCalled ( ) ;
343+ expect ( consoleWarnSpy ) . not . toHaveBeenCalled ( ) ;
363344 } ) ;
364345
365346 test . each ( [
366347 { token : TOKEN_23_1 , version : '23.1.3' } ,
367348 { token : TOKEN_23_1 , version : '12.3.4' } ,
368349 { token : TOKEN_23_2 , version : '23.1.5' } ,
369350 { token : TOKEN_23_2 , version : '23.2.6' } ,
370- ] ) ( 'Trial panel should not be displayed if license is valid ' , ( { token, version } ) => {
351+ ] ) ( 'Trial panel should not be displayed for valid old format license keys ' , ( { token, version } ) => {
371352 validateLicense ( token , version ) ;
372353 expect ( trialPanelSpy ) . not . toHaveBeenCalled ( ) ;
373354 } ) ;
@@ -388,7 +369,7 @@ describe('license check', () => {
388369 validateLicense ( '' , '1.0' ) ;
389370 validateLicense ( '' , '1.0' ) ;
390371
391- expect ( errors . log ) . toHaveBeenCalledTimes ( 1 ) ;
372+ expect ( consoleWarnSpy ) . toHaveBeenCalledTimes ( 2 ) ;
392373 } ) ;
393374
394375 test ( 'Base z-index should match the corresponding setting in DevExtreme' , ( ) => {
@@ -399,15 +380,16 @@ describe('license check', () => {
399380 setLicenseCheckSkipCondition ( ) ;
400381 validateLicense ( '' , '1.0' ) ;
401382 expect ( errors . log ) . not . toHaveBeenCalled ( ) ;
383+ expect ( consoleWarnSpy ) . not . toHaveBeenCalled ( ) ;
402384 } ) ;
403385
404386 test . each ( [
405387 { token : TOKEN_23_1 , version : '23.2.3' } ,
406388 { token : TOKEN_23_2 , version : '42.4.5' } ,
407- ] ) ( 'W0020 error should be logged if license is outdated' , ( { token, version } ) => {
389+ ] ) ( 'Old format license should trigger version-mismatch warning when outdated' , ( { token, version } ) => {
408390 validateLicense ( token , version ) ;
409- expect ( errors . log ) . toHaveBeenCalledTimes ( 1 ) ;
410- expect ( errors . log ) . toHaveBeenCalledWith ( 'W0020' ) ;
391+ expect ( consoleWarnSpy ) . toHaveBeenCalledTimes ( 2 ) ;
392+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'Incompatible DevExpress license key version' ) ) ;
411393 } ) ;
412394
413395 test . each ( [
@@ -425,7 +407,7 @@ describe('license check', () => {
425407 { token : TOKEN_23_1 , version : '23.2.3-alpha' } ,
426408 { token : TOKEN_23_2 , version : '24.1.0' } ,
427409 { token : TOKEN_23_2 , version : '24.1.abc' } ,
428- ] ) ( 'Trial panel should not be displayed in previews if the license is for the previous RTM ' , ( { token, version } ) => {
410+ ] ) ( 'Trial panel should not be displayed in previews for valid old format license keys ' , ( { token, version } ) => {
429411 validateLicense ( token , version ) ;
430412 expect ( trialPanelSpy ) . not . toHaveBeenCalled ( ) ;
431413 } ) ;
@@ -440,9 +422,10 @@ describe('license check', () => {
440422 { token : TOKEN_UNSUPPORTED_VERSION , version : '1.2.3' } ,
441423 { token : 'str@nge in.put' , version : '1.2.3' } ,
442424 { token : '3.2.1' , version : '1.2.3' } ,
443- ] ) ( 'W0021 error should be logged if license is corrupted/invalid [%#]' , ( { token, version } ) => {
425+ ] ) ( 'License verification warning should be logged if license is corrupted/invalid [%#]' , ( { token, version } ) => {
444426 validateLicense ( token , version ) ;
445- expect ( errors . log ) . toHaveBeenCalledWith ( 'W0021' ) ;
427+ expect ( consoleWarnSpy ) . toHaveBeenCalledTimes ( 2 ) ;
428+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'License key verification has failed' ) ) ;
446429 } ) ;
447430
448431 test . each ( [
@@ -503,20 +486,15 @@ describe('internal license check', () => {
503486 expect ( errors . log ) . toHaveBeenCalledWith ( 'W0020' ) ;
504487 expect ( trialPanelSpy ) . not . toHaveBeenCalled ( ) ;
505488 } ) ;
506-
507- test ( 'internal usage token (incorrect, pre-release)' , ( ) => {
508- const token = 'ewogICJpbnRlcm5hbFVzYWdlSWQiOiAiUDdmNU5icU9WMDZYRFVpa3Q1bkRyQSIsCiAgImZvcm1hdCI6IDEKfQ==.ox52WAqudazQ0ZKdnJqvh/RmNNNX+IB9cmun97irvSeZK2JMf9sbBXC1YCrSZNIPBjQapyIV8Ctv9z2wzb3BkWy+R9CEh+ev7purq7Lk0ugpwDye6GaCzqlDg+58EHwPCNaasIuBiQC3ztvOItrGwWSu0aEFooiajk9uAWwzWeM=' ;
509- validateLicense ( token , '1.2.1' ) ;
510- expect ( errors . log ) . toHaveBeenCalledWith ( 'W0022' ) ;
511- expect ( trialPanelSpy ) . not . toHaveBeenCalled ( ) ;
512- } ) ;
513489} ) ;
514490
515491describe ( 'DevExpress license check' , ( ) => {
516492 let trialPanelSpy = jest . spyOn ( trialPanel , 'renderTrialPanel' ) ;
493+ let consoleWarnSpy = jest . spyOn ( console , 'warn' ) ;
517494
518495 beforeEach ( ( ) => {
519496 jest . spyOn ( errors , 'log' ) . mockImplementation ( ( ) => { } ) ;
497+ consoleWarnSpy = jest . spyOn ( console , 'warn' ) . mockImplementation ( ( ) => { } ) ;
520498 trialPanelSpy = jest . spyOn ( trialPanel , 'renderTrialPanel' ) ;
521499 setLicenseCheckSkipCondition ( false ) ;
522500 } ) ;
@@ -528,14 +506,16 @@ describe('DevExpress license check', () => {
528506 test ( 'DevExpress License Key copied from Download Manager (incorrect)' , ( ) => {
529507 const token = 'LCXv1therestofthekey' ;
530508 validateLicense ( token , '25.1.3' ) ;
531- expect ( errors . log ) . toHaveBeenCalled ( ) ;
509+ expect ( consoleWarnSpy ) . toHaveBeenCalledTimes ( 2 ) ;
510+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'DevExpress license key has been specified instead of a key generated using devextreme-license' ) ) ;
532511 expect ( trialPanelSpy ) . toHaveBeenCalled ( ) ;
533512 } ) ;
534513
535514 test ( 'DevExpress License Key generated from LCX key (incorrect)' , ( ) => {
536515 const token = 'LCPtherestofthekey' ;
537516 validateLicense ( token , '25.1.3' ) ;
538- expect ( errors . log ) . toHaveBeenCalled ( ) ;
517+ expect ( consoleWarnSpy ) . toHaveBeenCalledTimes ( 2 ) ;
518+ expect ( consoleWarnSpy ) . toHaveBeenCalledWith ( expect . stringContaining ( 'License key verification has failed' ) ) ;
539519 expect ( trialPanelSpy ) . toHaveBeenCalled ( ) ;
540520 } ) ;
541521} ) ;
0 commit comments