fix: remove i18n fallbackNS (#4964)

* fix: remove i18n fallbackNS

* fix: add e2e
This commit is contained in:
jack zhang 2024-07-30 08:51:50 +08:00 committed by GitHub
parent 3ee075d0ab
commit afa55e38b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 41 additions and 1 deletions

View File

@ -37,7 +37,7 @@ i18n
lng: 'en-US',
// debug: true,
defaultNS: 'client',
fallbackNS: 'client',
// fallbackNS: 'client',
// backend: {
// // for all available options read the backend's repository readme file
// loadPath: '/api/locales/{{lng}}/{{ns}}.json',

View File

@ -68,3 +68,43 @@ test('menu permission ', async ({ page, mockPage, mockRole, updateRole }) => {
await page.waitForSelector('.nb-page-wrapper');
expect(page.url()).toContain(uid2);
});
test('i18n should not fallbackNS', async ({ page }) => {
await page.goto('/admin');
// 创建 Users 页面
await page.getByTestId('schema-initializer-Menu-header').hover();
await page.getByRole('menuitem', { name: 'Page' }).click();
await page.getByRole('textbox').click();
await page.getByRole('textbox').fill('Users');
await page.getByRole('button', { name: 'OK' }).click();
await expect(page.getByLabel('Users')).toBeVisible();
await expect(page.getByLabel('用户')).not.toBeVisible();
// 添加中文选项
await page.goto('/admin/settings/system-settings');
await page.getByTestId('select-multiple').click();
await page.getByRole('option', { name: '简体中文 (zh-CN)' }).click();
await page.getByLabel('action-Action-Submit').click();
// 切换为中文
await page.getByTestId('user-center-button').click();
await page.getByText('LanguageEnglish').click();
await page.getByRole('option', { name: '简体中文' }).click();
await page.goto('/admin/settings/system-settings');
// 应该显示 Users 而非中文 “用户”
await expect(page.getByLabel('Users')).toBeVisible();
await expect(page.getByLabel('用户')).not.toBeVisible();
// 删除中文
await page.getByLabel('简体中文 (zh-CN)').getByLabel('icon-close-tag').click();
await page.getByLabel('action-Action-提交').click();
// 删除 Users 页面
await page.getByLabel('Users').hover();
await page.getByLabel('designer-schema-settings-Menu').hover();
await page.getByRole('menuitem', { name: 'Delete' }).click();
await page.getByRole('button', { name: 'OK' }).click();
});