Browse Source

chore(core): Fix failing e2e tests

Michael Bromley 2 years ago
parent
commit
77f556a267

+ 2 - 2
packages/core/e2e/channel.e2e-spec.ts

@@ -321,7 +321,7 @@ describe('Channels', () => {
                     defaultLanguageCode: LanguageCode.zh,
                 },
             });
-
+            channelGuard.assertSuccess(updateChannel);
             expect(updateChannel.defaultLanguageCode).toBe(LanguageCode.zh);
         });
     });
@@ -356,7 +356,7 @@ describe('Channels', () => {
         expect(deleteChannel.result).toBe(DeletionResult.DELETED);
 
         const { channels } = await adminClient.query<Codegen.GetChannelsQuery>(GET_CHANNELS);
-        expect(channels.map(c => c.id).sort()).toEqual(['T_1']);
+        expect(channels.items.map(c => c.id).sort()).toEqual(['T_1']);
 
         const { product } = await adminClient.query<
             Codegen.GetProductWithVariantsQuery,

+ 1 - 1
packages/core/e2e/graphql/fragments.ts

@@ -237,7 +237,7 @@ export const FACET_WITH_VALUES_FRAGMENT = gql`
 `;
 
 export const COUNTRY_FRAGMENT = gql`
-    fragment Country on Country {
+    fragment Country on Region {
         id
         code
         name

+ 63 - 17
packages/core/e2e/graphql/generated-e2e-admin-types.ts

@@ -7955,7 +7955,7 @@ export type FacetWithValuesFragment = {
     }>;
 };
 
-export type CountryFragment = {
+type Country_Country_Fragment = {
     id: string;
     code: string;
     name: string;
@@ -7963,6 +7963,16 @@ export type CountryFragment = {
     translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
 };
 
+type Country_Province_Fragment = {
+    id: string;
+    code: string;
+    name: string;
+    enabled: boolean;
+    translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+};
+
+export type CountryFragment = Country_Country_Fragment | Country_Province_Fragment;
+
 export type AddressFragment = {
     id: string;
     fullName?: string | null;
@@ -8140,7 +8150,13 @@ export type ZoneFragment = {
               enabled: boolean;
               translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
           }
-        | {}
+        | {
+              id: string;
+              code: string;
+              name: string;
+              enabled: boolean;
+              translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+          }
     >;
 };
 
@@ -11611,7 +11627,13 @@ export type GetZoneQuery = {
                   enabled: boolean;
                   translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
               }
-            | {}
+            | {
+                  id: string;
+                  code: string;
+                  name: string;
+                  enabled: boolean;
+                  translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+              }
         >;
     } | null;
 };
@@ -11641,7 +11663,13 @@ export type CreateZoneMutation = {
                   enabled: boolean;
                   translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
               }
-            | {}
+            | {
+                  id: string;
+                  code: string;
+                  name: string;
+                  enabled: boolean;
+                  translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+              }
         >;
     };
 };
@@ -11662,7 +11690,13 @@ export type UpdateZoneMutation = {
                   enabled: boolean;
                   translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
               }
-            | {}
+            | {
+                  id: string;
+                  code: string;
+                  name: string;
+                  enabled: boolean;
+                  translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+              }
         >;
     };
 };
@@ -11684,7 +11718,13 @@ export type AddMembersToZoneMutation = {
                   enabled: boolean;
                   translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
               }
-            | {}
+            | {
+                  id: string;
+                  code: string;
+                  name: string;
+                  enabled: boolean;
+                  translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+              }
         >;
     };
 };
@@ -11706,7 +11746,13 @@ export type RemoveMembersFromZoneMutation = {
                   enabled: boolean;
                   translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
               }
-            | {}
+            | {
+                  id: string;
+                  code: string;
+                  name: string;
+                  enabled: boolean;
+                  translations: Array<{ id: string; languageCode: LanguageCode; name: string }>;
+              }
         >;
     };
 };
@@ -13191,7 +13237,7 @@ export const CountryFragmentDoc = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -13244,7 +13290,7 @@ export const ZoneFragmentDoc = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -17079,7 +17125,7 @@ export const GetCountryDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -17147,7 +17193,7 @@ export const CreateCountryDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -24881,7 +24927,7 @@ export const UpdateCountryDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -36991,7 +37037,7 @@ export const GetZoneDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -37130,7 +37176,7 @@ export const CreateZoneDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -37218,7 +37264,7 @@ export const UpdateZoneDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -37325,7 +37371,7 @@ export const AddMembersToZoneDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [
@@ -37432,7 +37478,7 @@ export const RemoveMembersFromZoneDocument = {
         {
             kind: 'FragmentDefinition',
             name: { kind: 'Name', value: 'Country' },
-            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Country' } },
+            typeCondition: { kind: 'NamedType', name: { kind: 'Name', value: 'Region' } },
             selectionSet: {
                 kind: 'SelectionSet',
                 selections: [

+ 2 - 2
packages/core/e2e/role.e2e-spec.ts

@@ -457,8 +457,8 @@ describe('Role resolver', () => {
 
         beforeAll(async () => {
             const { channels } = await adminClient.query<Codegen.GetChannelsQuery>(GET_CHANNELS);
-            defaultChannel = channels.find(c => c.token === E2E_DEFAULT_CHANNEL_TOKEN)!;
-            secondChannel = channels.find(c => c.token !== E2E_DEFAULT_CHANNEL_TOKEN)!;
+            defaultChannel = channels.items.find(c => c.token === E2E_DEFAULT_CHANNEL_TOKEN)!;
+            secondChannel = channels.items.find(c => c.token !== E2E_DEFAULT_CHANNEL_TOKEN)!;
             adminClient.setChannelToken(E2E_DEFAULT_CHANNEL_TOKEN);
             await adminClient.asSuperAdmin();
             const { createRole } = await adminClient.query<

+ 3 - 3
packages/core/e2e/tax-category.e2e-spec.ts

@@ -31,7 +31,7 @@ describe('TaxCategory resolver', () => {
             GET_TAX_CATEGORY_LIST,
         );
 
-        expect(taxCategories.sort(sortById)).toEqual([
+        expect(taxCategories.items.sort(sortById)).toEqual([
             { id: 'T_1', name: 'Standard Tax', isDefault: false },
             { id: 'T_2', name: 'Reduced Tax', isDefault: false },
             { id: 'T_3', name: 'Zero Tax', isDefault: false },
@@ -108,7 +108,7 @@ describe('TaxCategory resolver', () => {
         const { taxCategories } = await adminClient.query<Codegen.GetTaxCategoryListQuery>(
             GET_TAX_CATEGORY_LIST,
         );
-        expect(taxCategories.sort(sortById)).toEqual([
+        expect(taxCategories.items.sort(sortById)).toEqual([
             { id: 'T_1', name: 'Standard Tax', isDefault: false },
             { id: 'T_2', name: 'Reduced Tax', isDefault: true },
             { id: 'T_3', name: 'Zero Tax', isDefault: false },
@@ -136,7 +136,7 @@ describe('TaxCategory resolver', () => {
         const { taxCategories } = await adminClient.query<Codegen.GetTaxCategoryListQuery>(
             GET_TAX_CATEGORY_LIST,
         );
-        expect(taxCategories.sort(sortById)).toEqual([
+        expect(taxCategories.items.sort(sortById)).toEqual([
             { id: 'T_1', name: 'Standard Tax', isDefault: true },
             { id: 'T_2', name: 'Reduced Tax', isDefault: false },
             { id: 'T_3', name: 'Zero Tax', isDefault: false },

+ 6 - 6
packages/core/e2e/zone.e2e-spec.ts

@@ -38,8 +38,8 @@ describe('Zone resolver', () => {
 
     it('zones', async () => {
         const result = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
-        expect(result.zones.length).toBe(5);
-        zones = result.zones;
+        expect(result.zones.items.length).toBe(5);
+        zones = result.zones.items;
         oceania = zones[0];
     });
 
@@ -134,7 +134,7 @@ describe('Zone resolver', () => {
             });
 
             const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
-            expect(result2.zones.find(c => c.id === pangaea.id)).toBeUndefined();
+            expect(result2.zones.items.find(c => c.id === pangaea.id)).toBeUndefined();
         });
 
         it('does not delete Zone that is used in one or more TaxRates', async () => {
@@ -153,7 +153,7 @@ describe('Zone resolver', () => {
             });
 
             const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
-            expect(result2.zones.find(c => c.id === oceania.id)).not.toBeUndefined();
+            expect(result2.zones.items.find(c => c.id === oceania.id)).not.toBeUndefined();
         });
 
         it('does not delete Zone that is used as a Channel defaultTaxZone', async () => {
@@ -182,7 +182,7 @@ describe('Zone resolver', () => {
             });
 
             const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
-            expect(result2.zones.find(c => c.id === oceania.id)).not.toBeUndefined();
+            expect(result2.zones.items.find(c => c.id === oceania.id)).not.toBeUndefined();
         });
 
         it('does not delete Zone that is used as a Channel defaultShippingZone', async () => {
@@ -212,7 +212,7 @@ describe('Zone resolver', () => {
             });
 
             const result2 = await adminClient.query<Codegen.GetZonesQuery>(GET_ZONE_LIST);
-            expect(result2.zones.find(c => c.id === oceania.id)).not.toBeUndefined();
+            expect(result2.zones.items.find(c => c.id === oceania.id)).not.toBeUndefined();
         });
     });
 });