Skip to content

Commit 63491f7

Browse files
committed
add tests
1 parent 51ec0a7 commit 63491f7

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { expect, test } from '@grafana/plugin-e2e';
2+
3+
test.use({
4+
featureToggles: {
5+
localizationForPlugins: true,
6+
},
7+
userPreferences: {
8+
language: 'es-ES',
9+
},
10+
});
11+
12+
test('should display Spanish plugin translations for all supported versions (>=11.0.0)', async ({
13+
gotoPanelEditPage,
14+
readProvisionedDashboard,
15+
page,
16+
}) => {
17+
const dashboard = await readProvisionedDashboard({ fileName: 'dashboard.json' });
18+
const panelEditPage = await gotoPanelEditPage({ dashboard, id: '1' });
19+
20+
await expect(panelEditPage.panel.locator.getByText('Valor de la opción de texto:')).toBeVisible();
21+
const options = panelEditPage.getCustomOptions('Basic');
22+
const showSeriesCounter = options.getSwitch('Mostrar contador de series');
23+
await expect(showSeriesCounter.locator()).toBeVisible();
24+
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 v12.1+, English fallback for v11-12.0)', 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 isVersion12Point1OrHigher = semver.gte(grafanaVersion, '12.1.0');
24+
25+
if (isVersion12Point1OrHigher) {
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+
}
36+
});

0 commit comments

Comments
 (0)