Forráskód Böngészése

refactor: Ensure codegen works with new zone tests

Michael Bromley 2 hónapja
szülő
commit
fe824bd61d

+ 1 - 0
package-lock.json

@@ -5097,6 +5097,7 @@
     },
     "node_modules/@clack/prompts/node_modules/is-unicode-supported": {
       "version": "1.3.0",
+      "extraneous": true,
       "inBundle": true,
       "license": "MIT",
       "engines": {

+ 49 - 0
packages/core/e2e/graphql/generated-e2e-admin-types.ts

@@ -12800,6 +12800,12 @@ export type DeleteTaxRateMutationVariables = Exact<{
 
 export type DeleteTaxRateMutation = { deleteTaxRate: { result: DeletionResult; message?: string | null } };
 
+export type CreateFacetWithValueMutationVariables = Exact<{
+    input: CreateFacetInput;
+}>;
+
+export type CreateFacetWithValueMutation = { createFacet: { id: string; name: string } };
+
 export type DeleteZoneMutationVariables = Exact<{
     id: Scalars['ID']['input'];
 }>;
@@ -40964,6 +40970,49 @@ export const DeleteTaxRateDocument = {
         },
     ],
 } as unknown as DocumentNode<DeleteTaxRateMutation, DeleteTaxRateMutationVariables>;
+export const CreateFacetWithValueDocument = {
+    kind: 'Document',
+    definitions: [
+        {
+            kind: 'OperationDefinition',
+            operation: 'mutation',
+            name: { kind: 'Name', value: 'CreateFacetWithValue' },
+            variableDefinitions: [
+                {
+                    kind: 'VariableDefinition',
+                    variable: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
+                    type: {
+                        kind: 'NonNullType',
+                        type: { kind: 'NamedType', name: { kind: 'Name', value: 'CreateFacetInput' } },
+                    },
+                },
+            ],
+            selectionSet: {
+                kind: 'SelectionSet',
+                selections: [
+                    {
+                        kind: 'Field',
+                        name: { kind: 'Name', value: 'createFacet' },
+                        arguments: [
+                            {
+                                kind: 'Argument',
+                                name: { kind: 'Name', value: 'input' },
+                                value: { kind: 'Variable', name: { kind: 'Name', value: 'input' } },
+                            },
+                        ],
+                        selectionSet: {
+                            kind: 'SelectionSet',
+                            selections: [
+                                { kind: 'Field', name: { kind: 'Name', value: 'id' } },
+                                { kind: 'Field', name: { kind: 'Name', value: 'name' } },
+                            ],
+                        },
+                    },
+                ],
+            },
+        },
+    ],
+} as unknown as DocumentNode<CreateFacetWithValueMutation, CreateFacetWithValueMutationVariables>;
 export const DeleteZoneDocument = {
     kind: 'Document',
     definitions: [

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

@@ -11,7 +11,7 @@ import { ZONE_FRAGMENT } from './graphql/fragments';
 import * as Codegen from './graphql/generated-e2e-admin-types';
 import { DeletionResult } from './graphql/generated-e2e-admin-types';
 import { GET_COUNTRY_LIST, UPDATE_CHANNEL } from './graphql/shared-definitions';
-// import { Facet, LanguageCode } from '../src';
+
 /* eslint-disable @typescript-eslint/no-non-null-assertion */
 
 describe('Zone resolver', () => {
@@ -261,13 +261,13 @@ describe('Zone resolver', () => {
             const result = await adminClient.query<
                 CreateZoneMutationWithCF,
                 Codegen.CreateZoneMutationVariables
-            >(CREATE_ZONE_WITH_CF, { input });
+            >(gql(CREATE_ZONE_WITH_CF), { input });
 
             //  Verify the return value
             expect(result.createZone.customFields.relatedFacet.id).toBe(testFacet.id);
             //  Verify by querying it again from the database
             const result2 = await adminClient.query<GetZoneQueryWithCF, Codegen.GetZoneQueryVariables>(
-                GET_ZONE_WITH_CUSTOM_FIELDS,
+                gql(GET_ZONE_WITH_CUSTOM_FIELDS),
                 { id: result.createZone.id },
             );
             expect(result2.zone.customFields.relatedFacet.id).toBe(testFacet.id);
@@ -278,7 +278,7 @@ describe('Zone resolver', () => {
             const result = await adminClient.query<
                 UpdateZoneMutationWithCF,
                 Codegen.UpdateZoneMutationVariables
-            >(UPDATE_ZONE_WITH_CF, {
+            >(gql(UPDATE_ZONE_WITH_CF), {
                 input: {
                     id: zones[1].id,
                     customFields: {
@@ -292,7 +292,7 @@ describe('Zone resolver', () => {
 
             // Verify by querying it again from the database
             const result2 = await adminClient.query<GetZoneQueryWithCF, Codegen.GetZoneQueryVariables>(
-                GET_ZONE_WITH_CUSTOM_FIELDS,
+                gql(GET_ZONE_WITH_CUSTOM_FIELDS),
                 { id: zones[1].id },
             );
             expect(result2.zone.customFields.relatedFacet.id).toBe(testFacet.id);
@@ -330,7 +330,7 @@ const CREATE_FACET_WITH_VALUE = gql`
 `;
 
 // A new fragment to include the custom fields
-const ZONE_CUSTOM_FIELDS_FRAGMENT = gql`
+const ZONE_CUSTOM_FIELDS_FRAGMENT = `
     fragment ZoneCustomFields on Zone {
         customFields {
             relatedFacet {
@@ -341,38 +341,38 @@ const ZONE_CUSTOM_FIELDS_FRAGMENT = gql`
 `;
 
 // A new mutation to create a Zone with custom fields
-const CREATE_ZONE_WITH_CF = gql`
+const CREATE_ZONE_WITH_CF = `
     mutation CreateZoneWithCF($input: CreateZoneInput!) {
         createZone(input: $input) {
-            ...Zone
+            id
+            name
             ...ZoneCustomFields
         }
     }
-    ${ZONE_FRAGMENT}
     ${ZONE_CUSTOM_FIELDS_FRAGMENT}
 `;
 
 // A new mutation to update a Zone with custom fields
-const UPDATE_ZONE_WITH_CF = gql`
+const UPDATE_ZONE_WITH_CF = `
     mutation UpdateZoneWithCF($input: UpdateZoneInput!) {
         updateZone(input: $input) {
-            ...Zone
+            id
+            name
             ...ZoneCustomFields
         }
     }
-    ${ZONE_FRAGMENT}
     ${ZONE_CUSTOM_FIELDS_FRAGMENT}
 `;
 
 // A new query to fetch the Zone with its custom fields
-const GET_ZONE_WITH_CUSTOM_FIELDS = gql`
+const GET_ZONE_WITH_CUSTOM_FIELDS = `
     query GetZoneWithCustomFields($id: ID!) {
         zone(id: $id) {
-            ...Zone
+            id
+            name
             ...ZoneCustomFields
         }
     }
-    ${ZONE_FRAGMENT}
     ${ZONE_CUSTOM_FIELDS_FRAGMENT}
 `;
 

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 2 - 1
packages/dashboard/src/lib/graphql/graphql-env.d.ts


Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott