Skip to content

Commit 93c14db

Browse files
authored
Fix e2e tests (#17)
* Don't expect any specific error when providing an invalid permission context (rather than empty string which fails to match) * Allow manually running e2e tests
1 parent 215c39a commit 93c14db

2 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/workflows/end-to-end-tests.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ on:
1313
NPM_CLIENT:
1414
type: string
1515
default: 'yarn'
16+
RUN_FULL_TESTS:
17+
type: boolean
18+
default: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/release/') }}
19+
workflow_dispatch:
20+
inputs:
21+
RUN_FULL_TESTS:
22+
type: boolean
23+
default: true
1624

1725
jobs:
1826
pipeline:
@@ -53,7 +61,7 @@ jobs:
5361

5462
- name: Run end-to-end tests
5563
run: |
56-
if [[ "$GITHUB_REF" == "refs/heads/main" ]] || [[ "$GITHUB_REF" =~ ^refs/heads/release/ ]]; then
64+
if [[ "${{ inputs.RUN_FULL_TESTS }}" == "true" ]]; then
5765
yarn e2etest:full
5866
else
5967
yarn e2etest:smoketest

packages/delegator-e2e/test/caveats/nativeTokenPayment.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,13 +177,13 @@ test('Bob attempts to redeem the delegation without providing a valid permission
177177
),
178178
});
179179

180-
const permissionsContext = '0x';
180+
const permissionsContext = '0x' as const;
181181

182182
await runTest_expectFailure(
183183
delegationRequiringNativeTokenPayment,
184184
permissionsContext,
185185
recipient,
186-
'', // The NativeTokenPaymentEnforcer rejects when it fails to decode the permissions context
186+
undefined, // The NativeTokenPaymentEnforcer rejects when it fails to decode the permissions context
187187
);
188188
});
189189

@@ -295,15 +295,21 @@ const runTest_expectFailure = async (
295295
delegation: Delegation,
296296
permissionsContext: Hex,
297297
recipient: Address,
298-
expectedError: string,
298+
expectedError: string | undefined,
299299
) => {
300300
const balanceBefore = await publicClient.getBalance({
301301
address: recipient,
302302
});
303303

304-
await expect(
304+
const rejects = expect(
305305
submitUserOpForTest(delegation, permissionsContext),
306-
).rejects.toThrow(expectedError);
306+
).rejects;
307+
308+
if (expectedError) {
309+
await rejects.toThrow(expectedError);
310+
} else {
311+
await rejects.toThrow();
312+
}
307313

308314
const balanceAfter = await publicClient.getBalance({
309315
address: recipient,

0 commit comments

Comments
 (0)