diff --git a/.changeset/cost-insights-smooth-toes-draw.md b/.changeset/cost-insights-smooth-toes-draw.md new file mode 100644 index 0000000000..e106cbda9c --- /dev/null +++ b/.changeset/cost-insights-smooth-toes-draw.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-cost-insights': patch +--- + +fix for query parameters with null groups diff --git a/plugins/cost-insights/src/utils/history.test.ts b/plugins/cost-insights/src/utils/history.test.ts index e4310e13c6..dff6015aca 100644 --- a/plugins/cost-insights/src/utils/history.test.ts +++ b/plugins/cost-insights/src/utils/history.test.ts @@ -61,7 +61,9 @@ describe.each` params | expected ${''} | ${{}} ${'?foo=bar'} | ${{}} + ${'?group'} | ${{ group: null }} ${'?project'} | ${{ project: null }} + ${'?project&group'} | ${{ group: null, project: null }} ${'?group=some-group'} | ${{ group: 'some-group' }} ${'?group=some-group&project'} | ${{ group: 'some-group', project: null }} ${'?group=some-group&project=some-project'} | ${{ group: 'some-group', project: 'some-project' }} @@ -72,9 +74,3 @@ describe.each` expect(pageFilters).toMatchObject(expected); }); }); - -describe('invalidate', () => { - it("should throw an error if param values don't match schema", async () => { - await expect(validate('?group')).rejects.toThrowError(); - }); -}); diff --git a/plugins/cost-insights/src/utils/history.ts b/plugins/cost-insights/src/utils/history.ts index 7d45cfdad2..9e13db3c7a 100644 --- a/plugins/cost-insights/src/utils/history.ts +++ b/plugins/cost-insights/src/utils/history.ts @@ -23,7 +23,7 @@ import { ConfigContextProps } from '../hooks/useConfig'; const schema = yup .object() .shape({ - group: yup.string(), + group: yup.string().nullable(), project: yup.string().nullable(), }) .required();