Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions src/commands/variations/update.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions src/commands/variations/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ 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,
promptForVariationVariableValues,
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
Expand Down Expand Up @@ -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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems like it would be an API bug, all the endpoints should accept either a key or an ID 🤔

Copy link
Copy Markdown
Contributor

@laurawarr laurawarr Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh, I see the error is coming from the variables request, not the variations request

Copy link
Copy Markdown
Contributor Author

@elliotCamblor elliotCamblor Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even for query params? This field in the query params class has a decorater called isObjectIDorFalse which makes it seem intentional

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im just not sure why 😅

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally all values could be accepted as keys, I'm assuming we made this choice to avoid querying the feature by key just to build the variable query params. We could consider updating the API, but that's out of scope of this work 😛

))

this.writer.blankLine()
Expand Down