add test for migrator

This commit is contained in:
alexandra vargas
2025-07-18 11:25:33 +02:00
parent 8ee9ef744a
commit 9d86eecc4c
@@ -105,6 +105,107 @@ describe('v1 migrator', () => {
},
});
});
it('correctly parses state with queryRef', () => {
expect(
v1Migrator.parse({
panes: `{
"aaa": {
"datasource": "my-ds",
"queries": [
{
"refId": "A"
}
],
"range": {
"from": "now",
"to": "now-5m"
},
"queryRef": "library-query-123"
}
}`,
}).to
).toMatchObject({
panes: {
aaa: {
datasource: 'my-ds',
queries: [{ refId: 'A' }],
range: {
from: 'now',
to: 'now-5m',
},
queryRef: 'library-query-123',
},
},
});
});
it('ignores queryRef if it is not a string', () => {
expect(
v1Migrator.parse({
panes: `{
"aaa": {
"datasource": "my-ds",
"queries": [
{
"refId": "A"
}
],
"range": {
"from": "now",
"to": "now-5m"
},
"queryRef": 123
}
}`,
}).to
).toMatchObject({
panes: {
aaa: {
datasource: 'my-ds',
queries: [{ refId: 'A' }],
range: {
from: 'now',
to: 'now-5m',
},
},
},
});
});
it('handles empty string queryRef', () => {
expect(
v1Migrator.parse({
panes: `{
"aaa": {
"datasource": "my-ds",
"queries": [
{
"refId": "A"
}
],
"range": {
"from": "now",
"to": "now-5m"
},
"queryRef": ""
}
}`,
}).to
).toMatchObject({
panes: {
aaa: {
datasource: 'my-ds',
queries: [{ refId: 'A' }],
range: {
from: 'now',
to: 'now-5m',
},
queryRef: '',
},
},
});
});
});
describe('migrate', () => {