diff --git a/src/commands/variations/update.test.ts b/src/commands/variations/update.test.ts index 7835e2250..6b608cf5e 100644 --- a/src/commands/variations/update.test.ts +++ b/src/commands/variations/update.test.ts @@ -125,7 +125,11 @@ describe('variations update', () => { .reply(200, mockVariation) ) .nock(BASE_URL, (api) => api - .get(`/v1/projects/${projectKey}/variables?feature=${featureKey}`) + .get(`/v1/projects/${projectKey}/features/${featureKey}`) + .reply(200, mockFeature) + ) + .nock(BASE_URL, (api) => api + .get(`/v1/projects/${projectKey}/variables?feature=63b5eea3e6e91987bae47f3a`) .reply(200, mockVariables) ) .nock(BASE_URL, (api) => api @@ -153,7 +157,11 @@ describe('variations update', () => { .reply(200, mockVariation) ) .nock(BASE_URL, (api) => api - .get(`/v1/projects/${projectKey}/variables?feature=${featureKey}`) + .get(`/v1/projects/${projectKey}/features/${featureKey}`) + .reply(200, mockFeature) + ) + .nock(BASE_URL, (api) => api + .get(`/v1/projects/${projectKey}/variables?feature=63b5eea3e6e91987bae47f3a`) .reply(200, mockVariables) ) .nock(BASE_URL, (api) => api @@ -180,13 +188,18 @@ describe('variations update', () => { .reply(200, mockVariation) ) .nock(BASE_URL, (api) => api - .get(`/v1/projects/${projectKey}/variables?feature=${featureKey}`) + .get(`/v1/projects/${projectKey}/features/${featureKey}`) + .reply(200, mockFeature) + ) + .nock(BASE_URL, (api) => api + .get(`/v1/projects/${projectKey}/variables?feature=63b5eea3e6e91987bae47f3a`) .reply(200, mockVariables) ) .nock(BASE_URL, (api) => api .patch(`/v1/projects/${projectKey}/features/${featureKey}/variations/${variationKey}`, requestBody) .reply(200, mockFeature) ) + .stub(inquirer, 'registerPrompt', () => { return }) .stub(inquirer, 'prompt', () => { return { diff --git a/src/commands/variations/update.ts b/src/commands/variations/update.ts index 03c54cda5..2378a9279 100644 --- a/src/commands/variations/update.ts +++ b/src/commands/variations/update.ts @@ -2,7 +2,7 @@ import inquirer from 'inquirer' import UpdateCommand from '../updateCommand' import { fetchVariationByKey, updateVariation, UpdateVariationParams } from '../../api/variations' import { featurePrompt, keyPrompt, namePrompt } from '../../ui/prompts' -import { Variable } from '../../api/schemas' +import { Feature, Variable } from '../../api/schemas' import { getVariationVariablePrompt, @@ -10,6 +10,7 @@ import { variationPrompt, } from '../../ui/prompts/variationPrompts' import { Args, Flags } from '@oclif/core' +import { fetchFeatureByKey } from '../../api/features' export default class UpdateVariation extends UpdateCommand { static hidden = false @@ -65,11 +66,11 @@ export default class UpdateVariation extends UpdateCommand { } else { selectedVariation = await fetchVariationByKey(this.authToken, this.projectKey, featureKey, args.key) } - + const feature = await fetchFeatureByKey(this.authToken, this.projectKey, featureKey) as Feature this.prompts.push(await getVariationVariablePrompt( this.authToken, this.projectKey, - featureKey, + feature._id, )) this.writer.blankLine()