File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 1+ import { initPluginTranslations , t } from '@grafana/i18n' ;
2+
13import { PanelPlugin } from '@grafana/data' ;
24import { SimpleOptions } from './types' ;
35import { SimplePanel } from './components/SimplePanel' ;
4- import { initPluginTranslations , t } from '@grafana/i18n' ;
56import pluginJson from 'plugin.json' ;
67
78await initPluginTranslations ( pluginJson . id ) ;
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments