Core: Replace deprecated jest matcher toBeCalledWith (#86635)

* Replace depredated matcher from jest

* perform rechecks

---------

Co-authored-by: joshhunt <josh@trtr.co>
This commit is contained in:
Krishna Dhakal
2024-05-01 15:33:26 +01:00
committed by GitHub
co-authored by joshhunt
parent c5217aa632
commit deb6d27406
22 changed files with 91 additions and 77 deletions
@@ -59,7 +59,7 @@ describe('LabelFilters', () => {
const { name, value } = getLabelSelects(1);
await selectOptionInTest(name, 'baz');
await selectOptionInTest(value, 'qux');
expect(onChange).toBeCalledWith([
expect(onChange).toHaveBeenCalledWith([
{ label: 'foo', op: '=', value: 'bar' },
{ label: 'baz', op: '=', value: 'qux' },
]);
@@ -68,7 +68,7 @@ describe('LabelFilters', () => {
it('removes label', async () => {
const { onChange } = setup({ labelsFilters: [{ label: 'foo', op: '=', value: 'bar' }] });
await userEvent.click(screen.getByLabelText(/remove-foo/));
expect(onChange).toBeCalledWith([]);
expect(onChange).toHaveBeenCalledWith([]);
});
it('removes label but preserves a label with a value of empty string', async () => {
@@ -80,7 +80,7 @@ describe('LabelFilters', () => {
],
});
await userEvent.click(screen.getByLabelText(/remove-foo/));
expect(onChange).toBeCalledWith([
expect(onChange).toHaveBeenCalledWith([
{ label: 'lab', op: '=', value: 'bel' },
{ label: 'le', op: '=', value: '' },
]);
@@ -90,7 +90,7 @@ describe('PromQueryBuilder', () => {
it('tries to load metrics without labels', async () => {
const { languageProvider, container } = setup();
await openMetricSelect(container);
await waitFor(() => expect(languageProvider.getLabelValues).toBeCalledWith('__name__'));
await waitFor(() => expect(languageProvider.getLabelValues).toHaveBeenCalledWith('__name__'));
});
it('tries to load metrics with labels', async () => {
@@ -99,7 +99,7 @@ describe('PromQueryBuilder', () => {
labels: [{ label: 'label_name', op: '=', value: 'label_value' }],
});
await openMetricSelect(container);
await waitFor(() => expect(languageProvider.getSeries).toBeCalledWith('{label_name="label_value"}', true));
await waitFor(() => expect(languageProvider.getSeries).toHaveBeenCalledWith('{label_name="label_value"}', true));
});
it('tries to load variables in metric field', async () => {
@@ -135,7 +135,9 @@ describe('PromQueryBuilder', () => {
it('tries to load labels when metric selected', async () => {
const { languageProvider } = setup();
await openLabelNameSelect();
await waitFor(() => expect(languageProvider.fetchLabelsWithMatch).toBeCalledWith('{__name__="random_metric"}'));
await waitFor(() =>
expect(languageProvider.fetchLabelsWithMatch).toHaveBeenCalledWith('{__name__="random_metric"}')
);
});
it('tries to load variables in label field', async () => {
@@ -155,7 +157,7 @@ describe('PromQueryBuilder', () => {
});
await openLabelNameSelect(1);
await waitFor(() =>
expect(languageProvider.fetchLabelsWithMatch).toBeCalledWith(
expect(languageProvider.fetchLabelsWithMatch).toHaveBeenCalledWith(
'{label_name="label_value", __name__="random_metric"}'
)
);
@@ -304,7 +306,9 @@ describe('PromQueryBuilder', () => {
jsonData: { prometheusVersion: '2.38.1', prometheusType: PromApplication.Prometheus },
});
await openLabelNameSelect();
await waitFor(() => expect(languageProvider.fetchLabelsWithMatch).toBeCalledWith('{__name__="random_metric"}'));
await waitFor(() =>
expect(languageProvider.fetchLabelsWithMatch).toHaveBeenCalledWith('{__name__="random_metric"}')
);
});
it('tries to load variables in label field modern prom', async () => {
@@ -330,7 +334,7 @@ describe('PromQueryBuilder', () => {
);
await openLabelNameSelect(1);
await waitFor(() =>
expect(languageProvider.fetchLabelsWithMatch).toBeCalledWith(
expect(languageProvider.fetchLabelsWithMatch).toHaveBeenCalledWith(
'{label_name="label_value", __name__="random_metric"}'
)
);
@@ -20,7 +20,7 @@ describe('PromQueryBuilderContainer', () => {
expect(screen.getByText('metric_test')).toBeInTheDocument();
await addOperationInQueryBuilder('Range functions', 'Rate');
expect(props.onChange).toBeCalledWith({
expect(props.onChange).toHaveBeenCalledWith({
expr: 'rate(metric_test{job="testjob"}[$__rate_interval])',
refId: 'A',
});
@@ -142,7 +142,7 @@ describe('PromQueryEditorSelector', () => {
it('changes to builder mode', async () => {
const { onChange } = renderWithMode(QueryEditorMode.Code);
await switchToMode(QueryEditorMode.Builder);
expect(onChange).toBeCalledWith({
expect(onChange).toHaveBeenCalledWith({
refId: 'A',
expr: defaultQuery.expr,
range: true,
@@ -168,7 +168,7 @@ describe('PromQueryEditorSelector', () => {
it('changes to code mode', async () => {
const { onChange } = renderWithMode(QueryEditorMode.Builder);
await switchToMode(QueryEditorMode.Code);
expect(onChange).toBeCalledWith({
expect(onChange).toHaveBeenCalledWith({
refId: 'A',
expr: defaultQuery.expr,
range: true,
@@ -42,7 +42,7 @@ describe('OperationList', () => {
const removeOperationButtons = screen.getAllByTitle('Remove operation');
expect(removeOperationButtons).toHaveLength(2);
await userEvent.click(removeOperationButtons[1]);
expect(onChange).toBeCalledWith({
expect(onChange).toHaveBeenCalledWith({
labels: [{ label: 'instance', op: '=', value: 'localhost:9090' }],
metric: 'random_metric',
operations: [{ id: 'rate', params: ['auto'] }],
@@ -52,7 +52,7 @@ describe('OperationList', () => {
it('adds an operation', async () => {
const { onChange } = setup();
await addOperationInQueryBuilder('Aggregations', 'Min');
expect(onChange).toBeCalledWith({
expect(onChange).toHaveBeenCalledWith({
labels: [{ label: 'instance', op: '=', value: 'localhost:9090' }],
metric: 'random_metric',
operations: [
@@ -44,7 +44,7 @@ describe('ColorPickerPopover', () => {
await userEvent.click(color);
expect(onChangeSpy).toBeCalledTimes(1);
expect(onChangeSpy).toBeCalledWith(theme.visualization.getColorByName('red'));
expect(onChangeSpy).toHaveBeenCalledWith(theme.visualization.getColorByName('red'));
});
it('should pass color name to onChange prop when named colors enabled', async () => {
@@ -53,7 +53,7 @@ describe('ColorPickerPopover', () => {
await userEvent.click(color);
expect(onChangeSpy).toBeCalledTimes(2);
expect(onChangeSpy).toBeCalledWith(theme.visualization.getColorByName('red'));
expect(onChangeSpy).toHaveBeenCalledWith(theme.visualization.getColorByName('red'));
});
});
});
@@ -109,7 +109,7 @@ describe('The FileDropzone component', () => {
expect(await screen.findByText('ping.json')).toBeInTheDocument();
expect(fileReaderSpy).not.toBeCalled();
expect(onDrop).toBeCalledWith([fileToUpload], [], expect.anything());
expect(onDrop).toHaveBeenCalledWith([fileToUpload], [], expect.anything());
});
it('should show children inside the dropzone', () => {
@@ -58,6 +58,6 @@ describe('The FileListItem component', () => {
fireEvent.click(screen.getByRole('button', { name: REMOVE_FILE }));
expect(removeFile).toBeCalledWith(customFile);
expect(removeFile).toHaveBeenCalledWith(customFile);
});
});
@@ -61,7 +61,7 @@ describe('NumberInput', () => {
tests.forEach((test, i) => {
fireEvent.blur(data.input, { target: { value: test.value } });
expect(data.onChange).toBeCalledWith(test.onChangeCalledWith);
expect(data.onChange).toHaveBeenCalledWith(test.onChangeCalledWith);
expect(data.onChange).toBeCalledTimes(i + 1);
expect(data.input).toHaveValue(test.expected);
});
@@ -102,7 +102,7 @@ describe('NumberInput', () => {
tests.forEach((test, i) => {
input = screen.getByTestId('input-wrapper').firstChild?.firstChild as HTMLInputElement;
fireEvent.blur(input, { target: { value: test.value } });
expect(data.onChange).toBeCalledWith(test.onChangeCalledWith);
expect(data.onChange).toHaveBeenCalledWith(test.onChangeCalledWith);
expect(data.onChange).toBeCalledTimes(i + 1);
expect(screen.getByTestId('input-wrapper').firstChild?.firstChild).toHaveValue(test.expected);
});
@@ -58,7 +58,7 @@ describe('ValueMappingsEditorModal', () => {
await userEvent.click(screen.getAllByTestId('remove-value-mapping')[0]);
await userEvent.click(screen.getByText('Update'));
expect(onChangeSpy).toBeCalledWith([
expect(onChangeSpy).toHaveBeenCalledWith([
{
type: MappingType.RangeToText,
options: {
@@ -94,7 +94,7 @@ describe('ValueMappingsEditorModal', () => {
await userEvent.type(screen.getAllByPlaceholderText('Optional display text')[2], 'display');
await userEvent.click(screen.getByText('Update'));
expect(onChangeSpy).toBeCalledWith([
expect(onChangeSpy).toHaveBeenCalledWith([
{
type: MappingType.ValueToText,
options: {
@@ -146,7 +146,7 @@ describe('ValueMappingsEditorModal', () => {
await userEvent.click(screen.getByText('Update'));
expect(onChangeSpy).toBeCalledWith([
expect(onChangeSpy).toHaveBeenCalledWith([
{
type: MappingType.RangeToText,
options: {
@@ -182,7 +182,7 @@ describe('ValueMappingsEditorModal', () => {
await userEvent.click(screen.getByText('Update'));
expect(onChangeSpy).toBeCalledWith([
expect(onChangeSpy).toHaveBeenCalledWith([
{
type: MappingType.RegexToText,
options: {
@@ -44,10 +44,10 @@ describe('loadAndInitDatasource', () => {
const { instance } = await loadAndInitDatasource(1, { uid: 'Unknown' });
expect(dataSourceMock.get).toBeCalledTimes(2);
expect(dataSourceMock.get).toBeCalledWith({ uid: 'Unknown' });
expect(dataSourceMock.get).toBeCalledWith();
expect(dataSourceMock.get).toHaveBeenCalledWith({ uid: 'Unknown' });
expect(dataSourceMock.get).toHaveBeenCalledWith();
expect(instance).toMatchObject(DEFAULT_DATASOURCE);
expect(setLastUsedDatasourceUIDSpy).toBeCalledWith(1, DEFAULT_DATASOURCE.uid);
expect(setLastUsedDatasourceUIDSpy).toHaveBeenCalledWith(1, DEFAULT_DATASOURCE.uid);
});
it('saves last loaded data source uid', async () => {
@@ -65,7 +65,7 @@ describe('loadAndInitDatasource', () => {
expect(getLocalRichHistoryStorage).toHaveBeenCalledTimes(1);
expect(instance).toMatchObject(TEST_DATASOURCE);
expect(setLastUsedDatasourceUIDSpy).toBeCalledWith(1, TEST_DATASOURCE.uid);
expect(setLastUsedDatasourceUIDSpy).toHaveBeenCalledWith(1, TEST_DATASOURCE.uid);
});
it('pulls history data and returns the history by query', async () => {
@@ -122,7 +122,7 @@ describe('emitDataRequestEvent', () => {
emitDataRequestEvent(datasource)(data);
expect(reportMetaAnalytics).toBeCalledTimes(1);
expect(reportMetaAnalytics).toBeCalledWith(
expect(reportMetaAnalytics).toHaveBeenCalledWith(
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
datasourceName: datasource.name,
@@ -150,7 +150,7 @@ describe('emitDataRequestEvent', () => {
emitDataRequestEvent(datasource)(data);
expect(reportMetaAnalytics).toBeCalledTimes(1);
expect(reportMetaAnalytics).toBeCalledWith(
expect(reportMetaAnalytics).toHaveBeenCalledWith(
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
datasourceName: datasource.name,
@@ -178,7 +178,7 @@ describe('emitDataRequestEvent', () => {
emitDataRequestEvent(datasource)(data);
expect(reportMetaAnalytics).toBeCalledTimes(1);
expect(reportMetaAnalytics).toBeCalledWith(
expect(reportMetaAnalytics).toHaveBeenCalledWith(
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
datasourceName: datasource.name,
@@ -229,7 +229,7 @@ describe('emitDataRequestEvent', () => {
emitDataRequestEvent(datasource)(data);
expect(reportMetaAnalytics).toBeCalledTimes(1);
expect(reportMetaAnalytics).toBeCalledWith(
expect(reportMetaAnalytics).toHaveBeenCalledWith(
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
source: CoreApp.Explore,
@@ -247,7 +247,7 @@ describe('emitDataRequestEvent', () => {
emitDataRequestEvent(datasource)(data);
expect(reportMetaAnalytics).toBeCalledTimes(1);
expect(reportMetaAnalytics).toBeCalledWith(expect.not.objectContaining({ error: 'test error' }));
expect(reportMetaAnalytics).toHaveBeenCalledWith(expect.not.objectContaining({ error: 'test error' }));
});
});
@@ -266,7 +266,7 @@ describe('emitDataRequestEvent', () => {
emitDataRequestEvent(datasource)(data);
expect(reportMetaAnalytics).toBeCalledTimes(1);
expect(reportMetaAnalytics).toBeCalledWith(
expect(reportMetaAnalytics).toHaveBeenCalledWith(
expect.objectContaining({
eventName: MetaAnalyticsEventName.DataRequest,
source: CoreApp.Correlations,
@@ -284,7 +284,7 @@ describe('emitDataRequestEvent', () => {
emitDataRequestEvent(datasource)(data);
expect(reportMetaAnalytics).toBeCalledTimes(1);
expect(reportMetaAnalytics).toBeCalledWith(expect.not.objectContaining({ error: 'test error' }));
expect(reportMetaAnalytics).toHaveBeenCalledWith(expect.not.objectContaining({ error: 'test error' }));
});
});
});
@@ -419,8 +419,8 @@ describe('updateQueries with import', () => {
oldUidDSWithAbstract as any
);
expect(exportSpy).toBeCalledWith(queries);
expect(importSpy).toBeCalledWith(queries.map((q) => ({ ...q, exported: true })));
expect(exportSpy).toHaveBeenCalledWith(queries);
expect(importSpy).toHaveBeenCalledWith(queries.map((q) => ({ ...q, exported: true })));
expect(updated).toMatchInlineSnapshot(`
[
@@ -543,7 +543,7 @@ describe('updateQueries with import', () => {
const updated = await updateQueries(newUidDSWithImport, newUidDSWithImport.uid, queries, oldUidDS);
expect(importSpy).toBeCalledWith(queries, { uid: 'old-uid', type: 'old-type', meta: { id: 'old-type' } });
expect(importSpy).toHaveBeenCalledWith(queries, { uid: 'old-uid', type: 'old-type', meta: { id: 'old-type' } });
expect(updated).toMatchInlineSnapshot(`
[
@@ -33,7 +33,7 @@ describe('LogsQueryEditor.TimeManagement', () => {
const dashboardTimeOption = await screen.findByLabelText('Dashboard');
await userEvent.click(dashboardTimeOption);
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
azureLogAnalytics: expect.objectContaining({
dashboardTime: true,
@@ -52,7 +52,7 @@ describe('LogsQueryEditor.TimeManagement', () => {
/>
);
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
azureLogAnalytics: expect.objectContaining({
timeColumn: 'TimeGenerated',
@@ -90,7 +90,7 @@ describe('LogsQueryEditor.TimeManagement', () => {
/>
);
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
azureLogAnalytics: expect.objectContaining({
timeColumn: 'TimeGenerated',
@@ -128,7 +128,7 @@ describe('LogsQueryEditor.TimeManagement', () => {
/>
);
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
azureLogAnalytics: expect.objectContaining({
timeColumn: 'Timespan',
@@ -158,7 +158,7 @@ describe('MetricsQueryEditor', () => {
await userEvent.click(await screen.findByRole('button', { name: 'Apply' }));
expect(onChange).toBeCalledTimes(1);
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
subscription: 'def-456',
azureMonitor: expect.objectContaining({
@@ -213,7 +213,7 @@ describe('MetricsQueryEditor', () => {
await userEvent.click(await screen.findByRole('button', { name: 'Apply' }));
expect(onChange).toBeCalledTimes(1);
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
subscription: 'def-456',
azureMonitor: expect.objectContaining({
@@ -461,7 +461,7 @@ describe('MetricsQueryEditor', () => {
await userEvent.click(applyButton);
expect(onChange).toBeCalledTimes(1);
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({
azureMonitor: expect.objectContaining({
resources: [{ subscription: 'def-123', metricNamespace: 'ns', resourceGroup: 'rg', resourceName: 'rn' }],
@@ -89,7 +89,7 @@ describe('VisualMetricQueryEditor', () => {
await act(async () => {
await select(service, 'Srv', { container: document.body });
});
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({ filters: ['metric.type', '=', mockMetricDescriptor.type] })
);
});
@@ -128,7 +128,7 @@ describe('VisualMetricQueryEditor', () => {
await act(async () => {
await select(metricName, 'metricName_test', { container: document.body });
});
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({ filters: ['metric.type', '=', mockMetricDescriptor.type] })
);
});
@@ -209,7 +209,7 @@ describe('VisualMetricQueryEditor', () => {
await act(async () => {
await select(service, 'Srv 2', { container: document.body });
});
expect(onChange).toBeCalledWith(expect.objectContaining({ filters: ['metric.type', '=', 'type2'] }));
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ filters: ['metric.type', '=', 'type2'] }));
expect(query).toEqual(defaultQuery);
expect(screen.queryByText('metric.test_label')).not.toBeInTheDocument();
});
@@ -261,7 +261,7 @@ describe('VisualMetricQueryEditor', () => {
await act(async () => {
await select(metric, 'metricName2', { container: document.body });
});
expect(onChange).toBeCalledWith(
expect(onChange).toHaveBeenCalledWith(
expect.objectContaining({ filters: ['metric.test_label', '=', 'test', 'AND', 'metric.type', '=', 'type2'] })
);
expect(query).toEqual(defaultQuery);
@@ -51,7 +51,7 @@ describe('variables', () => {
mock.datasource.resources.getMetrics = getMetrics;
const query = { ...defaultQuery, queryType: VariableQueryType.Metrics, accountId: '123' };
const result = await variables.execute(query);
expect(getMetrics).toBeCalledWith({
expect(getMetrics).toHaveBeenCalledWith({
region: query.region,
namespace: 'foo',
accountId: query.accountId,
@@ -63,7 +63,7 @@ describe('variables', () => {
mock.datasource.resources.getDimensionKeys = getDimensionKeys;
const query = { ...defaultQuery, queryType: VariableQueryType.DimensionKeys, accountId: '123' };
const result = await variables.execute(query);
expect(getDimensionKeys).toBeCalledWith({
expect(getDimensionKeys).toHaveBeenCalledWith({
region: query.region,
namespace: query.namespace,
accountId: query.accountId,
@@ -120,7 +120,7 @@ describe('variables', () => {
});
it('should run if values are set', async () => {
const result = await variables.execute(query);
expect(getDimensionValues).toBeCalledWith({
expect(getDimensionValues).toHaveBeenCalledWith({
region: query.region,
namespace: query.namespace,
metricName: query.metricName,
@@ -150,7 +150,7 @@ describe('variables', () => {
queryType: VariableQueryType.EBSVolumeIDs,
instanceID: 'foo',
});
expect(getEbsVolumeIds).toBeCalledWith(defaultQuery.region, 'foo');
expect(getEbsVolumeIds).toHaveBeenCalledWith(defaultQuery.region, 'foo');
expect(result).toEqual([{ text: 'f', value: 'f', expandable: true }]);
});
});
@@ -175,7 +175,7 @@ describe('variables', () => {
it('should run if instance id set', async () => {
const result = await variables.execute(query);
expect(getEc2InstanceAttribute).toBeCalledWith(query.region, query.attributeName, { a: ['b'] });
expect(getEc2InstanceAttribute).toHaveBeenCalledWith(query.region, query.attributeName, { a: ['b'] });
expect(result).toEqual([{ text: 'g', value: 'g', expandable: true }]);
});
});
@@ -200,7 +200,7 @@ describe('variables', () => {
it('should run if instance id set', async () => {
const result = await variables.execute(query);
expect(getResourceARNs).toBeCalledWith(query.region, query.resourceType, { a: ['b'] });
expect(getResourceARNs).toHaveBeenCalledWith(query.region, query.resourceType, { a: ['b'] });
expect(result).toEqual([{ text: 'h', value: 'h', expandable: true }]);
});
});
@@ -238,7 +238,7 @@ describe('variables', () => {
accountId: '123',
};
await variables.execute(query);
expect(getLogGroups).toBeCalledWith({
expect(getLogGroups).toHaveBeenCalledWith({
region: query.region,
logGroupNamePrefix: 'templatedField',
listAllLogGroups: true,
@@ -24,7 +24,7 @@ describe('VariableSupport', () => {
vs.query(getDefaultRequest({ type: 'label', profileTypeId: 'profile:type:3', refId: 'A' }))
);
expect(resp.data).toEqual([{ text: 'foo' }, { text: 'bar' }, { text: 'baz' }]);
expect(mock.getLabelNames).toBeCalledWith(
expect(mock.getLabelNames).toHaveBeenCalledWith(
'{__profile_type__="profile:type:3"}',
expect.any(Number),
expect.any(Number)
@@ -38,7 +38,7 @@ describe('VariableSupport', () => {
vs.query(getDefaultRequest({ type: 'labelValue', labelName: 'foo', profileTypeId: 'profile:type:3', refId: 'A' }))
);
expect(resp.data).toEqual([{ text: 'val1' }, { text: 'val2' }, { text: 'val3' }]);
expect(mock.getLabelValues).toBeCalledWith(
expect(mock.getLabelValues).toHaveBeenCalledWith(
'{__profile_type__="profile:type:3"}',
'foo',
expect.any(Number),
@@ -209,19 +209,25 @@ describe('Graphite actions', () => {
const currentRange = { from: 0, to: 1 };
ctx.state.range = currentRange;
await getTagsSelectables(ctx.state, 0, 'any');
expect(ctx.state.datasource.getTagsAutoComplete).toBeCalledWith([], 'any', { range: currentRange, limit: 5000 });
expect(ctx.state.datasource.getTagsAutoComplete).toHaveBeenCalledWith([], 'any', {
range: currentRange,
limit: 5000,
});
});
it('current time range and limit is passed when getting list of tags for adding', async () => {
const currentRange = { from: 0, to: 1 };
ctx.state.range = currentRange;
await getTagsAsSegmentsSelectables(ctx.state, 'any');
expect(ctx.state.datasource.getTagsAutoComplete).toBeCalledWith([], 'any', { range: currentRange, limit: 5000 });
expect(ctx.state.datasource.getTagsAutoComplete).toHaveBeenCalledWith([], 'any', {
range: currentRange,
limit: 5000,
});
});
it('limit is passed when getting list of tag values', async () => {
await getTagValuesSelectables(ctx.state, { key: 'key', operator: '=', value: 'value' }, 1, 'test');
expect(ctx.state.datasource.getTagValuesAutoComplete).toBeCalledWith([], 'key', 'test', { limit: 5000 });
expect(ctx.state.datasource.getTagValuesAutoComplete).toHaveBeenCalledWith([], 'key', 'test', { limit: 5000 });
});
describe('when autocomplete for metric names is not available', () => {
@@ -237,7 +243,7 @@ describe('Graphite actions', () => {
it('getAltSegmentsSelectables should handle autocomplete errors', async () => {
await expect(async () => {
await getAltSegmentsSelectables(ctx.state, 0, 'any');
expect(mockDispatch).toBeCalledWith(
expect(mockDispatch).toHaveBeenCalledWith(
expect.objectContaining({
type: 'appNotifications/notifyApp',
})
@@ -267,7 +273,7 @@ describe('Graphite actions', () => {
it('getTagsSelectables should handle autocomplete errors', async () => {
await expect(async () => {
await getTagsSelectables(ctx.state, 0, 'any');
expect(mockDispatch).toBeCalledWith(
expect(mockDispatch).toHaveBeenCalledWith(
expect.objectContaining({
type: 'appNotifications/notifyApp',
})
@@ -286,7 +292,7 @@ describe('Graphite actions', () => {
it('getTagsAsSegmentsSelectables should handle autocomplete errors', async () => {
await expect(async () => {
await getTagsAsSegmentsSelectables(ctx.state, 'any');
expect(mockDispatch).toBeCalledWith(
expect(mockDispatch).toHaveBeenCalledWith(
expect.objectContaining({
type: 'appNotifications/notifyApp',
})
@@ -74,7 +74,7 @@ describe('JaegerDatasource', () => {
],
};
await lastValueFrom(ds.query(query));
expect(mock).toBeCalledWith({ url: `${defaultSettings.url}/api/traces/a%2Fb` });
expect(mock).toHaveBeenCalledWith({ url: `${defaultSettings.url}/api/traces/a%2Fb` });
});
it('returns empty response if trace id is not specified', async () => {
@@ -127,7 +127,7 @@ describe('JaegerDatasource', () => {
targets: [{ queryType: 'search', refId: 'a', service: 'jaeger-query', operation: '/api/services' }],
})
);
expect(mock).toBeCalledWith({
expect(mock).toHaveBeenCalledWith({
url: `${defaultSettings.url}/api/traces?service=jaeger-query&operation=%2Fapi%2Fservices&start=1704085200000000&end=1704106800000000&lookback=custom`,
});
expect(response.data[0].meta.preferredVisualisationType).toBe('table');
@@ -156,7 +156,7 @@ describe('JaegerDatasource', () => {
targets: [{ queryType: 'search', refId: 'a', service: 'jaeger-query', operation: ALL_OPERATIONS_KEY }],
})
);
expect(mock).toBeCalledWith({
expect(mock).toHaveBeenCalledWith({
url: `${defaultSettings.url}/api/traces?service=jaeger-query&start=1704085200000000&end=1704106800000000&lookback=custom`,
});
});
@@ -170,7 +170,7 @@ describe('JaegerDatasource', () => {
targets: [{ queryType: 'search', refId: 'a', service: 'jaeger-query', tags: 'error=true' }],
})
);
expect(mock).toBeCalledWith({
expect(mock).toHaveBeenCalledWith({
url: `${defaultSettings.url}/api/traces?service=jaeger-query&tags=%7B%22error%22%3A%22true%22%7D&start=1704085200000000&end=1704106800000000&lookback=custom`,
});
});
@@ -196,7 +196,7 @@ describe('JaegerDatasource', () => {
],
})
);
expect(mock).toBeCalledWith({
expect(mock).toHaveBeenCalledWith({
url: `${defaultSettings.url}/api/traces/5311b0dd0ca8df3463df93c99cb805a6`,
});
});
@@ -216,7 +216,7 @@ describe('JaegerDatasource', () => {
targets: [{ queryType: 'search', refId: 'a', service: 'jaeger-query', tags: 'error=$error' }],
})
);
expect(mock).toBeCalledWith({
expect(mock).toHaveBeenCalledWith({
url: `${defaultSettings.url}/api/traces?service=jaeger-query&tags=%7B%22error%22%3A%22true%22%7D&start=1704085200000000&end=1704106800000000&lookback=custom`,
});
});
@@ -246,7 +246,7 @@ describe('JaegerDatasource', () => {
],
})
);
expect(mock).toBeCalledWith({
expect(mock).toHaveBeenCalledWith({
url: `${defaultSettings.url}/api/traces?service=interpolationText&operation=interpolationText&minDuration=interpolationText&maxDuration=interpolationText&start=1704085200000000&end=1704106800000000&lookback=custom`,
});
});
@@ -59,7 +59,7 @@ describe('LokiQueryBuilder', () => {
const labels = screen.getByText(/Label filters/);
const selects = getAllByRole(getSelectParent(labels)!, 'combobox');
await userEvent.click(selects[3]);
expect(props.datasource.languageProvider.fetchSeriesLabels).toBeCalledWith('{baz="bar"}', {
expect(props.datasource.languageProvider.fetchSeriesLabels).toHaveBeenCalledWith('{baz="bar"}', {
timeRange: mockTimeRange,
});
await waitFor(() => expect(screen.getByText('job')).toBeInTheDocument());
@@ -82,7 +82,9 @@ describe('LokiQueryBuilder', () => {
const labels = screen.getByText(/Label filters/);
const selects = getAllByRole(getSelectParent(labels)!, 'combobox');
await userEvent.click(selects[5]);
expect(props.datasource.languageProvider.fetchLabelValues).toBeCalledWith('job', { timeRange: mockTimeRange });
expect(props.datasource.languageProvider.fetchLabelValues).toHaveBeenCalledWith('job', {
timeRange: mockTimeRange,
});
expect(props.datasource.languageProvider.fetchSeriesLabels).not.toBeCalled();
});
@@ -103,7 +105,9 @@ describe('LokiQueryBuilder', () => {
const labels = screen.getByText(/Label filters/);
const selects = getAllByRole(getSelectParent(labels)!, 'combobox');
await userEvent.click(selects[5]);
expect(props.datasource.languageProvider.fetchLabelValues).toBeCalledWith('job', { timeRange: mockTimeRange });
expect(props.datasource.languageProvider.fetchLabelValues).toHaveBeenCalledWith('job', {
timeRange: mockTimeRange,
});
expect(props.datasource.languageProvider.fetchSeriesLabels).not.toBeCalled();
});
@@ -124,7 +128,7 @@ describe('LokiQueryBuilder', () => {
const labels = screen.getByText(/Label filters/);
const selects = getAllByRole(getSelectParent(labels)!, 'combobox');
await userEvent.click(selects[3]);
expect(props.datasource.languageProvider.fetchLabels).toBeCalledWith({ timeRange: mockTimeRange });
expect(props.datasource.languageProvider.fetchLabels).toHaveBeenCalledWith({ timeRange: mockTimeRange });
expect(props.datasource.languageProvider.fetchSeriesLabels).not.toBeCalled();
});
@@ -145,7 +149,7 @@ describe('LokiQueryBuilder', () => {
const labels = screen.getByText(/Label filters/);
const selects = getAllByRole(getSelectParent(labels)!, 'combobox');
await userEvent.click(selects[5]);
expect(props.datasource.languageProvider.fetchSeriesLabels).toBeCalledWith('{cluster=~"cluster1|cluster2"}', {
expect(props.datasource.languageProvider.fetchSeriesLabels).toHaveBeenCalledWith('{cluster=~"cluster1|cluster2"}', {
timeRange: mockTimeRange,
});
expect(props.datasource.languageProvider.fetchLabelValues).not.toBeCalled();
@@ -306,7 +306,7 @@ describe('DataGrid', () => {
fireEvent.blur(columnInput);
expect(spy).toBeCalledWith(
expect(spy).toHaveBeenCalledWith(
expect.objectContaining({
fields: expect.arrayContaining([
expect.objectContaining({