@@ -69,7 +69,7 @@ suite('ExtensionsMerge', () => {
6969 aLocalSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
7070 ] ;
7171 const skippedExtension = [
72- anSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
72+ aSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
7373 ] ;
7474 const expected = [ ...localExtensions ] ;
7575
@@ -88,7 +88,7 @@ suite('ExtensionsMerge', () => {
8888 aLocalSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
8989 ] ;
9090 const skippedExtension = [
91- anSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
91+ aSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
9292 ] ;
9393 const expected = [ localExtensions [ 1 ] , localExtensions [ 2 ] ] ;
9494
@@ -106,8 +106,8 @@ suite('ExtensionsMerge', () => {
106106 aLocalSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
107107 ] ;
108108 const remoteExtensions = [
109- anSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
110- anSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
109+ aSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
110+ aSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
111111 ] ;
112112 const expected = [
113113 anExpectedSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -133,8 +133,8 @@ suite('ExtensionsMerge', () => {
133133 aLocalSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
134134 ] ;
135135 const remoteExtensions = [
136- anSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
137- anSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
136+ aSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
137+ aSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
138138 ] ;
139139 const expected = [
140140 anExpectedSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -155,16 +155,16 @@ suite('ExtensionsMerge', () => {
155155
156156 test ( 'merge local and remote extensions when remote is moved forwarded' , ( ) => {
157157 const baseExtensions = [
158- anSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
159- anSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
158+ aSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
159+ aSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
160160 ] ;
161161 const localExtensions = [
162162 aLocalSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
163163 aLocalSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
164164 ] ;
165165 const remoteExtensions = [
166- anSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
167- anSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
166+ aSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
167+ aSyncExtension ( { identifier : { id : 'c' , uuid : 'c' } } ) ,
168168 ] ;
169169
170170 const actual = merge ( localExtensions , remoteExtensions , baseExtensions , [ ] , [ ] , [ ] ) ;
@@ -238,7 +238,7 @@ suite('ExtensionsMerge', () => {
238238 aLocalSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
239239 ] ;
240240 const skippedExtensions = [
241- anSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
241+ aSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
242242 ] ;
243243 const remoteExtensions = [
244244 aRemoteSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -265,7 +265,7 @@ suite('ExtensionsMerge', () => {
265265 aLocalSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
266266 ] ;
267267 const skippedExtensions = [
268- anSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
268+ aSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
269269 ] ;
270270 const remoteExtensions = [
271271 aRemoteSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -364,7 +364,7 @@ suite('ExtensionsMerge', () => {
364364 aRemoteSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
365365 ] ;
366366 const skippedExtensions = [
367- anSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
367+ aSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
368368 ] ;
369369 const localExtensions = [
370370 aLocalSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -394,7 +394,7 @@ suite('ExtensionsMerge', () => {
394394 aRemoteSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
395395 ] ;
396396 const skippedExtensions = [
397- anSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
397+ aSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
398398 ] ;
399399 const localExtensions = [
400400 aLocalSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -481,7 +481,7 @@ suite('ExtensionsMerge', () => {
481481 aRemoteSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
482482 ] ;
483483 const skippedExtensions = [
484- anSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
484+ aSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
485485 ] ;
486486 const localExtensions = [
487487 aLocalSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -512,7 +512,7 @@ suite('ExtensionsMerge', () => {
512512 aRemoteSyncExtension ( { identifier : { id : 'd' , uuid : 'd' } } ) ,
513513 ] ;
514514 const skippedExtensions = [
515- anSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
515+ aSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
516516 ] ;
517517 const localExtensions = [
518518 aLocalSyncExtension ( { identifier : { id : 'b' , uuid : 'b' } } ) ,
@@ -1317,13 +1317,82 @@ suite('ExtensionsMerge', () => {
13171317 assert . deepStrictEqual ( actual . remote , null ) ;
13181318 } ) ;
13191319
1320+ test ( 'sync adding local application scoped extension' , ( ) => {
1321+ const localExtensions = [
1322+ aLocalSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : true } ) ,
1323+ ] ;
1324+
1325+ const actual = merge ( localExtensions , null , null , [ ] , [ ] , [ ] ) ;
1326+
1327+ assert . deepStrictEqual ( actual . local . added , [ ] ) ;
1328+ assert . deepStrictEqual ( actual . local . removed , [ ] ) ;
1329+ assert . deepStrictEqual ( actual . local . updated , [ ] ) ;
1330+ assert . deepStrictEqual ( actual . remote ?. all , localExtensions ) ;
1331+ } ) ;
1332+
1333+ test ( 'sync merging local extension with isApplicationScoped property and remote does not has isApplicationScoped property' , ( ) => {
1334+ const localExtensions = [
1335+ aLocalSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : false } ) ,
1336+ ] ;
1337+
1338+ const baseExtensions = [
1339+ aSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } } ) ,
1340+ ] ;
1341+
1342+ const actual = merge ( localExtensions , baseExtensions , baseExtensions , [ ] , [ ] , [ ] ) ;
1343+
1344+ assert . deepStrictEqual ( actual . local . added , [ ] ) ;
1345+ assert . deepStrictEqual ( actual . local . removed , [ ] ) ;
1346+ assert . deepStrictEqual ( actual . local . updated , [ ] ) ;
1347+ assert . deepStrictEqual ( actual . remote ?. all , localExtensions ) ;
1348+ } ) ;
1349+
1350+ test ( 'sync merging when applicaiton scope is changed locally' , ( ) => {
1351+ const localExtensions = [
1352+ aLocalSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : true } ) ,
1353+ ] ;
1354+
1355+ const baseExtensions = [
1356+ aRemoteSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : false } ) ,
1357+ ] ;
1358+
1359+ const actual = merge ( localExtensions , baseExtensions , baseExtensions , [ ] , [ ] , [ ] ) ;
1360+
1361+ assert . deepStrictEqual ( actual . local . added , [ ] ) ;
1362+ assert . deepStrictEqual ( actual . local . removed , [ ] ) ;
1363+ assert . deepStrictEqual ( actual . local . updated , [ ] ) ;
1364+ assert . deepStrictEqual ( actual . remote ?. all , localExtensions ) ;
1365+ } ) ;
1366+
1367+ test ( 'sync merging when applicaiton scope is changed remotely' , ( ) => {
1368+ const localExtensions = [
1369+ aLocalSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : false } ) ,
1370+ ] ;
1371+
1372+ const baseExtensions = [
1373+ aRemoteSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : false } ) ,
1374+ ] ;
1375+
1376+ const remoteExtensions = [
1377+ aRemoteSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : true } ) ,
1378+ ] ;
1379+
1380+ const actual = merge ( localExtensions , remoteExtensions , baseExtensions , [ ] , [ ] , [ ] ) ;
1381+
1382+ assert . deepStrictEqual ( actual . local . added , [ ] ) ;
1383+ assert . deepStrictEqual ( actual . local . removed , [ ] ) ;
1384+ assert . deepStrictEqual ( actual . local . updated , [ anExpectedSyncExtension ( { identifier : { id : 'a' , uuid : 'a' } , isApplicationScoped : true } ) ] ) ;
1385+ assert . deepStrictEqual ( actual . remote , null ) ;
1386+ } ) ;
1387+
13201388 function anExpectedSyncExtension ( extension : Partial < ISyncExtension > ) : ISyncExtension {
13211389 return {
13221390 identifier : { id : 'a' , uuid : 'a' } ,
13231391 version : '1.0.0' ,
13241392 pinned : false ,
13251393 preRelease : false ,
13261394 installed : true ,
1395+ isApplicationScoped : false ,
13271396 ...extension
13281397 } ;
13291398 }
@@ -1334,6 +1403,7 @@ suite('ExtensionsMerge', () => {
13341403 version : '1.0.0' ,
13351404 pinned : false ,
13361405 preRelease : false ,
1406+ isApplicationScoped : false ,
13371407 ...extension
13381408 } ;
13391409 }
@@ -1345,6 +1415,7 @@ suite('ExtensionsMerge', () => {
13451415 pinned : false ,
13461416 preRelease : false ,
13471417 installed : true ,
1418+ isApplicationScoped : false ,
13481419 ...extension
13491420 } ;
13501421 }
@@ -1356,11 +1427,12 @@ suite('ExtensionsMerge', () => {
13561427 pinned : false ,
13571428 preRelease : false ,
13581429 installed : true ,
1430+ isApplicationScoped : false ,
13591431 ...extension
13601432 } ;
13611433 }
13621434
1363- function anSyncExtension ( extension : Partial < ISyncExtension > ) : ISyncExtension {
1435+ function aSyncExtension ( extension : Partial < ISyncExtension > ) : ISyncExtension {
13641436 return {
13651437 identifier : { id : 'a' , uuid : 'a' } ,
13661438 version : '1.0.0' ,
0 commit comments