mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-07 22:49:26 +08:00
test(l10n): add cluster test
This commit is contained in:
parent
b9d5ad5645
commit
746b54e9c1
@ -0,0 +1,51 @@
|
||||
/**
|
||||
* This file is part of the NocoBase (R) project.
|
||||
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
|
||||
* Authors: NocoBase Team.
|
||||
*
|
||||
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
|
||||
* For more information, please refer to: https://www.nocobase.com/agreement.
|
||||
*/
|
||||
|
||||
import { createMockCluster, sleep } from '@nocobase/test';
|
||||
|
||||
describe('cluster', () => {
|
||||
it('publish', async () => {
|
||||
process.env.APP_ENV = 'production';
|
||||
const cluster = await createMockCluster({
|
||||
plugins: ['localization'],
|
||||
});
|
||||
const [app1, app2] = cluster.nodes;
|
||||
await app1.emitAsync('afterLoad');
|
||||
await app2.emitAsync('afterLoad');
|
||||
const agent1 = app1.agent();
|
||||
const repo1 = app1.db.getRepository('localizationTexts');
|
||||
await repo1.create({
|
||||
values: [
|
||||
{
|
||||
module: 'test',
|
||||
text: 'text',
|
||||
translations: [
|
||||
{
|
||||
locale: 'en-US',
|
||||
translation: 'translation',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
const { resources } = await app1.localeManager.get('en-US');
|
||||
expect(resources.test).toBeUndefined();
|
||||
const { resources: resources1 } = await app2.localeManager.get('en-US');
|
||||
expect(resources1.test).toBeUndefined();
|
||||
await agent1.resource('localization').publish();
|
||||
await sleep(1000);
|
||||
const { resources: resources2 } = await app1.localeManager.get('en-US');
|
||||
expect(resources2.test).toBeDefined();
|
||||
expect(resources2.test.text).toBe('translation');
|
||||
const { resources: resources3 } = await app2.localeManager.get('en-US');
|
||||
expect(resources3.test).toBeDefined();
|
||||
expect(resources3.test.text).toBe('translation');
|
||||
await cluster.destroy();
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user