From bf897c1255966690951a324ee0b6eadfdca19f8e Mon Sep 17 00:00:00 2001 From: Kristina Durivage Date: Tue, 16 Apr 2024 12:14:08 -0500 Subject: [PATCH] Add clarifying comments/docs --- contribute/developer-guide.md | 4 ++++ .../features/explore/extensions/AddToDashboard/index.test.tsx | 2 ++ 2 files changed, 6 insertions(+) diff --git a/contribute/developer-guide.md b/contribute/developer-guide.md index 6df07b690e0..120e8a0daa9 100644 --- a/contribute/developer-guide.md +++ b/contribute/developer-guide.md @@ -333,6 +333,10 @@ ulimit: open files: cannot modify limit: Operation not permitted If that happens to you, chances are you've already set a lower limit and your shell won't let you set a higher one. Try looking in your shell initialization files (~/.bashrc typically), if there's already an ulimit command that you can tweak. +### Getting `AggregateError` when building frontend tests + +If you encounter an `AggregateError` when building new tests, this is probably due to a call to our client [backend service](https://github.com/grafana/grafana/blob/main/public/app/core/services/backend_srv.ts) not being mocked. Our backend service anticipates multiple responses being returned and was built to return errors as an array. A test encountering errors from the service will group those errors as an `AggregateError` without breaking down the individual errors within. `backend_srv.processRequestError` is called once per error and is a great place to return information on what the individual errors might contain. + ## Next steps - Read our [style guides](/contribute/style-guides). diff --git a/public/app/features/explore/extensions/AddToDashboard/index.test.tsx b/public/app/features/explore/extensions/AddToDashboard/index.test.tsx index 42bcf6d4e9a..63549b181fc 100644 --- a/public/app/features/explore/extensions/AddToDashboard/index.test.tsx +++ b/public/app/features/explore/extensions/AddToDashboard/index.test.tsx @@ -57,6 +57,8 @@ describe('AddToDashboardButton', () => { setEchoSrv(new Echo()); }); + /* The Add to dashboard form brings in the DashboardPicker, which will call backendSrv.search as part of its instantiation + If we do not need a list of dashboards for the test, return an empty array. */ beforeEach(() => { // Mock the search response so we don't get any refused connection errors // from this test (as the fetch polyfill means this logic would actually try and call the API)