Skip to content

Commit

Permalink
fix(core): Fix updating channel currencyCode
Browse files Browse the repository at this point in the history
Fixes #2114
  • Loading branch information
michaelbromley committed Apr 6, 2023
1 parent c75296f commit 7e01ecf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
19 changes: 16 additions & 3 deletions packages/core/e2e/channel.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@ import path from 'path';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';

import { initialData } from '../../../e2e-common/e2e-initial-data';
import { testConfig, TEST_SETUP_TIMEOUT_MS } from '../../../e2e-common/test-config';
import { TEST_SETUP_TIMEOUT_MS, testConfig } from '../../../e2e-common/test-config';

import * as Codegen from './graphql/generated-e2e-admin-types';
import {
ChannelFragment,
CurrencyCode,
DeletionResult,
ErrorCode,
LanguageCode,
Permission,
} from './graphql/generated-e2e-admin-types';
import * as Codegen from './graphql/generated-e2e-admin-types';
import {
ASSIGN_PRODUCT_TO_CHANNEL,
CREATE_ADMINISTRATOR,
Expand Down Expand Up @@ -123,6 +122,20 @@ describe('Channels', () => {
});
});

it('update currencyCode', async () => {
const { updateChannel } = await adminClient.query<
Codegen.UpdateChannelMutation,
Codegen.UpdateChannelMutationVariables
>(UPDATE_CHANNEL, {
input: {
id: 'T_1',
currencyCode: CurrencyCode.MYR,
},
});
channelGuard.assertSuccess(updateChannel);
expect(updateChannel.currencyCode).toBe('MYR');
});

it('superadmin has all permissions on new channel', async () => {
const { me } = await adminClient.query<Codegen.MeQuery>(ME);

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/service/services/channel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,9 @@ export class ChannelService {
const seller = await this.connection.getEntityOrThrow(ctx, Seller, input.sellerId);
updatedChannel.seller = seller;
}
if (input.currencyCode) {
updatedChannel.defaultCurrencyCode = input.currencyCode;
}
await this.connection.getRepository(ctx, Channel).save(updatedChannel, { reload: false });
await this.customFieldRelationService.updateRelations(ctx, Channel, input, updatedChannel);
await this.allChannels.refresh(ctx);
Expand Down

0 comments on commit 7e01ecf

Please sign in to comment.