@featurevisor/core 2.26.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/coverage/clover.xml +4991 -3130
- package/coverage/coverage-final.json +63 -39
- package/coverage/lcov-report/block-navigation.js +1 -1
- package/coverage/lcov-report/index.html +248 -98
- package/coverage/lcov-report/sorter.js +21 -7
- package/coverage/lcov-report/src/assess-distribution/index.html +116 -0
- package/coverage/lcov-report/src/assess-distribution/index.ts.html +754 -0
- package/coverage/lcov-report/{list → src/benchmark}/index.html +30 -30
- package/coverage/lcov-report/src/benchmark/index.ts.html +793 -0
- package/coverage/lcov-report/{builder → src/builder}/allocator.ts.html +38 -38
- package/coverage/lcov-report/{builder/buildScopedConditions.ts.html → src/builder/applyContextToConditions.ts.html} +80 -65
- package/coverage/lcov-report/{builder/buildScopedDatafile.ts.html → src/builder/applyContextToDatafile.ts.html} +92 -92
- package/coverage/lcov-report/{builder/buildScopedSegments.ts.html → src/builder/applyContextToSegments.ts.html} +103 -67
- package/coverage/lcov-report/{builder → src/builder}/buildDatafile.ts.html +336 -306
- package/coverage/lcov-report/src/builder/buildProject.ts.html +1117 -0
- package/coverage/lcov-report/src/builder/buildRuntimeDatafiles.ts.html +256 -0
- package/coverage/lcov-report/{builder → src/builder}/getFeatureRanges.ts.html +22 -22
- package/coverage/lcov-report/{builder → src/builder}/hashes.ts.html +50 -50
- package/coverage/lcov-report/{builder → src/builder}/index.html +114 -84
- package/coverage/lcov-report/{tester/cliFormat.ts.html → src/builder/index.ts.html} +17 -29
- package/coverage/lcov-report/{builder → src/builder}/mutateVariables.ts.html +55 -55
- package/coverage/lcov-report/{builder → src/builder}/mutator.ts.html +118 -118
- package/coverage/lcov-report/{builder → src/builder}/revision.ts.html +15 -15
- package/coverage/lcov-report/{builder → src/builder}/traffic.ts.html +86 -86
- package/coverage/lcov-report/src/cli/cli.ts.html +400 -0
- package/coverage/lcov-report/{tester → src/cli}/index.html +41 -41
- package/coverage/lcov-report/src/cli/plugins.ts.html +214 -0
- package/coverage/lcov-report/{config → src/config}/index.html +31 -31
- package/coverage/lcov-report/{config → src/config}/index.ts.html +12 -12
- package/coverage/lcov-report/{config → src/config}/projectConfig.ts.html +312 -96
- package/coverage/lcov-report/{datasource → src/datasource}/adapter.ts.html +28 -73
- package/coverage/lcov-report/{datasource → src/datasource}/datasource.ts.html +191 -104
- package/coverage/lcov-report/{datasource → src/datasource}/filesystemAdapter.ts.html +233 -635
- package/coverage/lcov-report/{datasource → src/datasource}/index.html +48 -48
- package/coverage/lcov-report/{datasource → src/datasource}/index.ts.html +14 -14
- package/coverage/lcov-report/src/evaluate/index.html +116 -0
- package/coverage/lcov-report/src/evaluate/index.ts.html +814 -0
- package/coverage/lcov-report/src/find-duplicate-segments/findDuplicateSegments.ts.html +313 -0
- package/coverage/lcov-report/src/find-duplicate-segments/index.html +131 -0
- package/coverage/lcov-report/src/find-duplicate-segments/index.ts.html +307 -0
- package/coverage/lcov-report/src/find-usage/index.html +116 -0
- package/coverage/lcov-report/src/find-usage/index.ts.html +1780 -0
- package/coverage/lcov-report/src/generate-code/index.html +131 -0
- package/coverage/lcov-report/src/generate-code/index.ts.html +403 -0
- package/coverage/lcov-report/{generate-code → src/generate-code}/typescript.ts.html +266 -1361
- package/coverage/lcov-report/{generate-code → src}/index.html +38 -23
- package/coverage/lcov-report/src/info/index.html +116 -0
- package/coverage/lcov-report/src/info/index.ts.html +472 -0
- package/coverage/lcov-report/src/init/index.html +116 -0
- package/coverage/lcov-report/src/init/index.ts.html +280 -0
- package/coverage/lcov-report/{linter → src/linter}/attributeSchema.ts.html +160 -157
- package/coverage/lcov-report/{linter → src/linter}/checkCircularDependency.ts.html +25 -25
- package/coverage/lcov-report/{linter → src/linter}/checkPercentageExceedingSlot.ts.html +42 -42
- package/coverage/lcov-report/{linter → src/linter}/conditionSchema.ts.html +207 -207
- package/coverage/lcov-report/{linter → src/linter}/featureSchema.ts.html +462 -471
- package/coverage/lcov-report/{linter → src/linter}/groupSchema.ts.html +25 -22
- package/coverage/lcov-report/{linter → src/linter}/index.html +129 -99
- package/coverage/lcov-report/src/linter/index.ts.html +88 -0
- package/coverage/lcov-report/{linter → src/linter}/lintProject.ts.html +740 -332
- package/coverage/lcov-report/{linter → src/linter}/mutationNotation.ts.html +130 -130
- package/coverage/lcov-report/{linter → src/linter}/printError.ts.html +27 -27
- package/coverage/lcov-report/{linter → src/linter}/schema.ts.html +153 -150
- package/coverage/lcov-report/{linter → src/linter}/segmentSchema.ts.html +18 -15
- package/coverage/lcov-report/src/linter/targetSchema.ts.html +223 -0
- package/coverage/lcov-report/{linter → src/linter}/testSchema.ts.html +54 -48
- package/coverage/lcov-report/{linter → src/linter}/zodHelpers.ts.html +17 -17
- package/coverage/lcov-report/src/list/index.html +131 -0
- package/coverage/lcov-report/src/list/index.ts.html +2065 -0
- package/coverage/lcov-report/{list → src/list}/matrix.ts.html +43 -58
- package/coverage/lcov-report/src/promoter/index.html +116 -0
- package/coverage/lcov-report/src/promoter/index.ts.html +3883 -0
- package/coverage/lcov-report/src/sets.ts.html +313 -0
- package/coverage/lcov-report/src/targeting.ts.html +403 -0
- package/coverage/lcov-report/src/tester/cliFormat.ts.html +133 -0
- package/coverage/lcov-report/{tester → src/tester}/helpers.ts.html +15 -15
- package/coverage/lcov-report/src/tester/index.html +206 -0
- package/coverage/lcov-report/src/tester/prettyDuration.ts.html +187 -0
- package/coverage/lcov-report/src/tester/printTestResult.ts.html +337 -0
- package/coverage/lcov-report/src/tester/testFeature.ts.html +1186 -0
- package/coverage/lcov-report/src/tester/testProject.ts.html +1018 -0
- package/coverage/lcov-report/src/tester/testSegment.ts.html +316 -0
- package/coverage/lcov-report/{utils → src/utils}/extractKeys.ts.html +68 -68
- package/coverage/lcov-report/{utils → src/utils}/git.ts.html +44 -68
- package/coverage/lcov-report/{utils → src/utils}/index.html +44 -44
- package/coverage/lcov-report/{utils → src/utils}/index.ts.html +14 -14
- package/coverage/lcov-report/{utils → src/utils}/pretty.ts.html +20 -20
- package/coverage/lcov.info +10121 -5723
- package/jest.config.js +13 -4
- package/lib/assess-distribution/index.d.ts +1 -1
- package/lib/assess-distribution/index.js +59 -40
- package/lib/assess-distribution/index.js.map +1 -1
- package/lib/benchmark/index.d.ts +8 -5
- package/lib/benchmark/index.js +82 -65
- package/lib/benchmark/index.js.map +1 -1
- package/lib/builder/applyContextToConditions.d.ts +5 -0
- package/lib/builder/{buildScopedConditions.js → applyContextToConditions.js} +19 -14
- package/lib/builder/applyContextToConditions.js.map +1 -0
- package/lib/builder/applyContextToDatafile.d.ts +2 -0
- package/lib/builder/{buildScopedDatafile.js → applyContextToDatafile.js} +26 -26
- package/lib/builder/applyContextToDatafile.js.map +1 -0
- package/lib/builder/applyContextToSegments.d.ts +5 -0
- package/lib/builder/{buildScopedSegments.js → applyContextToSegments.js} +19 -14
- package/lib/builder/applyContextToSegments.js.map +1 -0
- package/lib/builder/buildDatafile.d.ts +9 -6
- package/lib/builder/buildDatafile.js +86 -51
- package/lib/builder/buildDatafile.js.map +1 -1
- package/lib/builder/buildProject.d.ts +17 -3
- package/lib/builder/buildProject.js +151 -59
- package/lib/builder/buildProject.js.map +1 -1
- package/lib/builder/buildRuntimeDatafiles.d.ts +12 -0
- package/lib/builder/buildRuntimeDatafiles.js +35 -0
- package/lib/builder/buildRuntimeDatafiles.js.map +1 -0
- package/lib/builder/getFeatureRanges.js +34 -1
- package/lib/builder/getFeatureRanges.js.map +1 -1
- package/lib/builder/hashes.js +34 -1
- package/lib/builder/hashes.js.map +1 -1
- package/lib/builder/index.d.ts +0 -1
- package/lib/builder/index.js +0 -1
- package/lib/builder/index.js.map +1 -1
- package/lib/cli/cli.js +0 -4
- package/lib/cli/cli.js.map +1 -1
- package/lib/cli/plugins.js +7 -2
- package/lib/cli/plugins.js.map +1 -1
- package/lib/config/projectConfig.d.ts +17 -17
- package/lib/config/projectConfig.js +101 -15
- package/lib/config/projectConfig.js.map +1 -1
- package/lib/datasource/adapter.d.ts +7 -9
- package/lib/datasource/adapter.js +0 -7
- package/lib/datasource/adapter.js.map +1 -1
- package/lib/datasource/datasource.d.ts +15 -5
- package/lib/datasource/datasource.js +37 -9
- package/lib/datasource/datasource.js.map +1 -1
- package/lib/datasource/filesystemAdapter.d.ts +4 -10
- package/lib/datasource/filesystemAdapter.js +111 -149
- package/lib/datasource/filesystemAdapter.js.map +1 -1
- package/lib/evaluate/index.d.ts +1 -7
- package/lib/evaluate/index.js +81 -67
- package/lib/evaluate/index.js.map +1 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js +34 -1
- package/lib/find-duplicate-segments/findDuplicateSegments.js.map +1 -1
- package/lib/find-duplicate-segments/index.js +21 -13
- package/lib/find-duplicate-segments/index.js.map +1 -1
- package/lib/find-usage/index.js +57 -41
- package/lib/find-usage/index.js.map +1 -1
- package/lib/generate-code/index.d.ts +1 -1
- package/lib/generate-code/index.js +64 -21
- package/lib/generate-code/index.js.map +1 -1
- package/lib/generate-code/typescript.d.ts +1 -1
- package/lib/generate-code/typescript.js +59 -333
- package/lib/generate-code/typescript.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +2 -1
- package/lib/index.js.map +1 -1
- package/lib/info/index.js +57 -16
- package/lib/info/index.js.map +1 -1
- package/lib/init/index.d.ts +2 -2
- package/lib/init/index.js +39 -3
- package/lib/init/index.js.map +1 -1
- package/lib/linter/attributeSchema.d.ts +1 -0
- package/lib/linter/attributeSchema.js +1 -0
- package/lib/linter/attributeSchema.js.map +1 -1
- package/lib/linter/conditionSchema.js +5 -5
- package/lib/linter/conditionSchema.js.map +1 -1
- package/lib/linter/featureSchema.d.ts +4 -1
- package/lib/linter/featureSchema.js +15 -13
- package/lib/linter/featureSchema.js.map +1 -1
- package/lib/linter/groupSchema.d.ts +1 -0
- package/lib/linter/groupSchema.js +1 -0
- package/lib/linter/groupSchema.js.map +1 -1
- package/lib/linter/lintProject.d.ts +1 -3
- package/lib/linter/lintProject.js +198 -68
- package/lib/linter/lintProject.js.map +1 -1
- package/lib/linter/schema.js +1 -0
- package/lib/linter/schema.js.map +1 -1
- package/lib/linter/segmentSchema.d.ts +1 -0
- package/lib/linter/segmentSchema.js +1 -0
- package/lib/linter/segmentSchema.js.map +1 -1
- package/lib/linter/targetSchema.d.ts +16 -0
- package/lib/linter/targetSchema.js +40 -0
- package/lib/linter/targetSchema.js.map +1 -0
- package/lib/linter/testSchema.d.ts +4 -3
- package/lib/linter/testSchema.js +9 -4
- package/lib/linter/testSchema.js.map +1 -1
- package/lib/list/index.d.ts +1 -0
- package/lib/list/index.js +131 -12
- package/lib/list/index.js.map +1 -1
- package/lib/list/matrix.js +3 -7
- package/lib/list/matrix.js.map +1 -1
- package/lib/promoter/index.d.ts +50 -0
- package/lib/promoter/index.js +880 -0
- package/lib/promoter/index.js.map +1 -0
- package/lib/sets.d.ts +11 -0
- package/lib/sets.js +81 -0
- package/lib/sets.js.map +1 -0
- package/lib/targeting.d.ts +14 -0
- package/lib/targeting.js +82 -0
- package/lib/targeting.js.map +1 -0
- package/lib/tester/cliFormat.d.ts +7 -1
- package/lib/tester/cliFormat.js +11 -2
- package/lib/tester/cliFormat.js.map +1 -1
- package/lib/tester/printTestResult.js +2 -2
- package/lib/tester/printTestResult.js.map +1 -1
- package/lib/tester/testFeature.d.ts +0 -1
- package/lib/tester/testFeature.js +8 -25
- package/lib/tester/testFeature.js.map +1 -1
- package/lib/tester/testProject.d.ts +2 -3
- package/lib/tester/testProject.js +93 -86
- package/lib/tester/testProject.js.map +1 -1
- package/lib/tester/testSegment.d.ts +1 -1
- package/lib/tester/testSegment.js +3 -21
- package/lib/tester/testSegment.js.map +1 -1
- package/lib/utils/git.js +45 -19
- package/lib/utils/git.js.map +1 -1
- package/package.json +12 -12
- package/src/assess-distribution/index.ts +72 -52
- package/src/benchmark/index.ts +124 -91
- package/src/builder/{buildScopedConditions.spec.ts → applyContextToConditions.spec.ts} +160 -142
- package/src/builder/{buildScopedConditions.ts → applyContextToConditions.ts} +19 -14
- package/src/builder/{buildScopedDatafile.spec.ts → applyContextToDatafile.spec.ts} +141 -81
- package/src/builder/{buildScopedDatafile.ts → applyContextToDatafile.ts} +33 -33
- package/src/builder/{buildScopedSegments.spec.ts → applyContextToSegments.spec.ts} +171 -151
- package/src/builder/{buildScopedSegments.ts → applyContextToSegments.ts} +26 -14
- package/src/builder/buildDatafile.spec.ts +192 -14
- package/src/builder/buildDatafile.ts +74 -64
- package/src/builder/buildProject.ts +171 -86
- package/src/builder/buildRuntimeDatafiles.ts +57 -0
- package/src/builder/index.ts +0 -1
- package/src/cli/cli.ts +0 -5
- package/src/cli/plugins.ts +7 -2
- package/src/config/projectConfig.spec.ts +171 -8
- package/src/config/projectConfig.ts +100 -28
- package/src/datasource/adapter.ts +8 -23
- package/src/datasource/datasource.ts +50 -21
- package/src/datasource/filesystemAdapter.spec.ts +133 -74
- package/src/datasource/filesystemAdapter.ts +93 -227
- package/src/evaluate/index.ts +109 -97
- package/src/find-duplicate-segments/index.ts +34 -16
- package/src/find-usage/index.ts +89 -44
- package/src/generate-code/index.ts +36 -24
- package/src/generate-code/typescript.spec.ts +106 -0
- package/src/generate-code/typescript.ts +33 -398
- package/src/index.ts +2 -1
- package/src/info/index.ts +72 -16
- package/src/init/index.ts +1 -1
- package/src/linter/attributeSchema.ts +1 -0
- package/src/linter/conditionSchema.spec.ts +23 -3
- package/src/linter/conditionSchema.ts +5 -5
- package/src/linter/featureSchema.spec.ts +107 -18
- package/src/linter/featureSchema.ts +25 -28
- package/src/linter/groupSchema.ts +1 -0
- package/src/linter/lintProject.spec.ts +131 -92
- package/src/linter/lintProject.ts +233 -97
- package/src/linter/schema.ts +1 -0
- package/src/linter/segmentSchema.spec.ts +5 -3
- package/src/linter/segmentSchema.ts +1 -0
- package/src/linter/targetSchema.spec.ts +159 -0
- package/src/linter/targetSchema.ts +46 -0
- package/src/linter/testSchema.spec.ts +70 -5
- package/src/linter/testSchema.ts +12 -10
- package/src/list/index.spec.ts +135 -0
- package/src/list/index.ts +188 -12
- package/src/list/matrix.ts +3 -8
- package/src/promoter/index.spec.ts +617 -0
- package/src/promoter/index.ts +1266 -0
- package/src/sets.ts +76 -0
- package/src/targeting.spec.ts +74 -0
- package/src/targeting.ts +106 -0
- package/src/tester/cliFormat.ts +11 -1
- package/src/tester/printTestResult.ts +12 -3
- package/src/tester/testFeature.ts +10 -36
- package/src/tester/testProject.spec.ts +50 -0
- package/src/tester/testProject.ts +89 -140
- package/src/tester/testSegment.ts +5 -22
- package/src/utils/git.ts +13 -21
- package/tsconfig.cjs.json +5 -1
- package/tsconfig.typecheck.json +9 -0
- package/coverage/lcov-report/builder/convertToV1.ts.html +0 -583
- package/lib/builder/allocator.spec.d.ts +0 -1
- package/lib/builder/allocator.spec.js +0 -85
- package/lib/builder/allocator.spec.js.map +0 -1
- package/lib/builder/buildDatafile.spec.d.ts +0 -1
- package/lib/builder/buildDatafile.spec.js +0 -233
- package/lib/builder/buildDatafile.spec.js.map +0 -1
- package/lib/builder/buildScopedConditions.d.ts +0 -5
- package/lib/builder/buildScopedConditions.js.map +0 -1
- package/lib/builder/buildScopedConditions.spec.d.ts +0 -1
- package/lib/builder/buildScopedConditions.spec.js +0 -2167
- package/lib/builder/buildScopedConditions.spec.js.map +0 -1
- package/lib/builder/buildScopedDatafile.d.ts +0 -2
- package/lib/builder/buildScopedDatafile.js.map +0 -1
- package/lib/builder/buildScopedDatafile.spec.d.ts +0 -1
- package/lib/builder/buildScopedDatafile.spec.js +0 -2277
- package/lib/builder/buildScopedDatafile.spec.js.map +0 -1
- package/lib/builder/buildScopedSegments.d.ts +0 -5
- package/lib/builder/buildScopedSegments.js.map +0 -1
- package/lib/builder/buildScopedSegments.spec.d.ts +0 -1
- package/lib/builder/buildScopedSegments.spec.js +0 -1062
- package/lib/builder/buildScopedSegments.spec.js.map +0 -1
- package/lib/builder/convertToV1.d.ts +0 -10
- package/lib/builder/convertToV1.js +0 -119
- package/lib/builder/convertToV1.js.map +0 -1
- package/lib/builder/mutateVariables.spec.d.ts +0 -1
- package/lib/builder/mutateVariables.spec.js +0 -1074
- package/lib/builder/mutateVariables.spec.js.map +0 -1
- package/lib/builder/mutator.spec.d.ts +0 -1
- package/lib/builder/mutator.spec.js +0 -368
- package/lib/builder/mutator.spec.js.map +0 -1
- package/lib/builder/revision.spec.d.ts +0 -1
- package/lib/builder/revision.spec.js +0 -21
- package/lib/builder/revision.spec.js.map +0 -1
- package/lib/builder/traffic.spec.d.ts +0 -1
- package/lib/builder/traffic.spec.js +0 -872
- package/lib/builder/traffic.spec.js.map +0 -1
- package/lib/config/projectConfig.spec.d.ts +0 -1
- package/lib/config/projectConfig.spec.js +0 -24
- package/lib/config/projectConfig.spec.js.map +0 -1
- package/lib/datasource/filesystemAdapter.spec.d.ts +0 -1
- package/lib/datasource/filesystemAdapter.spec.js +0 -88
- package/lib/datasource/filesystemAdapter.spec.js.map +0 -1
- package/lib/generate-code/typescript.spec.d.ts +0 -1
- package/lib/generate-code/typescript.spec.js +0 -78
- package/lib/generate-code/typescript.spec.js.map +0 -1
- package/lib/linter/attributeSchema.spec.d.ts +0 -1
- package/lib/linter/attributeSchema.spec.js +0 -266
- package/lib/linter/attributeSchema.spec.js.map +0 -1
- package/lib/linter/conditionSchema.spec.d.ts +0 -1
- package/lib/linter/conditionSchema.spec.js +0 -380
- package/lib/linter/conditionSchema.spec.js.map +0 -1
- package/lib/linter/featureSchema.spec.d.ts +0 -1
- package/lib/linter/featureSchema.spec.js +0 -1552
- package/lib/linter/featureSchema.spec.js.map +0 -1
- package/lib/linter/lintProject.spec.d.ts +0 -1
- package/lib/linter/lintProject.spec.js +0 -211
- package/lib/linter/lintProject.spec.js.map +0 -1
- package/lib/linter/mutationNotation.spec.d.ts +0 -1
- package/lib/linter/mutationNotation.spec.js +0 -598
- package/lib/linter/mutationNotation.spec.js.map +0 -1
- package/lib/linter/schema.spec.d.ts +0 -1
- package/lib/linter/schema.spec.js +0 -535
- package/lib/linter/schema.spec.js.map +0 -1
- package/lib/linter/segmentSchema.spec.d.ts +0 -1
- package/lib/linter/segmentSchema.spec.js +0 -303
- package/lib/linter/segmentSchema.spec.js.map +0 -1
- package/lib/linter/testSchema.spec.d.ts +0 -1
- package/lib/linter/testSchema.spec.js +0 -162
- package/lib/linter/testSchema.spec.js.map +0 -1
- package/lib/list/matrix.spec.d.ts +0 -1
- package/lib/list/matrix.spec.js +0 -42
- package/lib/list/matrix.spec.js.map +0 -1
- package/lib/site/exportSite.d.ts +0 -2
- package/lib/site/exportSite.js +0 -30
- package/lib/site/exportSite.js.map +0 -1
- package/lib/site/generateHistory.d.ts +0 -3
- package/lib/site/generateHistory.js +0 -31
- package/lib/site/generateHistory.js.map +0 -1
- package/lib/site/generateSiteSearchIndex.d.ts +0 -4
- package/lib/site/generateSiteSearchIndex.js +0 -195
- package/lib/site/generateSiteSearchIndex.js.map +0 -1
- package/lib/site/getLastModifiedFromHistory.d.ts +0 -2
- package/lib/site/getLastModifiedFromHistory.js +0 -18
- package/lib/site/getLastModifiedFromHistory.js.map +0 -1
- package/lib/site/getOwnerAndRepoFromUrl.d.ts +0 -4
- package/lib/site/getOwnerAndRepoFromUrl.js +0 -20
- package/lib/site/getOwnerAndRepoFromUrl.js.map +0 -1
- package/lib/site/getRelativePaths.d.ts +0 -6
- package/lib/site/getRelativePaths.js +0 -15
- package/lib/site/getRelativePaths.js.map +0 -1
- package/lib/site/getRepoDetails.d.ts +0 -8
- package/lib/site/getRepoDetails.js +0 -48
- package/lib/site/getRepoDetails.js.map +0 -1
- package/lib/site/index.d.ts +0 -2
- package/lib/site/index.js +0 -43
- package/lib/site/index.js.map +0 -1
- package/lib/site/serveSite.d.ts +0 -2
- package/lib/site/serveSite.js +0 -54
- package/lib/site/serveSite.js.map +0 -1
- package/lib/tester/helpers.spec.d.ts +0 -1
- package/lib/tester/helpers.spec.js +0 -115
- package/lib/tester/helpers.spec.js.map +0 -1
- package/src/builder/convertToV1.ts +0 -166
- package/src/site/exportSite.ts +0 -42
- package/src/site/generateHistory.ts +0 -40
- package/src/site/generateSiteSearchIndex.ts +0 -258
- package/src/site/getLastModifiedFromHistory.ts +0 -21
- package/src/site/getOwnerAndRepoFromUrl.ts +0 -17
- package/src/site/getRelativePaths.ts +0 -24
- package/src/site/getRepoDetails.ts +0 -62
- package/src/site/index.ts +0 -46
- package/src/site/serveSite.ts +0 -58
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { DatafileContent } from "@featurevisor/types";
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
-
|
|
4
|
+
applyContextToSegments,
|
|
5
5
|
removeRedundantGroupSegments,
|
|
6
|
-
|
|
7
|
-
} from "./
|
|
8
|
-
import {
|
|
6
|
+
applyContextToGroupSegments,
|
|
7
|
+
} from "./applyContextToSegments";
|
|
8
|
+
import { createFeaturevisor } from "@featurevisor/sdk";
|
|
9
9
|
|
|
10
|
-
describe("core:
|
|
11
|
-
describe("
|
|
10
|
+
describe("core: applyContextToSegments", function () {
|
|
11
|
+
describe("applyContextToSegments", function () {
|
|
12
12
|
const datafileWithSegments: DatafileContent = {
|
|
13
13
|
schemaVersion: "2",
|
|
14
14
|
revision: "unknown",
|
|
@@ -45,43 +45,43 @@ describe("core: buildScopedSegments", function () {
|
|
|
45
45
|
features: {},
|
|
46
46
|
};
|
|
47
47
|
|
|
48
|
-
const
|
|
48
|
+
const featurevisorWithSegments = createFeaturevisor({
|
|
49
49
|
datafile: datafileWithSegments,
|
|
50
|
-
|
|
50
|
+
logLevel: "fatal",
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
test("
|
|
54
|
-
expect(
|
|
53
|
+
test("applyContextToSegments is a function", function () {
|
|
54
|
+
expect(applyContextToSegments).toBeInstanceOf(Function);
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
test("simple cases", function () {
|
|
58
58
|
// "*" remains "*"
|
|
59
|
-
expect(
|
|
59
|
+
expect(applyContextToSegments(featurevisorWithSegments, "*", {})).toEqual("*");
|
|
60
60
|
|
|
61
61
|
// Plain segment that matches
|
|
62
62
|
expect(
|
|
63
|
-
|
|
63
|
+
applyContextToSegments(featurevisorWithSegments, "web", {
|
|
64
64
|
platform: "web",
|
|
65
65
|
}),
|
|
66
66
|
).toEqual("*");
|
|
67
67
|
|
|
68
68
|
// Plain segment that doesn't match
|
|
69
69
|
expect(
|
|
70
|
-
|
|
70
|
+
applyContextToSegments(featurevisorWithSegments, "web", {
|
|
71
71
|
platform: "mobile",
|
|
72
72
|
}),
|
|
73
73
|
).toEqual("web");
|
|
74
74
|
|
|
75
75
|
// Array of segments - partial match (redundant "*" removed)
|
|
76
76
|
expect(
|
|
77
|
-
|
|
77
|
+
applyContextToSegments(featurevisorWithSegments, ["web", "chrome"], {
|
|
78
78
|
platform: "web",
|
|
79
79
|
}),
|
|
80
80
|
).toEqual(["chrome"]);
|
|
81
81
|
|
|
82
82
|
// Array of segments - full match (all "*" becomes "*")
|
|
83
83
|
expect(
|
|
84
|
-
|
|
84
|
+
applyContextToSegments(featurevisorWithSegments, ["web", "chrome"], {
|
|
85
85
|
platform: "web",
|
|
86
86
|
browser: "chrome",
|
|
87
87
|
}),
|
|
@@ -89,7 +89,7 @@ describe("core: buildScopedSegments", function () {
|
|
|
89
89
|
|
|
90
90
|
// Array of segments - no match
|
|
91
91
|
expect(
|
|
92
|
-
|
|
92
|
+
applyContextToSegments(featurevisorWithSegments, ["web", "chrome"], {
|
|
93
93
|
platform: "mobile",
|
|
94
94
|
browser: "safari",
|
|
95
95
|
}),
|
|
@@ -99,8 +99,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
99
99
|
test("AND group segments", function () {
|
|
100
100
|
// AND with all matching segments (all "*" becomes "*")
|
|
101
101
|
expect(
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
applyContextToSegments(
|
|
103
|
+
featurevisorWithSegments,
|
|
104
104
|
{
|
|
105
105
|
and: ["web", "chrome"],
|
|
106
106
|
},
|
|
@@ -113,8 +113,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
113
113
|
|
|
114
114
|
// AND with partial match (redundant "*" removed)
|
|
115
115
|
expect(
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
applyContextToSegments(
|
|
117
|
+
featurevisorWithSegments,
|
|
118
118
|
{
|
|
119
119
|
and: ["web", "chrome"],
|
|
120
120
|
},
|
|
@@ -128,8 +128,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
128
128
|
|
|
129
129
|
// AND with no matches
|
|
130
130
|
expect(
|
|
131
|
-
|
|
132
|
-
|
|
131
|
+
applyContextToSegments(
|
|
132
|
+
featurevisorWithSegments,
|
|
133
133
|
{
|
|
134
134
|
and: ["web", "chrome"],
|
|
135
135
|
},
|
|
@@ -144,8 +144,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
144
144
|
|
|
145
145
|
// AND with "*" in it (all "*" becomes "*")
|
|
146
146
|
expect(
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
applyContextToSegments(
|
|
148
|
+
featurevisorWithSegments,
|
|
149
149
|
{
|
|
150
150
|
and: ["*", "chrome"],
|
|
151
151
|
},
|
|
@@ -159,8 +159,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
159
159
|
test("OR group segments", function () {
|
|
160
160
|
// OR with all matching segments (all "*" becomes "*")
|
|
161
161
|
expect(
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
applyContextToSegments(
|
|
163
|
+
featurevisorWithSegments,
|
|
164
164
|
{
|
|
165
165
|
or: ["web", "chrome"],
|
|
166
166
|
},
|
|
@@ -173,8 +173,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
173
173
|
|
|
174
174
|
// OR with partial match (redundant "*" removed, but OR structure remains)
|
|
175
175
|
expect(
|
|
176
|
-
|
|
177
|
-
|
|
176
|
+
applyContextToSegments(
|
|
177
|
+
featurevisorWithSegments,
|
|
178
178
|
{
|
|
179
179
|
or: ["web", "chrome"],
|
|
180
180
|
},
|
|
@@ -188,8 +188,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
188
188
|
|
|
189
189
|
// OR with no matches
|
|
190
190
|
expect(
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
applyContextToSegments(
|
|
192
|
+
featurevisorWithSegments,
|
|
193
193
|
{
|
|
194
194
|
or: ["web", "mobile"],
|
|
195
195
|
},
|
|
@@ -203,10 +203,10 @@ describe("core: buildScopedSegments", function () {
|
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
test("NOT group segments", function () {
|
|
206
|
-
// NOT with matching segment
|
|
206
|
+
// NOT with matching segment remains an always-false expression
|
|
207
207
|
expect(
|
|
208
|
-
|
|
209
|
-
|
|
208
|
+
applyContextToSegments(
|
|
209
|
+
featurevisorWithSegments,
|
|
210
210
|
{
|
|
211
211
|
not: ["web"],
|
|
212
212
|
},
|
|
@@ -214,12 +214,14 @@ describe("core: buildScopedSegments", function () {
|
|
|
214
214
|
platform: "web",
|
|
215
215
|
},
|
|
216
216
|
),
|
|
217
|
-
).toEqual(
|
|
217
|
+
).toEqual({
|
|
218
|
+
not: ["*"],
|
|
219
|
+
});
|
|
218
220
|
|
|
219
221
|
// NOT with non-matching segment
|
|
220
222
|
expect(
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
applyContextToSegments(
|
|
224
|
+
featurevisorWithSegments,
|
|
223
225
|
{
|
|
224
226
|
not: ["web"],
|
|
225
227
|
},
|
|
@@ -231,10 +233,10 @@ describe("core: buildScopedSegments", function () {
|
|
|
231
233
|
not: ["web"],
|
|
232
234
|
});
|
|
233
235
|
|
|
234
|
-
// NOT with multiple segments
|
|
236
|
+
// NOT with multiple matching segments remains an always-false expression
|
|
235
237
|
expect(
|
|
236
|
-
|
|
237
|
-
|
|
238
|
+
applyContextToSegments(
|
|
239
|
+
featurevisorWithSegments,
|
|
238
240
|
{
|
|
239
241
|
not: ["web", "chrome"],
|
|
240
242
|
},
|
|
@@ -243,14 +245,16 @@ describe("core: buildScopedSegments", function () {
|
|
|
243
245
|
browser: "chrome",
|
|
244
246
|
},
|
|
245
247
|
),
|
|
246
|
-
).toEqual(
|
|
248
|
+
).toEqual({
|
|
249
|
+
not: ["*"],
|
|
250
|
+
});
|
|
247
251
|
});
|
|
248
252
|
|
|
249
253
|
test("nested AND group segments", function () {
|
|
250
254
|
// Nested AND with all matching (all "*" becomes "*")
|
|
251
255
|
expect(
|
|
252
|
-
|
|
253
|
-
|
|
256
|
+
applyContextToSegments(
|
|
257
|
+
featurevisorWithSegments,
|
|
254
258
|
{
|
|
255
259
|
and: [
|
|
256
260
|
"web",
|
|
@@ -269,8 +273,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
269
273
|
|
|
270
274
|
// Nested AND with partial match (redundant "*" removed)
|
|
271
275
|
expect(
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
applyContextToSegments(
|
|
277
|
+
featurevisorWithSegments,
|
|
274
278
|
{
|
|
275
279
|
and: [
|
|
276
280
|
"web",
|
|
@@ -296,8 +300,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
296
300
|
test("nested OR group segments", function () {
|
|
297
301
|
// Nested OR with outer match (redundant "*" removed, but inner OR remains)
|
|
298
302
|
expect(
|
|
299
|
-
|
|
300
|
-
|
|
303
|
+
applyContextToSegments(
|
|
304
|
+
featurevisorWithSegments,
|
|
301
305
|
{
|
|
302
306
|
or: [
|
|
303
307
|
"web",
|
|
@@ -320,8 +324,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
320
324
|
|
|
321
325
|
// Nested OR with inner match (redundant "*" removed, but outer OR remains)
|
|
322
326
|
expect(
|
|
323
|
-
|
|
324
|
-
|
|
327
|
+
applyContextToSegments(
|
|
328
|
+
featurevisorWithSegments,
|
|
325
329
|
{
|
|
326
330
|
or: [
|
|
327
331
|
"web",
|
|
@@ -345,10 +349,10 @@ describe("core: buildScopedSegments", function () {
|
|
|
345
349
|
});
|
|
346
350
|
|
|
347
351
|
test("nested NOT group segments", function () {
|
|
348
|
-
// Nested NOT
|
|
352
|
+
// Nested NOT preserves non-broadening false expressions
|
|
349
353
|
expect(
|
|
350
|
-
|
|
351
|
-
|
|
354
|
+
applyContextToSegments(
|
|
355
|
+
featurevisorWithSegments,
|
|
352
356
|
{
|
|
353
357
|
not: [
|
|
354
358
|
"web",
|
|
@@ -362,14 +366,20 @@ describe("core: buildScopedSegments", function () {
|
|
|
362
366
|
browser: "chrome",
|
|
363
367
|
},
|
|
364
368
|
),
|
|
365
|
-
).toEqual(
|
|
369
|
+
).toEqual({
|
|
370
|
+
not: [
|
|
371
|
+
{
|
|
372
|
+
not: ["*"],
|
|
373
|
+
},
|
|
374
|
+
],
|
|
375
|
+
});
|
|
366
376
|
});
|
|
367
377
|
|
|
368
378
|
test("mixed nested group segments", function () {
|
|
369
379
|
// AND with nested OR (redundant "*" removed, but OR structure remains if not all match)
|
|
370
380
|
expect(
|
|
371
|
-
|
|
372
|
-
|
|
381
|
+
applyContextToSegments(
|
|
382
|
+
featurevisorWithSegments,
|
|
373
383
|
{
|
|
374
384
|
and: [
|
|
375
385
|
"web",
|
|
@@ -393,8 +403,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
393
403
|
|
|
394
404
|
// OR with nested AND (redundant "*" removed, but OR structure remains if not all match)
|
|
395
405
|
expect(
|
|
396
|
-
|
|
397
|
-
|
|
406
|
+
applyContextToSegments(
|
|
407
|
+
featurevisorWithSegments,
|
|
398
408
|
{
|
|
399
409
|
or: [
|
|
400
410
|
"web",
|
|
@@ -414,8 +424,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
414
424
|
|
|
415
425
|
// AND with nested NOT (redundant "*" removed)
|
|
416
426
|
expect(
|
|
417
|
-
|
|
418
|
-
|
|
427
|
+
applyContextToSegments(
|
|
428
|
+
featurevisorWithSegments,
|
|
419
429
|
{
|
|
420
430
|
and: [
|
|
421
431
|
"web",
|
|
@@ -438,8 +448,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
438
448
|
|
|
439
449
|
// Complex nested structure (redundant "*" removed)
|
|
440
450
|
expect(
|
|
441
|
-
|
|
442
|
-
|
|
451
|
+
applyContextToSegments(
|
|
452
|
+
featurevisorWithSegments,
|
|
443
453
|
{
|
|
444
454
|
and: [
|
|
445
455
|
"web",
|
|
@@ -471,8 +481,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
471
481
|
test("arrays with nested group segments", function () {
|
|
472
482
|
// Array with AND group segment (redundant "*" removed)
|
|
473
483
|
expect(
|
|
474
|
-
|
|
475
|
-
|
|
484
|
+
applyContextToSegments(
|
|
485
|
+
featurevisorWithSegments,
|
|
476
486
|
[
|
|
477
487
|
"web",
|
|
478
488
|
{
|
|
@@ -489,8 +499,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
489
499
|
|
|
490
500
|
// Array with OR group segment (redundant "*" removed, but OR structure remains if not all match)
|
|
491
501
|
expect(
|
|
492
|
-
|
|
493
|
-
|
|
502
|
+
applyContextToSegments(
|
|
503
|
+
featurevisorWithSegments,
|
|
494
504
|
[
|
|
495
505
|
"web",
|
|
496
506
|
{
|
|
@@ -512,7 +522,7 @@ describe("core: buildScopedSegments", function () {
|
|
|
512
522
|
test("segments with complex conditions", function () {
|
|
513
523
|
// Segment with AND conditions in its definition
|
|
514
524
|
expect(
|
|
515
|
-
|
|
525
|
+
applyContextToSegments(featurevisorWithSegments, "premium", {
|
|
516
526
|
tier: "premium",
|
|
517
527
|
status: "active",
|
|
518
528
|
}),
|
|
@@ -520,7 +530,7 @@ describe("core: buildScopedSegments", function () {
|
|
|
520
530
|
|
|
521
531
|
// Segment with AND conditions that doesn't match
|
|
522
532
|
expect(
|
|
523
|
-
|
|
533
|
+
applyContextToSegments(featurevisorWithSegments, "premium", {
|
|
524
534
|
tier: "premium",
|
|
525
535
|
status: "inactive",
|
|
526
536
|
}),
|
|
@@ -529,22 +539,22 @@ describe("core: buildScopedSegments", function () {
|
|
|
529
539
|
|
|
530
540
|
test("edge cases", function () {
|
|
531
541
|
// Empty context
|
|
532
|
-
expect(
|
|
542
|
+
expect(applyContextToSegments(featurevisorWithSegments, "web", {})).toEqual("web");
|
|
533
543
|
|
|
534
544
|
// Empty array (all "*" becomes "*")
|
|
535
|
-
expect(
|
|
545
|
+
expect(applyContextToSegments(featurevisorWithSegments, [], {})).toEqual("*");
|
|
536
546
|
|
|
537
547
|
// "*" in array with matching segment (all "*" becomes "*")
|
|
538
548
|
expect(
|
|
539
|
-
|
|
549
|
+
applyContextToSegments(featurevisorWithSegments, ["*", "web"], {
|
|
540
550
|
platform: "web",
|
|
541
551
|
}),
|
|
542
552
|
).toEqual("*");
|
|
543
553
|
|
|
544
554
|
// AND with empty array (all "*" becomes "*")
|
|
545
555
|
expect(
|
|
546
|
-
|
|
547
|
-
|
|
556
|
+
applyContextToSegments(
|
|
557
|
+
featurevisorWithSegments,
|
|
548
558
|
{
|
|
549
559
|
and: [],
|
|
550
560
|
},
|
|
@@ -554,8 +564,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
554
564
|
|
|
555
565
|
// OR with empty array (all "*" becomes "*")
|
|
556
566
|
expect(
|
|
557
|
-
|
|
558
|
-
|
|
567
|
+
applyContextToSegments(
|
|
568
|
+
featurevisorWithSegments,
|
|
559
569
|
{
|
|
560
570
|
or: [],
|
|
561
571
|
},
|
|
@@ -629,7 +639,9 @@ describe("core: buildScopedSegments", function () {
|
|
|
629
639
|
|
|
630
640
|
test("NOT group segments", function () {
|
|
631
641
|
// All "*" in NOT
|
|
632
|
-
expect(removeRedundantGroupSegments({ not: ["*", "*", "*"] })).toEqual(
|
|
642
|
+
expect(removeRedundantGroupSegments({ not: ["*", "*", "*"] })).toEqual({
|
|
643
|
+
not: ["*"],
|
|
644
|
+
});
|
|
633
645
|
|
|
634
646
|
// Mixed with "*" in NOT
|
|
635
647
|
expect(
|
|
@@ -726,7 +738,13 @@ describe("core: buildScopedSegments", function () {
|
|
|
726
738
|
removeRedundantGroupSegments({
|
|
727
739
|
not: ["*", { not: ["*", "*", "*"] }, "*"],
|
|
728
740
|
}),
|
|
729
|
-
).toEqual(
|
|
741
|
+
).toEqual({
|
|
742
|
+
not: [
|
|
743
|
+
{
|
|
744
|
+
not: ["*"],
|
|
745
|
+
},
|
|
746
|
+
],
|
|
747
|
+
});
|
|
730
748
|
|
|
731
749
|
// Nested NOT with mixed group segments
|
|
732
750
|
expect(
|
|
@@ -898,7 +916,7 @@ describe("core: buildScopedSegments", function () {
|
|
|
898
916
|
});
|
|
899
917
|
});
|
|
900
918
|
|
|
901
|
-
describe("
|
|
919
|
+
describe("applyContextToGroupSegments", function () {
|
|
902
920
|
const datafileWithSegments: DatafileContent = {
|
|
903
921
|
schemaVersion: "2",
|
|
904
922
|
revision: "unknown",
|
|
@@ -935,43 +953,43 @@ describe("core: buildScopedSegments", function () {
|
|
|
935
953
|
features: {},
|
|
936
954
|
};
|
|
937
955
|
|
|
938
|
-
const
|
|
956
|
+
const featurevisorWithSegments = createFeaturevisor({
|
|
939
957
|
datafile: datafileWithSegments,
|
|
940
|
-
|
|
958
|
+
logLevel: "fatal",
|
|
941
959
|
});
|
|
942
960
|
|
|
943
|
-
test("
|
|
944
|
-
expect(
|
|
961
|
+
test("applyContextToGroupSegments is a function", function () {
|
|
962
|
+
expect(applyContextToGroupSegments).toBeInstanceOf(Function);
|
|
945
963
|
});
|
|
946
964
|
|
|
947
965
|
test("simple cases", function () {
|
|
948
966
|
// "*" remains "*"
|
|
949
|
-
expect(
|
|
967
|
+
expect(applyContextToGroupSegments(featurevisorWithSegments, "*", {})).toEqual("*");
|
|
950
968
|
|
|
951
969
|
// Plain segment that matches
|
|
952
970
|
expect(
|
|
953
|
-
|
|
971
|
+
applyContextToGroupSegments(featurevisorWithSegments, "web", {
|
|
954
972
|
platform: "web",
|
|
955
973
|
}),
|
|
956
974
|
).toEqual("*");
|
|
957
975
|
|
|
958
976
|
// Plain segment that doesn't match
|
|
959
977
|
expect(
|
|
960
|
-
|
|
978
|
+
applyContextToGroupSegments(featurevisorWithSegments, "web", {
|
|
961
979
|
platform: "mobile",
|
|
962
980
|
}),
|
|
963
981
|
).toEqual("web");
|
|
964
982
|
|
|
965
983
|
// Array of segments - partial match
|
|
966
984
|
expect(
|
|
967
|
-
|
|
985
|
+
applyContextToGroupSegments(featurevisorWithSegments, ["web", "chrome"], {
|
|
968
986
|
platform: "web",
|
|
969
987
|
}),
|
|
970
988
|
).toEqual(["*", "chrome"]);
|
|
971
989
|
|
|
972
990
|
// Array of segments - full match (all "*" - will be cleaned by removeRedundantGroupSegments later)
|
|
973
991
|
expect(
|
|
974
|
-
|
|
992
|
+
applyContextToGroupSegments(featurevisorWithSegments, ["web", "chrome"], {
|
|
975
993
|
platform: "web",
|
|
976
994
|
browser: "chrome",
|
|
977
995
|
}),
|
|
@@ -979,7 +997,7 @@ describe("core: buildScopedSegments", function () {
|
|
|
979
997
|
|
|
980
998
|
// Array of segments - no match
|
|
981
999
|
expect(
|
|
982
|
-
|
|
1000
|
+
applyContextToGroupSegments(featurevisorWithSegments, ["web", "chrome"], {
|
|
983
1001
|
platform: "mobile",
|
|
984
1002
|
browser: "safari",
|
|
985
1003
|
}),
|
|
@@ -989,8 +1007,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
989
1007
|
test("AND group segments", function () {
|
|
990
1008
|
// AND with all matching segments (all "*" becomes "*")
|
|
991
1009
|
expect(
|
|
992
|
-
|
|
993
|
-
|
|
1010
|
+
applyContextToGroupSegments(
|
|
1011
|
+
featurevisorWithSegments,
|
|
994
1012
|
{
|
|
995
1013
|
and: ["web", "chrome"],
|
|
996
1014
|
},
|
|
@@ -1005,8 +1023,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1005
1023
|
|
|
1006
1024
|
// AND with partial match
|
|
1007
1025
|
expect(
|
|
1008
|
-
|
|
1009
|
-
|
|
1026
|
+
applyContextToGroupSegments(
|
|
1027
|
+
featurevisorWithSegments,
|
|
1010
1028
|
{
|
|
1011
1029
|
and: ["web", "chrome"],
|
|
1012
1030
|
},
|
|
@@ -1020,8 +1038,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1020
1038
|
|
|
1021
1039
|
// AND with no matches
|
|
1022
1040
|
expect(
|
|
1023
|
-
|
|
1024
|
-
|
|
1041
|
+
applyContextToGroupSegments(
|
|
1042
|
+
featurevisorWithSegments,
|
|
1025
1043
|
{
|
|
1026
1044
|
and: ["web", "chrome"],
|
|
1027
1045
|
},
|
|
@@ -1036,8 +1054,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1036
1054
|
|
|
1037
1055
|
// AND with "*" in it
|
|
1038
1056
|
expect(
|
|
1039
|
-
|
|
1040
|
-
|
|
1057
|
+
applyContextToGroupSegments(
|
|
1058
|
+
featurevisorWithSegments,
|
|
1041
1059
|
{
|
|
1042
1060
|
and: ["*", "chrome"],
|
|
1043
1061
|
},
|
|
@@ -1053,8 +1071,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1053
1071
|
test("OR group segments", function () {
|
|
1054
1072
|
// OR with all matching segments (all "*" becomes "*")
|
|
1055
1073
|
expect(
|
|
1056
|
-
|
|
1057
|
-
|
|
1074
|
+
applyContextToGroupSegments(
|
|
1075
|
+
featurevisorWithSegments,
|
|
1058
1076
|
{
|
|
1059
1077
|
or: ["web", "chrome"],
|
|
1060
1078
|
},
|
|
@@ -1069,8 +1087,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1069
1087
|
|
|
1070
1088
|
// OR with partial match
|
|
1071
1089
|
expect(
|
|
1072
|
-
|
|
1073
|
-
|
|
1090
|
+
applyContextToGroupSegments(
|
|
1091
|
+
featurevisorWithSegments,
|
|
1074
1092
|
{
|
|
1075
1093
|
or: ["web", "chrome"],
|
|
1076
1094
|
},
|
|
@@ -1084,8 +1102,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1084
1102
|
|
|
1085
1103
|
// OR with no matches
|
|
1086
1104
|
expect(
|
|
1087
|
-
|
|
1088
|
-
|
|
1105
|
+
applyContextToGroupSegments(
|
|
1106
|
+
featurevisorWithSegments,
|
|
1089
1107
|
{
|
|
1090
1108
|
or: ["web", "mobile"],
|
|
1091
1109
|
},
|
|
@@ -1101,8 +1119,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1101
1119
|
test("NOT group segments", function () {
|
|
1102
1120
|
// NOT with matching segment
|
|
1103
1121
|
expect(
|
|
1104
|
-
|
|
1105
|
-
|
|
1122
|
+
applyContextToGroupSegments(
|
|
1123
|
+
featurevisorWithSegments,
|
|
1106
1124
|
{
|
|
1107
1125
|
not: ["web"],
|
|
1108
1126
|
},
|
|
@@ -1116,8 +1134,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1116
1134
|
|
|
1117
1135
|
// NOT with non-matching segment
|
|
1118
1136
|
expect(
|
|
1119
|
-
|
|
1120
|
-
|
|
1137
|
+
applyContextToGroupSegments(
|
|
1138
|
+
featurevisorWithSegments,
|
|
1121
1139
|
{
|
|
1122
1140
|
not: ["web"],
|
|
1123
1141
|
},
|
|
@@ -1131,8 +1149,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1131
1149
|
|
|
1132
1150
|
// NOT with multiple segments (all "*" becomes "*")
|
|
1133
1151
|
expect(
|
|
1134
|
-
|
|
1135
|
-
|
|
1152
|
+
applyContextToGroupSegments(
|
|
1153
|
+
featurevisorWithSegments,
|
|
1136
1154
|
{
|
|
1137
1155
|
not: ["web", "chrome"],
|
|
1138
1156
|
},
|
|
@@ -1149,8 +1167,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1149
1167
|
test("nested AND group segments", function () {
|
|
1150
1168
|
// Nested AND with all matching (all "*" becomes "*")
|
|
1151
1169
|
expect(
|
|
1152
|
-
|
|
1153
|
-
|
|
1170
|
+
applyContextToGroupSegments(
|
|
1171
|
+
featurevisorWithSegments,
|
|
1154
1172
|
{
|
|
1155
1173
|
and: [
|
|
1156
1174
|
"web",
|
|
@@ -1176,8 +1194,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1176
1194
|
|
|
1177
1195
|
// Nested AND with partial match
|
|
1178
1196
|
expect(
|
|
1179
|
-
|
|
1180
|
-
|
|
1197
|
+
applyContextToGroupSegments(
|
|
1198
|
+
featurevisorWithSegments,
|
|
1181
1199
|
{
|
|
1182
1200
|
and: [
|
|
1183
1201
|
"web",
|
|
@@ -1204,8 +1222,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1204
1222
|
test("nested OR group segments", function () {
|
|
1205
1223
|
// Nested OR with all matching
|
|
1206
1224
|
expect(
|
|
1207
|
-
|
|
1208
|
-
|
|
1225
|
+
applyContextToGroupSegments(
|
|
1226
|
+
featurevisorWithSegments,
|
|
1209
1227
|
{
|
|
1210
1228
|
or: [
|
|
1211
1229
|
"web",
|
|
@@ -1230,8 +1248,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1230
1248
|
|
|
1231
1249
|
// Nested OR with partial match
|
|
1232
1250
|
expect(
|
|
1233
|
-
|
|
1234
|
-
|
|
1251
|
+
applyContextToGroupSegments(
|
|
1252
|
+
featurevisorWithSegments,
|
|
1235
1253
|
{
|
|
1236
1254
|
or: [
|
|
1237
1255
|
"web",
|
|
@@ -1257,8 +1275,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1257
1275
|
test("complex nested structures", function () {
|
|
1258
1276
|
// Complex nested with AND, OR, NOT
|
|
1259
1277
|
expect(
|
|
1260
|
-
|
|
1261
|
-
|
|
1278
|
+
applyContextToGroupSegments(
|
|
1279
|
+
featurevisorWithSegments,
|
|
1262
1280
|
{
|
|
1263
1281
|
and: [
|
|
1264
1282
|
"web",
|
|
@@ -1291,7 +1309,7 @@ describe("core: buildScopedSegments", function () {
|
|
|
1291
1309
|
test("segments with complex conditions", function () {
|
|
1292
1310
|
// Segment with AND conditions in its definition
|
|
1293
1311
|
expect(
|
|
1294
|
-
|
|
1312
|
+
applyContextToGroupSegments(featurevisorWithSegments, "premium", {
|
|
1295
1313
|
tier: "premium",
|
|
1296
1314
|
status: "active",
|
|
1297
1315
|
}),
|
|
@@ -1299,7 +1317,7 @@ describe("core: buildScopedSegments", function () {
|
|
|
1299
1317
|
|
|
1300
1318
|
// Segment with AND conditions that doesn't match
|
|
1301
1319
|
expect(
|
|
1302
|
-
|
|
1320
|
+
applyContextToGroupSegments(featurevisorWithSegments, "premium", {
|
|
1303
1321
|
tier: "premium",
|
|
1304
1322
|
status: "inactive",
|
|
1305
1323
|
}),
|
|
@@ -1308,21 +1326,23 @@ describe("core: buildScopedSegments", function () {
|
|
|
1308
1326
|
|
|
1309
1327
|
test("removeSegments parameter", function () {
|
|
1310
1328
|
// Simple segment in removeSegments
|
|
1311
|
-
expect(
|
|
1329
|
+
expect(applyContextToGroupSegments(featurevisorWithSegments, "web", {}, ["web"])).toEqual(
|
|
1330
|
+
"*",
|
|
1331
|
+
);
|
|
1312
1332
|
|
|
1313
1333
|
// Segment not in removeSegments
|
|
1314
|
-
expect(
|
|
1334
|
+
expect(applyContextToGroupSegments(featurevisorWithSegments, "web", {}, ["mobile"])).toEqual(
|
|
1315
1335
|
"web",
|
|
1316
1336
|
);
|
|
1317
1337
|
|
|
1318
1338
|
// Array with one segment in removeSegments
|
|
1319
1339
|
expect(
|
|
1320
|
-
|
|
1340
|
+
applyContextToGroupSegments(featurevisorWithSegments, ["web", "chrome"], {}, ["web"]),
|
|
1321
1341
|
).toEqual(["*", "chrome"]);
|
|
1322
1342
|
|
|
1323
1343
|
// Array with all segments in removeSegments
|
|
1324
1344
|
expect(
|
|
1325
|
-
|
|
1345
|
+
applyContextToGroupSegments(featurevisorWithSegments, ["web", "chrome"], {}, [
|
|
1326
1346
|
"web",
|
|
1327
1347
|
"chrome",
|
|
1328
1348
|
]),
|
|
@@ -1330,8 +1350,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1330
1350
|
|
|
1331
1351
|
// Array with multiple segments, some in removeSegments
|
|
1332
1352
|
expect(
|
|
1333
|
-
|
|
1334
|
-
|
|
1353
|
+
applyContextToGroupSegments(
|
|
1354
|
+
featurevisorWithSegments,
|
|
1335
1355
|
["web", "chrome", "mobile", "safari"],
|
|
1336
1356
|
{},
|
|
1337
1357
|
["web", "mobile"],
|
|
@@ -1340,8 +1360,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1340
1360
|
|
|
1341
1361
|
// AND group segment with removeSegments
|
|
1342
1362
|
expect(
|
|
1343
|
-
|
|
1344
|
-
|
|
1363
|
+
applyContextToGroupSegments(
|
|
1364
|
+
featurevisorWithSegments,
|
|
1345
1365
|
{
|
|
1346
1366
|
and: ["web", "chrome"],
|
|
1347
1367
|
},
|
|
@@ -1354,8 +1374,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1354
1374
|
|
|
1355
1375
|
// AND group segment with all segments in removeSegments
|
|
1356
1376
|
expect(
|
|
1357
|
-
|
|
1358
|
-
|
|
1377
|
+
applyContextToGroupSegments(
|
|
1378
|
+
featurevisorWithSegments,
|
|
1359
1379
|
{
|
|
1360
1380
|
and: ["web", "chrome"],
|
|
1361
1381
|
},
|
|
@@ -1368,8 +1388,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1368
1388
|
|
|
1369
1389
|
// OR group segment with removeSegments
|
|
1370
1390
|
expect(
|
|
1371
|
-
|
|
1372
|
-
|
|
1391
|
+
applyContextToGroupSegments(
|
|
1392
|
+
featurevisorWithSegments,
|
|
1373
1393
|
{
|
|
1374
1394
|
or: ["web", "chrome"],
|
|
1375
1395
|
},
|
|
@@ -1382,8 +1402,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1382
1402
|
|
|
1383
1403
|
// OR group segment with all segments in removeSegments
|
|
1384
1404
|
expect(
|
|
1385
|
-
|
|
1386
|
-
|
|
1405
|
+
applyContextToGroupSegments(
|
|
1406
|
+
featurevisorWithSegments,
|
|
1387
1407
|
{
|
|
1388
1408
|
or: ["web", "chrome"],
|
|
1389
1409
|
},
|
|
@@ -1396,8 +1416,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1396
1416
|
|
|
1397
1417
|
// NOT group segment with removeSegments
|
|
1398
1418
|
expect(
|
|
1399
|
-
|
|
1400
|
-
|
|
1419
|
+
applyContextToGroupSegments(
|
|
1420
|
+
featurevisorWithSegments,
|
|
1401
1421
|
{
|
|
1402
1422
|
not: ["web", "chrome"],
|
|
1403
1423
|
},
|
|
@@ -1410,8 +1430,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1410
1430
|
|
|
1411
1431
|
// NOT group segment with all segments in removeSegments
|
|
1412
1432
|
expect(
|
|
1413
|
-
|
|
1414
|
-
|
|
1433
|
+
applyContextToGroupSegments(
|
|
1434
|
+
featurevisorWithSegments,
|
|
1415
1435
|
{
|
|
1416
1436
|
not: ["web", "chrome"],
|
|
1417
1437
|
},
|
|
@@ -1424,8 +1444,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1424
1444
|
|
|
1425
1445
|
// Nested AND with removeSegments
|
|
1426
1446
|
expect(
|
|
1427
|
-
|
|
1428
|
-
|
|
1447
|
+
applyContextToGroupSegments(
|
|
1448
|
+
featurevisorWithSegments,
|
|
1429
1449
|
{
|
|
1430
1450
|
and: [
|
|
1431
1451
|
"web",
|
|
@@ -1448,8 +1468,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1448
1468
|
|
|
1449
1469
|
// Nested OR with removeSegments
|
|
1450
1470
|
expect(
|
|
1451
|
-
|
|
1452
|
-
|
|
1471
|
+
applyContextToGroupSegments(
|
|
1472
|
+
featurevisorWithSegments,
|
|
1453
1473
|
{
|
|
1454
1474
|
or: [
|
|
1455
1475
|
"web",
|
|
@@ -1472,8 +1492,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1472
1492
|
|
|
1473
1493
|
// Mixed nested structure with removeSegments
|
|
1474
1494
|
expect(
|
|
1475
|
-
|
|
1476
|
-
|
|
1495
|
+
applyContextToGroupSegments(
|
|
1496
|
+
featurevisorWithSegments,
|
|
1477
1497
|
{
|
|
1478
1498
|
and: [
|
|
1479
1499
|
"web",
|
|
@@ -1502,8 +1522,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1502
1522
|
|
|
1503
1523
|
// removeSegments combined with matching context
|
|
1504
1524
|
expect(
|
|
1505
|
-
|
|
1506
|
-
|
|
1525
|
+
applyContextToGroupSegments(
|
|
1526
|
+
featurevisorWithSegments,
|
|
1507
1527
|
["web", "chrome"],
|
|
1508
1528
|
{
|
|
1509
1529
|
platform: "web",
|
|
@@ -1514,8 +1534,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1514
1534
|
|
|
1515
1535
|
// removeSegments with segment that would match context
|
|
1516
1536
|
expect(
|
|
1517
|
-
|
|
1518
|
-
|
|
1537
|
+
applyContextToGroupSegments(
|
|
1538
|
+
featurevisorWithSegments,
|
|
1519
1539
|
["web", "chrome"],
|
|
1520
1540
|
{
|
|
1521
1541
|
platform: "web",
|
|
@@ -1527,8 +1547,8 @@ describe("core: buildScopedSegments", function () {
|
|
|
1527
1547
|
|
|
1528
1548
|
// Complex: removeSegments, context matching, and nested structures
|
|
1529
1549
|
expect(
|
|
1530
|
-
|
|
1531
|
-
|
|
1550
|
+
applyContextToGroupSegments(
|
|
1551
|
+
featurevisorWithSegments,
|
|
1532
1552
|
{
|
|
1533
1553
|
and: [
|
|
1534
1554
|
"web",
|
|
@@ -1555,18 +1575,18 @@ describe("core: buildScopedSegments", function () {
|
|
|
1555
1575
|
});
|
|
1556
1576
|
|
|
1557
1577
|
// Empty removeSegments array (should behave like no removeSegments)
|
|
1558
|
-
expect(
|
|
1578
|
+
expect(applyContextToGroupSegments(featurevisorWithSegments, "web", {}, [])).toEqual("web");
|
|
1559
1579
|
|
|
1560
1580
|
// removeSegments with segment that doesn't exist in datafile
|
|
1561
1581
|
expect(
|
|
1562
|
-
|
|
1582
|
+
applyContextToGroupSegments(featurevisorWithSegments, ["web", "nonexistent"], {}, [
|
|
1563
1583
|
"nonexistent",
|
|
1564
1584
|
]),
|
|
1565
1585
|
).toEqual(["web", "*"]);
|
|
1566
1586
|
|
|
1567
1587
|
// removeSegments with "*" in array (should still work)
|
|
1568
1588
|
expect(
|
|
1569
|
-
|
|
1589
|
+
applyContextToGroupSegments(featurevisorWithSegments, ["*", "web", "chrome"], {}, ["web"]),
|
|
1570
1590
|
).toEqual(["*", "*", "chrome"]);
|
|
1571
1591
|
});
|
|
1572
1592
|
});
|