mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
# Backport This will backport the following commits from `main` to `8.6`: - [[i18n] Fix ja-JP locale causing FATAL error when starting kibana (#146704)](https://github.com/elastic/kibana/pull/146704) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ahmad Bamieh","email":"ahmad.bamyeh@elastic.co"},"sourceCommit":{"committedDate":"2022-11-30T18:28:28Z","message":"[i18n] Fix ja-JP locale causing FATAL error when starting kibana (#146704)\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCloses https://github.com/elastic/kibana/issues/146693","sha":"1323fd8de68e0da9e56a6fd26b12b3c031cb74fd","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:skip","v8.6.0","v8.7.0","v8.5.3"],"number":146704,"url":"https://github.com/elastic/kibana/pull/146704","mergeCommit":{"message":"[i18n] Fix ja-JP locale causing FATAL error when starting kibana (#146704)\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCloses https://github.com/elastic/kibana/issues/146693","sha":"1323fd8de68e0da9e56a6fd26b12b3c031cb74fd"}},"sourceBranch":"main","suggestedTargetBranches":["8.6","8.5"],"targetPullRequestStates":[{"branch":"8.6","label":"v8.6.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/146704","number":146704,"mergeCommit":{"message":"[i18n] Fix ja-JP locale causing FATAL error when starting kibana (#146704)\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\r\nCloses https://github.com/elastic/kibana/issues/146693","sha":"1323fd8de68e0da9e56a6fd26b12b3c031cb74fd"}},{"branch":"8.5","label":"v8.5.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ahmad Bamieh <ahmad.bamyeh@elastic.co> Co-authored-by: Ahmad Bamieh <ahmadbamieh@gmail.com>
This commit is contained in:
parent
cfeb5a7f37
commit
0cbcf24414
16 changed files with 213 additions and 6 deletions
|
@ -7,6 +7,7 @@ disabled:
|
|||
- x-pack/test/functional/config.base.js
|
||||
- x-pack/test/detection_engine_api_integration/security_and_spaces/config.base.ts
|
||||
- x-pack/test/functional_enterprise_search/base_config.ts
|
||||
- x-pack/test/localization/config.base.ts
|
||||
- test/server_integration/config.base.js
|
||||
|
||||
# QA suites that are run out-of-band
|
||||
|
@ -116,6 +117,9 @@ enabled:
|
|||
- test/server_integration/http/ssl/config.js
|
||||
- test/ui_capabilities/newsfeed_err/config.ts
|
||||
- x-pack/test/accessibility/config.ts
|
||||
- x-pack/test/localization/config.ja_jp.ts
|
||||
- x-pack/test/localization/config.fr_fr.ts
|
||||
- x-pack/test/localization/config.zh_cn.ts
|
||||
- x-pack/test/alerting_api_integration/basic/config.ts
|
||||
- x-pack/test/alerting_api_integration/security_and_spaces/group1/config.ts
|
||||
- x-pack/test/alerting_api_integration/security_and_spaces/group2/config.ts
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"paths": {
|
||||
"guidedOnboardingExample": "."
|
||||
},
|
||||
"translations": ["translations/ja-JP.json"]
|
||||
"translations": []
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"paths": {
|
||||
"screenshotModeExample": "."
|
||||
},
|
||||
"translations": ["translations/ja-JP.json"]
|
||||
"translations": []
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"paths": {
|
||||
"files": "."
|
||||
},
|
||||
"translations": ["translations/ja-JP.json"]
|
||||
"translations": []
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"paths": {
|
||||
"guidedOnboarding": "."
|
||||
},
|
||||
"translations": ["translations/ja-JP.json"]
|
||||
"translations": []
|
||||
}
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
"paths": {
|
||||
"cloudFullStory": "."
|
||||
},
|
||||
"translations": ["translations/ja-JP.json"]
|
||||
"translations": []
|
||||
}
|
||||
|
|
|
@ -332,6 +332,7 @@ exports[`LoginPage page renders as expected 1`] = `
|
|||
</span>
|
||||
<EuiTitle
|
||||
className="loginWelcome__title"
|
||||
data-test-subj="loginWelcomeTitle"
|
||||
size="m"
|
||||
>
|
||||
<h1>
|
||||
|
|
|
@ -130,7 +130,7 @@ export class LoginPage extends Component<Props, State> {
|
|||
<span className="loginWelcome__logo">
|
||||
<EuiIcon type="logoElastic" size="xxl" />
|
||||
</span>
|
||||
<EuiTitle size="m" className="loginWelcome__title">
|
||||
<EuiTitle size="m" className="loginWelcome__title" data-test-subj="loginWelcomeTitle">
|
||||
<h1>
|
||||
<FormattedMessage
|
||||
id="xpack.security.loginPage.welcomeTitle"
|
||||
|
|
3
x-pack/test/localization/README.md
Normal file
3
x-pack/test/localization/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
# FTR tests for the `core.i18n` service
|
||||
|
||||
Contains sanity checks to ensure that Kibana can load each supported locale without failures.
|
31
x-pack/test/localization/config.base.ts
Normal file
31
x-pack/test/localization/config.base.ts
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { resolve } from 'path';
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { services, pageObjects } from './ftr_provider_context';
|
||||
|
||||
export async function withLocale({ readConfigFile }: FtrConfigProviderContext, locale: string) {
|
||||
const functionalConfig = await readConfigFile(require.resolve('../functional/config.base.js'));
|
||||
|
||||
return {
|
||||
...functionalConfig.getAll(),
|
||||
testFiles: [require.resolve('./tests')],
|
||||
services,
|
||||
pageObjects,
|
||||
junit: {
|
||||
reportName: `Localization (${locale}) Integration Tests`,
|
||||
},
|
||||
screenshots: {
|
||||
directory: resolve(__dirname, 'screenshots'),
|
||||
},
|
||||
kbnTestServer: {
|
||||
...functionalConfig.get('kbnTestServer'),
|
||||
serverArgs: [...functionalConfig.get('kbnTestServer.serverArgs'), `--i18n.locale=${locale}`],
|
||||
},
|
||||
};
|
||||
}
|
20
x-pack/test/localization/config.fr_fr.ts
Normal file
20
x-pack/test/localization/config.fr_fr.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { withLocale } from './config.base';
|
||||
|
||||
/*
|
||||
* These tests exist in a separate configuration because:
|
||||
* 1) The FTR does not support building and installing plugins against built Kibana.
|
||||
* This test must be run against source only in order to build the fixture plugins.
|
||||
* 2) It provides a specific service to make EBT testing easier.
|
||||
* 3) The intention is to grow this suite as more developers use this feature.
|
||||
*/
|
||||
export default async function (ftrConfigProviderContext: FtrConfigProviderContext) {
|
||||
return withLocale(ftrConfigProviderContext, 'fr-FR');
|
||||
}
|
20
x-pack/test/localization/config.ja_jp.ts
Normal file
20
x-pack/test/localization/config.ja_jp.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { withLocale } from './config.base';
|
||||
|
||||
/*
|
||||
* These tests exist in a separate configuration because:
|
||||
* 1) The FTR does not support building and installing plugins against built Kibana.
|
||||
* This test must be run against source only in order to build the fixture plugins.
|
||||
* 2) It provides a specific service to make EBT testing easier.
|
||||
* 3) The intention is to grow this suite as more developers use this feature.
|
||||
*/
|
||||
export default async function (ftrConfigProviderContext: FtrConfigProviderContext) {
|
||||
return withLocale(ftrConfigProviderContext, 'ja-JP');
|
||||
}
|
20
x-pack/test/localization/config.zh_cn.ts
Normal file
20
x-pack/test/localization/config.zh_cn.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { FtrConfigProviderContext } from '@kbn/test';
|
||||
import { withLocale } from './config.base';
|
||||
|
||||
/*
|
||||
* These tests exist in a separate configuration because:
|
||||
* 1) The FTR does not support building and installing plugins against built Kibana.
|
||||
* This test must be run against source only in order to build the fixture plugins.
|
||||
* 2) It provides a specific service to make EBT testing easier.
|
||||
* 3) The intention is to grow this suite as more developers use this feature.
|
||||
*/
|
||||
export default async function (ftrConfigProviderContext: FtrConfigProviderContext) {
|
||||
return withLocale(ftrConfigProviderContext, 'zh-CN');
|
||||
}
|
13
x-pack/test/localization/ftr_provider_context.ts
Normal file
13
x-pack/test/localization/ftr_provider_context.ts
Normal file
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { GenericFtrProviderContext } from '@kbn/test';
|
||||
import { services } from '../functional/services';
|
||||
import { pageObjects } from '../functional/page_objects';
|
||||
|
||||
export type FtrProviderContext = GenericFtrProviderContext<typeof services, typeof pageObjects>;
|
||||
export { services, pageObjects };
|
14
x-pack/test/localization/tests/index.ts
Normal file
14
x-pack/test/localization/tests/index.ts
Normal file
|
@ -0,0 +1,14 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import type { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
export default function ({ loadTestFile }: FtrProviderContext) {
|
||||
describe('Sanity checks', () => {
|
||||
loadTestFile(require.resolve('./login_page'));
|
||||
});
|
||||
}
|
81
x-pack/test/localization/tests/login_page.ts
Normal file
81
x-pack/test/localization/tests/login_page.ts
Normal file
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import type { FtrProviderContext } from '../ftr_provider_context';
|
||||
|
||||
/**
|
||||
* Strings Needs to be hardcoded since getting it from the i18n.translate
|
||||
* function will not actually test if the expected locale is being used.
|
||||
*
|
||||
* The alternative would be to read directly from the filesystem but this
|
||||
* would add unnecessary ties between the test suite and the localization plugin.
|
||||
*/
|
||||
function getExpectedI18nTranslation(locale: string): string | undefined {
|
||||
switch (locale) {
|
||||
case 'ja-JP':
|
||||
return 'Elasticへようこそ';
|
||||
case 'zh-CN':
|
||||
return '欢迎使用 Elastic';
|
||||
case 'fr-FR':
|
||||
return 'Bienvenue dans Elastic';
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function getI18nLocaleFromServerArgs(kbnServerArgs: string[]): string {
|
||||
const re = /--i18n\.locale=(?<locale>.*)/;
|
||||
for (const serverArg of kbnServerArgs) {
|
||||
const match = re.exec(serverArg);
|
||||
const locale = match?.groups?.locale;
|
||||
if (locale) {
|
||||
return locale;
|
||||
}
|
||||
}
|
||||
|
||||
throw Error('i18n.locale is not set in the server arguments');
|
||||
}
|
||||
|
||||
export default function ({ getService, getPageObjects }: FtrProviderContext) {
|
||||
const testSubjects = getService('testSubjects');
|
||||
const config = getService('config');
|
||||
const log = getService('log');
|
||||
const retry = getService('retry');
|
||||
const PageObjects = getPageObjects(['common', 'security']);
|
||||
|
||||
describe('Login Page', function () {
|
||||
this.tags('includeFirefox');
|
||||
|
||||
before(async () => {
|
||||
await PageObjects.security.forceLogout();
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// NOTE: Logout needs to happen before anything else to avoid flaky behavior
|
||||
await PageObjects.security.forceLogout();
|
||||
});
|
||||
|
||||
it('login page meets i18n requirements', async () => {
|
||||
await PageObjects.common.navigateToApp('login');
|
||||
const serverArgs: string[] = config.get('kbnTestServer.serverArgs');
|
||||
const kbnServerLocale = getI18nLocaleFromServerArgs(serverArgs);
|
||||
|
||||
log.debug(`Expecting page to be using ${kbnServerLocale} Locale.`);
|
||||
|
||||
const expectedWelcomeTitleText = getExpectedI18nTranslation(kbnServerLocale);
|
||||
await retry.waitFor(
|
||||
'login page visible',
|
||||
async () => await testSubjects.exists('loginSubmit')
|
||||
);
|
||||
const welcomeTitleText = await testSubjects.getVisibleText('loginWelcomeTitle');
|
||||
|
||||
expect(welcomeTitleText).not.to.be(undefined);
|
||||
expect(welcomeTitleText).to.be(expectedWelcomeTitleText);
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue