Skip to content

Commit cceadbf

Browse files
committed
alternate lang based on grafana version
1 parent c715ff7 commit cceadbf

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed
Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as semver from 'semver';
2+
13
import { expect, test } from '@grafana/plugin-e2e';
24

35
test.use({
@@ -9,17 +11,26 @@ test.use({
911
},
1012
});
1113

12-
test('should display Swedish plugin translations', async ({ gotoPanelEditPage, readProvisionedDashboard, page }) => {
14+
test('should display correct translation based on Grafana version (Swedish for v12+, English fallback for v11)', async ({
15+
gotoPanelEditPage,
16+
readProvisionedDashboard,
17+
grafanaVersion,
18+
page,
19+
}) => {
1320
const dashboard = await readProvisionedDashboard({ fileName: 'dashboard.json' });
1421
const panelEditPage = await gotoPanelEditPage({ dashboard, id: '1' });
15-
await page.evaluate(() => {
16-
console.log('lang', (window as any).grafanaBootData?.user?.language);
17-
console.log('toggles', (window as any).grafanaBootData?.settings.featureToggles);
18-
});
1922

20-
// For Grafana v11+, expect Swedish translations
21-
await expect(panelEditPage.panel.locator.getByText('Textalternativ värde:')).toBeVisible();
22-
const options = panelEditPage.getCustomOptions('Basic');
23-
const showSeriesCounter = options.getSwitch('Visa serieräknare');
24-
await expect(showSeriesCounter.locator()).toBeVisible();
23+
const isVersion12OrHigher = semver.gte(grafanaVersion, '12.0.0');
24+
25+
if (isVersion12OrHigher) {
26+
await expect(panelEditPage.panel.locator.getByText('Textalternativ värde:')).toBeVisible();
27+
const options = panelEditPage.getCustomOptions('Basic');
28+
const showSeriesCounter = options.getSwitch('Visa serieräknare');
29+
await expect(showSeriesCounter.locator()).toBeVisible();
30+
} else {
31+
await expect(panelEditPage.panel.locator.getByText('Text option value:')).toBeVisible();
32+
const options = panelEditPage.getCustomOptions('Basic');
33+
const showSeriesCounter = options.getSwitch('Show series counter');
34+
await expect(showSeriesCounter.locator()).toBeVisible();
35+
}
2536
});

0 commit comments

Comments
 (0)