Skip to content

Commit 46c6ec0

Browse files
committed
add basic test
1 parent 8504652 commit 46c6ec0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as semver from 'semver';
2+
3+
import { expect, test } from '@grafana/plugin-e2e';
4+
5+
test.use({
6+
featureToggles: {
7+
localizationForPlugins: true,
8+
},
9+
userPreferences: {
10+
language: 'sv-SE',
11+
},
12+
});
13+
14+
test('should display correct translation based on Grafana version (Swedish for v11+, English fallback for <v11)', async ({
15+
gotoPanelEditPage,
16+
readProvisionedDashboard,
17+
grafanaVersion,
18+
page,
19+
}) => {
20+
const dashboard = await readProvisionedDashboard({ fileName: 'dashboard.json' });
21+
const panelEditPage = await gotoPanelEditPage({ dashboard, id: '1' });
22+
23+
const isVersion11OrHigher = semver.gte(grafanaVersion, '11.0.0');
24+
25+
if (isVersion11OrHigher) {
26+
// For Grafana v11+, expect Swedish translations
27+
await expect(panelEditPage.panel.locator.getByText('Textalternativ värde:')).toBeVisible();
28+
const options = panelEditPage.getCustomOptions('Basic');
29+
const showSeriesCounter = options.getSwitch('Visa serieräknare');
30+
await expect(showSeriesCounter.locator()).toBeVisible();
31+
} else {
32+
// For Grafana <v11, expect English fallback
33+
await expect(panelEditPage.panel.locator.getByText('Text option value:')).toBeVisible();
34+
const options = panelEditPage.getCustomOptions('Basic');
35+
const showSeriesCounter = options.getSwitch('Show series counter');
36+
await expect(showSeriesCounter.locator()).toBeVisible();
37+
}
38+
});

0 commit comments

Comments
 (0)