Files
Ivan Ortega Alba bfedf0b512 Dashboard: Redirect between v1alpha1 and v2alpha1 depending on stored version (#101292)
* wip: Create a proxy state manager to avoid complexity

* Read path redirecting

* add tests for unified dashboard API

* add tests

* Contemplate both formats in DashboardProxy

* Fix force old

* Fix tests for proxy

* catch errors

* Save as V2 when dynamic dashboard is enabled

* Improve tests

* Remove feature toggle

* Use kubernetesDashboards for e2e suite

* Fix issue when loading snapshots

* Fix typescript errors

* Integrate with backend conversion error

* Remove legacy annotation

* fix snapshot loading; lint

* Add missing hideTimeControls

* fix test

* make setupDashboardAPI to all suites

* refactor getDashboardAPI

* Add tests

* fix DashboardScenePage tests

* fix tests

* fix go tests

* Refactor to understand better the need of transforming to v2 to compare

* Fix detect changes logic

* yes status from schema gen

---------

Co-authored-by: alexandra vargas <alexa1866@gmail.com>
Co-authored-by: Haris Rozajac <haris.rozajac12@gmail.com>
2025-03-12 11:43:32 -06:00

64 lines
1.9 KiB
TypeScript

import { config, locationService } from '@grafana/runtime';
import { getDashboardsApiVersion } from './utils';
describe('getDashboardsApiVersion', () => {
beforeEach(() => {
jest.resetModules();
});
it('should return v1 when dashboardScene is disabled and kubernetesDashboards is enabled', () => {
config.featureToggles = {
dashboardScene: false,
kubernetesDashboards: true,
};
expect(getDashboardsApiVersion()).toBe('v1');
});
it('should return legacy when dashboardScene is disabled and kubernetesDashboards is disabled', () => {
config.featureToggles = {
dashboardScene: false,
kubernetesDashboards: false,
};
expect(getDashboardsApiVersion()).toBe('legacy');
});
it('should return unified when dashboardScene is enabled and kubernetesDashboards is enabled', () => {
config.featureToggles = {
dashboardScene: true,
kubernetesDashboards: true,
};
expect(getDashboardsApiVersion()).toBe('unified');
});
it('should return legacy when dashboardScene is enabled and kubernetesDashboards is disabled', () => {
config.featureToggles = {
dashboardScene: true,
kubernetesDashboards: false,
};
expect(getDashboardsApiVersion()).toBe('legacy');
});
describe('forcing scenes through URL', () => {
beforeAll(() => {
locationService.push('/test?scenes=false');
});
it('should return legacy when kubernetesDashboards is disabled', () => {
config.featureToggles = {
dashboardScene: false,
kubernetesDashboards: false,
};
expect(getDashboardsApiVersion()).toBe('legacy');
});
it('should return v1 when kubernetesDashboards is enabled', () => {
config.featureToggles = {
dashboardScene: false,
kubernetesDashboards: true,
};
expect(getDashboardsApiVersion()).toBe('v1');
});
});
});