Skip to content

Commit c7d8561

Browse files
committed
add basic test
1 parent 3b6f870 commit c7d8561

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

examples/panel-basic/src/module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
import { initPluginTranslations, t } from '@grafana/i18n';
2+
13
import { PanelPlugin } from '@grafana/data';
24
import { SimpleOptions } from './types';
35
import { SimplePanel } from './components/SimplePanel';
4-
import { initPluginTranslations, t } from '@grafana/i18n';
56
import pluginJson from 'plugin.json';
67

78
await initPluginTranslations(pluginJson.id);
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)