Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update groups for new default language #5260

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .source
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { UserSession } from '@novu/testing';
import { expect } from 'chai';
import { OrganizationRepository } from '@novu/dal';

describe('Update default locale and add new translations - /translations/language (PATCH)', async () => {
let session: UserSession;
const organizationRepository = new OrganizationRepository();

before(async () => {
session = new UserSession();
await session.initialize();
await session.testAgent.put(`/v1/organizations/language`).send({
locale: 'en_US',
});
});

it('should update default locale and add that locale to groups', async () => {
await session.testAgent.post(`/v1/translations/groups`).send({
name: 'test',
identifier: 'test',
locales: ['en_US', 'sv_SE'],
});

await session.applyChanges({
enabled: false,
});

await session.testAgent.patch(`/v1/translations/language`).send({
locale: 'en_GB',
});

const org = await organizationRepository.findById(session.organization._id);
expect(org?.defaultLocale).to.be.equal('en_GB');

const result = await session.testAgent.get(`/v1/translations/groups/test`).send();
let group = result.body.data;

let locales = group.translations.map((t) => t.isoLanguage);

expect(locales).to.deep.equal(['en_US', 'sv_SE', 'en_GB']);

await session.applyChanges({
enabled: false,
});
await session.switchToProdEnvironment();

const data = await session.testAgent.get(`/v1/translations/groups/test`).send();
group = data.body.data;
locales = group.translations.map((t) => t.isoLanguage);
expect(locales).to.deep.equal(['en_US', 'sv_SE', 'en_GB']);
});
});
Loading