Skip to content

Commit abe6860

Browse files
authored
Fix error when user chooses no Y fields in the Plot Wizard (#4808)
1 parent 02fb41f commit abe6860

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

extension/src/pipeline/quickPick.test.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -497,19 +497,26 @@ describe('pickPlotConfiguration', () => {
497497
})
498498

499499
it('should return early if the user does not pick a y field', async () => {
500-
mockedPickFiles.mockResolvedValueOnce(['/file.json'])
501-
mockedLoadDataFiles.mockResolvedValueOnce([
500+
mockedPickFiles.mockResolvedValue(['/file.json'])
501+
mockedLoadDataFiles.mockResolvedValue([
502502
{ data: mockValidData, file: 'file.json' }
503503
])
504-
mockedQuickPickOne.mockResolvedValueOnce('simple')
505-
mockedGetInput.mockResolvedValueOnce('simple_plot')
506-
mockedQuickPickValue.mockResolvedValueOnce('actual')
507-
mockedQuickPickValues.mockResolvedValueOnce(undefined)
504+
mockedQuickPickOne.mockResolvedValue('simple')
505+
mockedGetInput.mockResolvedValue('simple_plot')
506+
mockedQuickPickValue.mockResolvedValue('actual')
507+
mockedQuickPickValues
508+
.mockResolvedValueOnce(undefined)
509+
.mockResolvedValueOnce([])
508510

509-
const result = await pickPlotConfiguration('/')
511+
const undefinedResult = await pickPlotConfiguration('/')
510512

511513
expect(mockedQuickPickValues).toHaveBeenCalledTimes(1)
512-
expect(result).toStrictEqual(undefined)
514+
expect(undefinedResult).toStrictEqual(undefined)
515+
516+
const emptyFieldsResult = await pickPlotConfiguration('/')
517+
518+
expect(mockedQuickPickValues).toHaveBeenCalledTimes(2)
519+
expect(emptyFieldsResult).toStrictEqual(undefined)
513520
})
514521

515522
it('should return early if the user does not pick a title', async () => {

extension/src/pipeline/quickPick.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ const pickFields = async (
9292
{ title: Title.SELECT_PLOT_Y_METRIC }
9393
)) as { file: string; key: string }[] | undefined
9494

95-
if (!yValues) {
95+
if (!yValues || yValues.length === 0) {
9696
return
9797
}
9898

0 commit comments

Comments
 (0)