From fffd1af6c08518d3660af45db4661feea472052b Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Mon, 24 May 2021 17:36:03 -0400 Subject: [PATCH 1/4] null groups are valid Signed-off-by: Ryan Vazquez --- plugins/cost-insights/src/utils/history.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From e153e4371bf5c3c4d3da10f7d10aa7466b0d90e8 Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Mon, 24 May 2021 17:54:11 -0400 Subject: [PATCH 2/4] update tests Signed-off-by: Ryan Vazquez --- plugins/cost-insights/src/utils/history.test.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/plugins/cost-insights/src/utils/history.test.ts b/plugins/cost-insights/src/utils/history.test.ts index e4310e13c6..961a2ce241 100644 --- a/plugins/cost-insights/src/utils/history.test.ts +++ b/plugins/cost-insights/src/utils/history.test.ts @@ -61,6 +61,7 @@ describe.each` params | expected ${''} | ${{}} ${'?foo=bar'} | ${{}} + ${'?group'} | ${{ group: null }} ${'?project'} | ${{ project: null }} ${'?group=some-group'} | ${{ group: 'some-group' }} ${'?group=some-group&project'} | ${{ group: 'some-group', project: null }} @@ -72,9 +73,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(); - }); -}); From 41c3ec421fd0e7aec2d5be8e4e9ad40d0d7d4d31 Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Mon, 24 May 2021 17:56:03 -0400 Subject: [PATCH 3/4] changeset Signed-off-by: Ryan Vazquez --- .changeset/cost-insights-smooth-toes-draw.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/cost-insights-smooth-toes-draw.md 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 From 4915b554d055b7dc28c1117122bb192299d691e6 Mon Sep 17 00:00:00 2001 From: Ryan Vazquez Date: Mon, 24 May 2021 18:12:19 -0400 Subject: [PATCH 4/4] test for null groups and project Signed-off-by: Ryan Vazquez --- plugins/cost-insights/src/utils/history.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/cost-insights/src/utils/history.test.ts b/plugins/cost-insights/src/utils/history.test.ts index 961a2ce241..dff6015aca 100644 --- a/plugins/cost-insights/src/utils/history.test.ts +++ b/plugins/cost-insights/src/utils/history.test.ts @@ -63,6 +63,7 @@ describe.each` ${'?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' }}