Skip to content

Commit 9182d84

Browse files
committed
Remove typeVersion from tests - verify versions by line structure instead
- Remove sed command that added typeVersion to GraphQL queries - Tests now verify version differences by checking line structure - Version 1 has 2 lines, version 2 has 3 lines (including fee-line) - This tests what Fragment CLI actually generates, not modified output
1 parent 0ed7103 commit 9182d84

4 files changed

Lines changed: 14 additions & 19 deletions

File tree

‎scripts/update-test-schema.sh‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ fragment gen-graphql \
99
--path tests/fixtures/test-schema.json \
1010
--output tests/fixtures/test-schema-queries.graphql
1111

12-
echo "Adding typeVersion to GraphQL query response fields..."
13-
# Fragment CLI doesn't include typeVersion in response by default, so we add it
14-
sed -i.bak 's/ type$/ type\n typeVersion/g' tests/fixtures/test-schema-queries.graphql
15-
rm tests/fixtures/test-schema-queries.graphql.bak
16-
1712
echo "Generating SDK from GraphQL queries..."
1813
yarn fragment-node-client-codegen \
1914
-i tests/fixtures/test-schema-queries.graphql \

‎tests/fixtures/generated-test-client.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3092,7 +3092,7 @@ export type PostUserFundsAccountMutationVariables = Exact<{
30923092
}>;
30933093

30943094

3095-
export type PostUserFundsAccountMutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, typeVersion?: number | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
3095+
export type PostUserFundsAccountMutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
30963096

30973097
export type PostUserFundsAccount_V2MutationVariables = Exact<{
30983098
ik: Scalars['SafeString']['input'];
@@ -3103,7 +3103,7 @@ export type PostUserFundsAccount_V2MutationVariables = Exact<{
31033103
}>;
31043104

31053105

3106-
export type PostUserFundsAccount_V2Mutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, typeVersion?: number | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
3106+
export type PostUserFundsAccount_V2Mutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
31073107

31083108
export type PostFundingSettlementMutationVariables = Exact<{
31093109
ik: Scalars['SafeString']['input'];
@@ -3113,7 +3113,7 @@ export type PostFundingSettlementMutationVariables = Exact<{
31133113
}>;
31143114

31153115

3116-
export type PostFundingSettlementMutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, typeVersion?: number | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
3116+
export type PostFundingSettlementMutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
31173117

31183118
export type PostPaymentProcessingMutationVariables = Exact<{
31193119
ik: Scalars['SafeString']['input'];
@@ -3123,7 +3123,7 @@ export type PostPaymentProcessingMutationVariables = Exact<{
31233123
}>;
31243124

31253125

3126-
export type PostPaymentProcessingMutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, typeVersion?: number | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
3126+
export type PostPaymentProcessingMutation = { __typename?: 'Mutation', addLedgerEntry: { __typename: 'AddLedgerEntryResult', isIkReplay: boolean, entry: { __typename?: 'LedgerEntry', ik: string, id: string, created: string, type?: string | null, posted: string, description?: string | null, ledger: { __typename?: 'Ledger', ik: string }, tags: Array<{ __typename?: 'LedgerEntryTag', key: string, value: string }>, groups: Array<{ __typename?: 'LedgerEntryGroup', key: string, value: string }> }, lines: Array<{ __typename?: 'LedgerLine', amount: string, key?: string | null, account: { __typename?: 'LedgerAccount', path: string }, currency?: { __typename?: 'Currency', code: CurrencyCode, customCurrencyId?: string | null } | null }> } | { __typename: 'BadRequestError', code: string, message: string, retryable: boolean } | { __typename: 'InternalError', code: string, message: string, retryable: boolean } };
31273127

31283128

31293129
export const PostUserFundsAccountDocument = gql`
@@ -3139,7 +3139,6 @@ export const PostUserFundsAccountDocument = gql`
31393139
id
31403140
created
31413141
type
3142-
typeVersion
31433142
posted
31443143
description
31453144
ledger {
@@ -3193,7 +3192,6 @@ export const PostUserFundsAccount_V2Document = gql`
31933192
id
31943193
created
31953194
type
3196-
typeVersion
31973195
posted
31983196
description
31993197
ledger {
@@ -3247,7 +3245,6 @@ export const PostFundingSettlementDocument = gql`
32473245
id
32483246
created
32493247
type
3250-
typeVersion
32513248
posted
32523249
description
32533250
ledger {
@@ -3301,7 +3298,6 @@ export const PostPaymentProcessingDocument = gql`
33013298
id
33023299
created
33033300
type
3304-
typeVersion
33053301
posted
33063302
description
33073303
ledger {

‎tests/fixtures/test-schema-queries.graphql‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mutation PostUserFundsAccount($ik: SafeString!, $posted: DateTime, $ledgerIk: Sa
1010
id
1111
created
1212
type
13-
typeVersion
1413
posted
1514
description
1615
ledger {
@@ -62,7 +61,6 @@ mutation PostUserFundsAccount_v2($ik: SafeString!, $posted: DateTime, $ledgerIk:
6261
id
6362
created
6463
type
65-
typeVersion
6664
posted
6765
description
6866
ledger {
@@ -114,7 +112,6 @@ mutation PostFundingSettlement($ik: SafeString!, $posted: DateTime, $ledgerIk: S
114112
id
115113
created
116114
type
117-
typeVersion
118115
posted
119116
description
120117
ledger {
@@ -166,7 +163,6 @@ mutation PostPaymentProcessing($ik: SafeString!, $posted: DateTime, $ledgerIk: S
166163
id
167164
created
168165
type
169-
typeVersion
170166
posted
171167
description
172168
ledger {

‎tests/generated-sdk.test.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ test("PostUserFundsAccount method from generated SDK (version 1 and 2)", async (
161161
expect(result1.addLedgerEntry.__typename).toEqual("AddLedgerEntryResult");
162162
if (result1.addLedgerEntry.__typename === "AddLedgerEntryResult") {
163163
expect(result1.addLedgerEntry.entry.type).toEqual("user-funds-account");
164-
expect(result1.addLedgerEntry.entry.typeVersion).toEqual(1);
164+
// Version 1 has 2 lines (asset-line and liability-line)
165+
expect(result1.addLedgerEntry.lines).toHaveLength(2);
165166
}
166167

167168
// Use the generated PostUserFundsAccount_v2 method for version 2 (with feeAmount)
@@ -176,7 +177,14 @@ test("PostUserFundsAccount method from generated SDK (version 1 and 2)", async (
176177
expect(result2.addLedgerEntry.__typename).toEqual("AddLedgerEntryResult");
177178
if (result2.addLedgerEntry.__typename === "AddLedgerEntryResult") {
178179
expect(result2.addLedgerEntry.entry.type).toEqual("user-funds-account");
179-
expect(result2.addLedgerEntry.entry.typeVersion).toEqual(2);
180+
// Version 2 has 3 lines (asset-line, liability-line, and fee-line)
181+
expect(result2.addLedgerEntry.lines).toHaveLength(3);
182+
// Verify fee-line exists
183+
const feeLine = result2.addLedgerEntry.lines.find(
184+
(line) => line.key === "fee-line"
185+
);
186+
expect(feeLine).toBeDefined();
187+
expect(feeLine?.amount).toEqual("10");
180188
}
181189

182190
// Verify both entries exist

0 commit comments

Comments
 (0)