From afa55e38b350f3aec2aaa58d18f04a3ca16e4978 Mon Sep 17 00:00:00 2001 From: jack zhang <1098626505@qq.com> Date: Tue, 30 Jul 2024 08:51:50 +0800 Subject: [PATCH] fix: remove i18n fallbackNS (#4964) * fix: remove i18n fallbackNS * fix: add e2e --- packages/core/client/src/i18n/i18n.ts | 2 +- .../src/client/__e2e__/menu.test.ts | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/packages/core/client/src/i18n/i18n.ts b/packages/core/client/src/i18n/i18n.ts index 98b7d59020..b0618a2a00 100644 --- a/packages/core/client/src/i18n/i18n.ts +++ b/packages/core/client/src/i18n/i18n.ts @@ -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', diff --git a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts index 8a2fd2c651..51f2fe10a1 100644 --- a/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts +++ b/packages/plugins/@nocobase/plugin-acl/src/client/__e2e__/menu.test.ts @@ -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(); +});