|
1 | 1 | import { describe, expect, it } from 'vitest' |
2 | 2 | import { stackDefinitions } from '../constants/config.js' |
3 | 3 | import { |
| 4 | + applyFeatureToggle, |
4 | 5 | deriveStepDisplay, |
5 | 6 | getPackagesToRemove, |
6 | 7 | getPostInstallMessages, |
7 | 8 | isFeatureSelected, |
8 | 9 | isValidName, |
| 10 | + resolveSelectedFeatures, |
9 | 11 | } from '../utils/utils.js' |
10 | 12 |
|
11 | 13 | const evmFeatures = stackDefinitions.evm.features |
@@ -136,6 +138,66 @@ describe('getPostInstallMessages', () => { |
136 | 138 | }) |
137 | 139 | }) |
138 | 140 |
|
| 141 | +describe('resolveSelectedFeatures — canton (e2e requires counter)', () => { |
| 142 | + it('pulls counter in when only e2e is selected', () => { |
| 143 | + expect(resolveSelectedFeatures('canton', ['e2e'])).toEqual(['counter', 'e2e']) |
| 144 | + }) |
| 145 | + |
| 146 | + it('leaves an already-complete selection unchanged', () => { |
| 147 | + expect(resolveSelectedFeatures('canton', ['counter', 'e2e'])).toEqual(['counter', 'e2e']) |
| 148 | + }) |
| 149 | + |
| 150 | + it('orders the resolved set by config order, not selection order', () => { |
| 151 | + expect(resolveSelectedFeatures('canton', ['e2e', 'carpincho'])).toEqual([ |
| 152 | + 'counter', |
| 153 | + 'e2e', |
| 154 | + 'carpincho', |
| 155 | + ]) |
| 156 | + }) |
| 157 | + |
| 158 | + it('does not pull e2e in when only counter is selected (one-directional)', () => { |
| 159 | + expect(resolveSelectedFeatures('canton', ['counter'])).toEqual(['counter']) |
| 160 | + }) |
| 161 | + |
| 162 | + it('de-duplicates when a requirement is already present', () => { |
| 163 | + expect(resolveSelectedFeatures('canton', ['counter', 'e2e', 'carpincho'])).toEqual([ |
| 164 | + 'counter', |
| 165 | + 'e2e', |
| 166 | + 'carpincho', |
| 167 | + ]) |
| 168 | + }) |
| 169 | +}) |
| 170 | + |
| 171 | +describe('resolveSelectedFeatures — evm (no requires)', () => { |
| 172 | + it('returns the selection unchanged, in config order', () => { |
| 173 | + expect(resolveSelectedFeatures('evm', ['subgraph', 'demo'])).toEqual(['demo', 'subgraph']) |
| 174 | + }) |
| 175 | +}) |
| 176 | + |
| 177 | +describe('applyFeatureToggle — canton (interactive cascade)', () => { |
| 178 | + it('selecting e2e pulls counter in', () => { |
| 179 | + expect(applyFeatureToggle('canton', ['carpincho'], 'e2e', 'select')).toEqual([ |
| 180 | + 'counter', |
| 181 | + 'e2e', |
| 182 | + 'carpincho', |
| 183 | + ]) |
| 184 | + }) |
| 185 | + |
| 186 | + it('unselecting counter cascades e2e out', () => { |
| 187 | + expect( |
| 188 | + applyFeatureToggle('canton', ['counter', 'e2e', 'carpincho'], 'counter', 'unselect'), |
| 189 | + ).toEqual(['carpincho']) |
| 190 | + }) |
| 191 | + |
| 192 | + it('unselecting e2e leaves counter alone', () => { |
| 193 | + expect(applyFeatureToggle('canton', ['counter', 'e2e'], 'e2e', 'unselect')).toEqual(['counter']) |
| 194 | + }) |
| 195 | + |
| 196 | + it('selecting counter does not pull e2e', () => { |
| 197 | + expect(applyFeatureToggle('canton', [], 'counter', 'select')).toEqual(['counter']) |
| 198 | + }) |
| 199 | +}) |
| 200 | + |
139 | 201 | describe('deriveStepDisplay', () => { |
140 | 202 | it('shows all steps as completed when done', () => { |
141 | 203 | const result = deriveStepDisplay(['Step 1', 'Step 2', 'Step 3'], 'done') |
|
0 commit comments