mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
tests update
This commit is contained in:
parent
44012b5cd6
commit
43f894236a
@ -150,7 +150,7 @@ export const DashboardInteractions = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const reportDashboardInteraction: typeof reportInteraction = (name, properties) => {
|
const reportDashboardInteraction: typeof reportInteraction = (name, properties) => {
|
||||||
const meta = isScenesContextSet ? { scenesView: true } : {};
|
const meta = isScenesContextSet ? { scenesView: true } : undefined;
|
||||||
|
|
||||||
if (properties) {
|
if (properties) {
|
||||||
reportInteraction(`dashboards_${name}`, properties, meta);
|
reportInteraction(`dashboards_${name}`, properties, meta);
|
||||||
|
@ -110,7 +110,11 @@ it('creates new visualization when clicked on menu item Visualization', () => {
|
|||||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Visualization' }));
|
fireEvent.click(screen.getByRole('menuitem', { name: 'Visualization' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reportInteraction).toHaveBeenCalledWith('dashboards_toolbar_add_clicked', { item: 'add_visualization' });
|
expect(reportInteraction).toHaveBeenCalledWith(
|
||||||
|
'dashboards_toolbar_add_clicked',
|
||||||
|
{ item: 'add_visualization' },
|
||||||
|
undefined
|
||||||
|
);
|
||||||
expect(locationService.partial).toHaveBeenCalled();
|
expect(locationService.partial).toHaveBeenCalled();
|
||||||
expect(onCreateNewPanel).toHaveBeenCalled();
|
expect(onCreateNewPanel).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -122,7 +126,7 @@ it('creates new row when clicked on menu item Row', () => {
|
|||||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Row' }));
|
fireEvent.click(screen.getByRole('menuitem', { name: 'Row' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reportInteraction).toHaveBeenCalledWith('dashboards_toolbar_add_clicked', { item: 'add_row' });
|
expect(reportInteraction).toHaveBeenCalledWith('dashboards_toolbar_add_clicked', { item: 'add_row' }, undefined);
|
||||||
expect(locationService.partial).not.toHaveBeenCalled();
|
expect(locationService.partial).not.toHaveBeenCalled();
|
||||||
expect(onCreateNewRow).toHaveBeenCalled();
|
expect(onCreateNewRow).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -134,7 +138,11 @@ it('adds a library panel when clicked on menu item Import from library', () => {
|
|||||||
fireEvent.click(screen.getByRole('menuitem', { name: 'Import from library' }));
|
fireEvent.click(screen.getByRole('menuitem', { name: 'Import from library' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reportInteraction).toHaveBeenCalledWith('dashboards_toolbar_add_clicked', { item: 'import_from_library' });
|
expect(reportInteraction).toHaveBeenCalledWith(
|
||||||
|
'dashboards_toolbar_add_clicked',
|
||||||
|
{ item: 'import_from_library' },
|
||||||
|
undefined
|
||||||
|
);
|
||||||
expect(locationService.partial).not.toHaveBeenCalled();
|
expect(locationService.partial).not.toHaveBeenCalled();
|
||||||
expect(onAddLibraryPanel).toHaveBeenCalled();
|
expect(onAddLibraryPanel).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -371,9 +371,13 @@ describe('SharePublic - Report interactions', () => {
|
|||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(reportInteraction).toHaveBeenCalledTimes(1);
|
expect(reportInteraction).toHaveBeenCalledTimes(1);
|
||||||
expect(reportInteraction).toHaveBeenLastCalledWith('dashboards_sharing_public_time_picker_clicked', {
|
expect(reportInteraction).toHaveBeenLastCalledWith(
|
||||||
enabled: !pubdashResponse.timeSelectionEnabled,
|
'dashboards_sharing_public_time_picker_clicked',
|
||||||
});
|
{
|
||||||
|
enabled: !pubdashResponse.timeSelectionEnabled,
|
||||||
|
},
|
||||||
|
undefined
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -388,9 +392,13 @@ describe('SharePublic - Report interactions', () => {
|
|||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(reportInteraction).toHaveBeenCalledTimes(1);
|
expect(reportInteraction).toHaveBeenCalledTimes(1);
|
||||||
expect(reportInteraction).toHaveBeenLastCalledWith('dashboards_sharing_public_annotations_clicked', {
|
expect(reportInteraction).toHaveBeenLastCalledWith(
|
||||||
enabled: !pubdashResponse.annotationsEnabled,
|
'dashboards_sharing_public_annotations_clicked',
|
||||||
});
|
{
|
||||||
|
enabled: !pubdashResponse.annotationsEnabled,
|
||||||
|
},
|
||||||
|
undefined
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
it('reports interaction when pause is clicked', async () => {
|
it('reports interaction when pause is clicked', async () => {
|
||||||
@ -402,9 +410,13 @@ describe('SharePublic - Report interactions', () => {
|
|||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(reportInteraction).toHaveBeenCalledTimes(1);
|
expect(reportInteraction).toHaveBeenCalledTimes(1);
|
||||||
expect(reportInteraction).toHaveBeenLastCalledWith('dashboards_sharing_public_pause_clicked', {
|
expect(reportInteraction).toHaveBeenLastCalledWith(
|
||||||
paused: pubdashResponse.isEnabled,
|
'dashboards_sharing_public_pause_clicked',
|
||||||
});
|
{
|
||||||
|
paused: pubdashResponse.isEnabled,
|
||||||
|
},
|
||||||
|
undefined
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -75,7 +75,11 @@ it('creates new visualization when clicked Add visualization', () => {
|
|||||||
fireEvent.click(screen.getByRole('button', { name: 'Add visualization' }));
|
fireEvent.click(screen.getByRole('button', { name: 'Add visualization' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reportInteraction).toHaveBeenCalledWith('dashboards_emptydashboard_clicked', { item: 'add_visualization' });
|
expect(reportInteraction).toHaveBeenCalledWith(
|
||||||
|
'dashboards_emptydashboard_clicked',
|
||||||
|
{ item: 'add_visualization' },
|
||||||
|
undefined
|
||||||
|
);
|
||||||
expect(locationService.partial).toHaveBeenCalled();
|
expect(locationService.partial).toHaveBeenCalled();
|
||||||
expect(onCreateNewPanel).toHaveBeenCalled();
|
expect(onCreateNewPanel).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
@ -87,7 +91,11 @@ it('open import dashboard when clicked Import dashboard', () => {
|
|||||||
fireEvent.click(screen.getByRole('button', { name: 'Import dashboard' }));
|
fireEvent.click(screen.getByRole('button', { name: 'Import dashboard' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reportInteraction).toHaveBeenCalledWith('dashboards_emptydashboard_clicked', { item: 'import_dashboard' });
|
expect(reportInteraction).toHaveBeenCalledWith(
|
||||||
|
'dashboards_emptydashboard_clicked',
|
||||||
|
{ item: 'import_dashboard' },
|
||||||
|
undefined
|
||||||
|
);
|
||||||
expect(onImportDashboard).toHaveBeenCalled();
|
expect(onImportDashboard).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -98,7 +106,11 @@ it('adds a library panel when clicked Add library panel', () => {
|
|||||||
fireEvent.click(screen.getByRole('button', { name: 'Add library panel' }));
|
fireEvent.click(screen.getByRole('button', { name: 'Add library panel' }));
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(reportInteraction).toHaveBeenCalledWith('dashboards_emptydashboard_clicked', { item: 'import_from_library' });
|
expect(reportInteraction).toHaveBeenCalledWith(
|
||||||
|
'dashboards_emptydashboard_clicked',
|
||||||
|
{ item: 'import_from_library' },
|
||||||
|
undefined
|
||||||
|
);
|
||||||
expect(locationService.partial).not.toHaveBeenCalled();
|
expect(locationService.partial).not.toHaveBeenCalled();
|
||||||
expect(onAddLibraryPanel).toHaveBeenCalled();
|
expect(onAddLibraryPanel).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
@ -35,22 +35,26 @@ describe('trackDashboardLoaded', () => {
|
|||||||
|
|
||||||
trackDashboardLoaded(model, 16);
|
trackDashboardLoaded(model, 16);
|
||||||
|
|
||||||
expect(reportInteractionSpy).toHaveBeenCalledWith('dashboards_init_dashboard_completed', {
|
expect(reportInteractionSpy).toHaveBeenCalledWith(
|
||||||
uid: 'dashboard-123',
|
'dashboards_init_dashboard_completed',
|
||||||
title: 'Test Dashboard',
|
{
|
||||||
schemaVersion: model.schemaVersion, // This value is based on public/app/features/dashboard/state/DashboardMigrator.ts#L81
|
uid: 'dashboard-123',
|
||||||
panels_count: 7,
|
title: 'Test Dashboard',
|
||||||
variable_type_query_count: 2,
|
schemaVersion: model.schemaVersion, // This value is based on public/app/features/dashboard/state/DashboardMigrator.ts#L81
|
||||||
variable_type_interval_count: 1,
|
panels_count: 7,
|
||||||
version_before_migration: 16,
|
variable_type_query_count: 2,
|
||||||
panel_type_row_count: 1,
|
variable_type_interval_count: 1,
|
||||||
panel_type_stat_count: 1,
|
version_before_migration: 16,
|
||||||
panel_type_graph_count: 2,
|
panel_type_row_count: 1,
|
||||||
panel_type_timeseries_count: 1,
|
panel_type_stat_count: 1,
|
||||||
'panel_type_grafana-worldmap-panel_count': 1,
|
panel_type_graph_count: 2,
|
||||||
panel_type_geomap_count: 1,
|
panel_type_timeseries_count: 1,
|
||||||
settings_nowdelay: '1m',
|
'panel_type_grafana-worldmap-panel_count': 1,
|
||||||
settings_livenow: true,
|
panel_type_geomap_count: 1,
|
||||||
});
|
settings_nowdelay: '1m',
|
||||||
|
settings_livenow: true,
|
||||||
|
},
|
||||||
|
undefined
|
||||||
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user