|
|
@@ -22,6 +22,8 @@ import {
|
|
|
Me,
|
|
|
Permission,
|
|
|
RemoveProductsFromChannel,
|
|
|
+ UpdateChannel,
|
|
|
+ UpdateGlobalSettings,
|
|
|
} from './graphql/generated-e2e-admin-types';
|
|
|
import {
|
|
|
ASSIGN_PRODUCT_TO_CHANNEL,
|
|
|
@@ -100,8 +102,8 @@ describe('Channels', () => {
|
|
|
|
|
|
expect(me!.channels.length).toBe(2);
|
|
|
|
|
|
- const secondChannelData = me!.channels.find(c => c.token === SECOND_CHANNEL_TOKEN);
|
|
|
- const nonOwnerPermissions = Object.values(Permission).filter(p => p !== Permission.Owner);
|
|
|
+ const secondChannelData = me!.channels.find((c) => c.token === SECOND_CHANNEL_TOKEN);
|
|
|
+ const nonOwnerPermissions = Object.values(Permission).filter((p) => p !== Permission.Owner);
|
|
|
expect(secondChannelData!.permissions).toEqual(nonOwnerPermissions);
|
|
|
});
|
|
|
|
|
|
@@ -111,7 +113,7 @@ describe('Channels', () => {
|
|
|
|
|
|
expect(me!.channels.length).toBe(2);
|
|
|
|
|
|
- const secondChannelData = me!.channels.find(c => c.token === SECOND_CHANNEL_TOKEN);
|
|
|
+ const secondChannelData = me!.channels.find((c) => c.token === SECOND_CHANNEL_TOKEN);
|
|
|
expect(me!.channels).toEqual([
|
|
|
{
|
|
|
code: DEFAULT_CHANNEL_CODE,
|
|
|
@@ -170,7 +172,7 @@ describe('Channels', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- expect(createAdministrator.user.roles.map(r => r.description)).toEqual(['second channel admin']);
|
|
|
+ expect(createAdministrator.user.roles.map((r) => r.description)).toEqual(['second channel admin']);
|
|
|
});
|
|
|
|
|
|
it(
|
|
|
@@ -288,7 +290,7 @@ describe('Channels', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- expect(assignProductsToChannel[0].channels.map(c => c.id).sort()).toEqual(['T_1', 'T_2']);
|
|
|
+ expect(assignProductsToChannel[0].channels.map((c) => c.id).sort()).toEqual(['T_1', 'T_2']);
|
|
|
await adminClient.setChannelToken(SECOND_CHANNEL_TOKEN);
|
|
|
const { product } = await adminClient.query<
|
|
|
GetProductWithVariants.Query,
|
|
|
@@ -297,12 +299,12 @@ describe('Channels', () => {
|
|
|
id: product1.id,
|
|
|
});
|
|
|
|
|
|
- expect(product!.variants.map(v => v.price)).toEqual(
|
|
|
- product1.variants.map(v => v.price * PRICE_FACTOR),
|
|
|
+ expect(product!.variants.map((v) => v.price)).toEqual(
|
|
|
+ product1.variants.map((v) => v.price * PRICE_FACTOR),
|
|
|
);
|
|
|
// Second Channel is configured to include taxes in price, so they should be the same.
|
|
|
- expect(product!.variants.map(v => v.priceWithTax)).toEqual(
|
|
|
- product1.variants.map(v => v.price * PRICE_FACTOR),
|
|
|
+ expect(product!.variants.map((v) => v.priceWithTax)).toEqual(
|
|
|
+ product1.variants.map((v) => v.price * PRICE_FACTOR),
|
|
|
);
|
|
|
});
|
|
|
|
|
|
@@ -317,7 +319,7 @@ describe('Channels', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- expect(assignProductsToChannel[0].channels.map(c => c.id).sort()).toEqual(['T_1', 'T_2']);
|
|
|
+ expect(assignProductsToChannel[0].channels.map((c) => c.id).sort()).toEqual(['T_1', 'T_2']);
|
|
|
});
|
|
|
|
|
|
it(
|
|
|
@@ -348,7 +350,44 @@ describe('Channels', () => {
|
|
|
},
|
|
|
});
|
|
|
|
|
|
- expect(removeProductsFromChannel[0].channels.map(c => c.id)).toEqual(['T_1']);
|
|
|
+ expect(removeProductsFromChannel[0].channels.map((c) => c.id)).toEqual(['T_1']);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ describe('setting defaultLanguage', () => {
|
|
|
+ it(
|
|
|
+ 'throws if languageCode not in availableLanguages',
|
|
|
+ assertThrowsWithMessage(async () => {
|
|
|
+ await adminClient.query<UpdateChannel.Mutation, UpdateChannel.Variables>(UPDATE_CHANNEL, {
|
|
|
+ input: {
|
|
|
+ id: 'T_1',
|
|
|
+ defaultLanguageCode: LanguageCode.zh,
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }, 'Language "zh" is not available. First enable it via GlobalSettings and try again.'),
|
|
|
+ );
|
|
|
+
|
|
|
+ it('allows setting to an available language', async () => {
|
|
|
+ await adminClient.query<UpdateGlobalSettings.Mutation, UpdateGlobalSettings.Variables>(
|
|
|
+ UPDATE_GLOBAL_SETTINGS,
|
|
|
+ {
|
|
|
+ input: {
|
|
|
+ availableLanguages: [LanguageCode.en, LanguageCode.zh],
|
|
|
+ },
|
|
|
+ },
|
|
|
+ );
|
|
|
+
|
|
|
+ const { updateChannel } = await adminClient.query<
|
|
|
+ UpdateChannel.Mutation,
|
|
|
+ UpdateChannel.Variables
|
|
|
+ >(UPDATE_CHANNEL, {
|
|
|
+ input: {
|
|
|
+ id: 'T_1',
|
|
|
+ defaultLanguageCode: LanguageCode.zh,
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ expect(updateChannel.defaultLanguageCode).toBe(LanguageCode.zh);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -364,7 +403,7 @@ describe('Channels', () => {
|
|
|
productIds: [PROD_ID],
|
|
|
},
|
|
|
});
|
|
|
- expect(assignProductsToChannel[0].channels.map(c => c.id).sort()).toEqual(['T_1', 'T_2']);
|
|
|
+ expect(assignProductsToChannel[0].channels.map((c) => c.id).sort()).toEqual(['T_1', 'T_2']);
|
|
|
|
|
|
const { deleteChannel } = await adminClient.query<DeleteChannel.Mutation, DeleteChannel.Variables>(
|
|
|
DELETE_CHANNEL,
|
|
|
@@ -376,7 +415,7 @@ describe('Channels', () => {
|
|
|
expect(deleteChannel.result).toBe(DeletionResult.DELETED);
|
|
|
|
|
|
const { channels } = await adminClient.query<GetChannels.Query>(GET_CHANNELS);
|
|
|
- expect(channels.map(c => c.id).sort()).toEqual(['T_1', 'T_3']);
|
|
|
+ expect(channels.map((c) => c.id).sort()).toEqual(['T_1', 'T_3']);
|
|
|
|
|
|
const { product } = await adminClient.query<
|
|
|
GetProductWithVariants.Query,
|
|
|
@@ -384,7 +423,7 @@ describe('Channels', () => {
|
|
|
>(GET_PRODUCT_WITH_VARIANTS, {
|
|
|
id: PROD_ID,
|
|
|
});
|
|
|
- expect(product!.channels.map(c => c.id)).toEqual(['T_1']);
|
|
|
+ expect(product!.channels.map((c) => c.id)).toEqual(['T_1']);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -398,6 +437,17 @@ const GET_CHANNELS = gql`
|
|
|
}
|
|
|
`;
|
|
|
|
|
|
+const UPDATE_CHANNEL = gql`
|
|
|
+ mutation UpdateChannel($input: UpdateChannelInput!) {
|
|
|
+ updateChannel(input: $input) {
|
|
|
+ id
|
|
|
+ code
|
|
|
+ defaultLanguageCode
|
|
|
+ currencyCode
|
|
|
+ }
|
|
|
+ }
|
|
|
+`;
|
|
|
+
|
|
|
const DELETE_CHANNEL = gql`
|
|
|
mutation DeleteChannel($id: ID!) {
|
|
|
deleteChannel(id: $id) {
|
|
|
@@ -406,3 +456,12 @@ const DELETE_CHANNEL = gql`
|
|
|
}
|
|
|
}
|
|
|
`;
|
|
|
+
|
|
|
+const UPDATE_GLOBAL_SETTINGS = gql`
|
|
|
+ mutation UpdateGlobalSettings($input: UpdateGlobalSettingsInput!) {
|
|
|
+ updateGlobalSettings(input: $input) {
|
|
|
+ id
|
|
|
+ availableLanguages
|
|
|
+ }
|
|
|
+ }
|
|
|
+`;
|