Loki Context UI: Do not disable last label (#62866)

* improved text

* prevent all labels removed

* use `structuredClone` instead of lodash

* update test

* get `structuredClone` in test?

* fix using structuredClone
This commit is contained in:
Sven Grossmann
2023-02-10 14:23:17 +01:00
committed by GitHub
parent f0333ac41f
commit 00edc1c6b1
3 changed files with 30 additions and 2 deletions

View File

@@ -15,6 +15,20 @@ jest.mock('@grafana/runtime', () => ({
}));
describe('LokiContextUi', () => {
const savedGlobal = global;
beforeAll(() => {
// TODO: `structuredClone` is not yet in jsdom https://github.com/jsdom/jsdom/issues/3363
if (!(global as any).structuredClone) {
(global as any).structuredClone = function structuredClone(objectToClone: any) {
const stringified = JSON.stringify(objectToClone);
const parsed = JSON.parse(stringified);
return parsed;
};
}
});
afterAll(() => {
global = savedGlobal;
});
const setupProps = (): LokiContextUiProps => {
const mockLanguageProvider = {
start: jest.fn().mockImplementation(() => Promise.resolve()),
@@ -66,7 +80,7 @@ describe('LokiContextUi', () => {
render(<LokiContextUi {...props} />);
// Initial set of labels is available and not selected
expect(await screen.findByText(/Select labels to include in the context query/)).toBeInTheDocument();
expect(await screen.findByText(/Select labels to be included in the context query/)).toBeInTheDocument();
});
it('starts the languageProvider', async () => {