Skip to content

Commit

Permalink
fix: attempt to fix failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf committed Feb 19, 2024
1 parent 1d55f2b commit 4c9c532
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
10 changes: 5 additions & 5 deletions test-app/src/components/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from 'react';

import { useAuth } from '@common/use-auth';
import { stacksMainnetNetwork } from '@common/utils';
import { stacksMainnetNetwork, stacksTestnetNetwork } from '@common/utils';
import { openProfileUpdateRequestPopup } from '@stacks/connect';
import { StacksNetwork } from '@stacks/network';
import { PublicPersonProfile, PublicProfile } from '@stacks/profile';
Expand Down Expand Up @@ -70,11 +70,11 @@ export const Profile = () => {
},
],
},
stacksMainnetNetwork
stacksTestnetNetwork
)
}
>
Update profile (Mainnet)
Update profile (Testnet)
</styled.button>

<styled.button
Expand All @@ -85,11 +85,11 @@ export const Profile = () => {
{
name: 1,
} as any,
stacksMainnetNetwork
stacksTestnetNetwork
)
}
>
Try to update invalid profile (Mainnet)
Try to update invalid profile (Testnet)
</styled.button>
</Flex>
</Box>
Expand Down
33 changes: 14 additions & 19 deletions tests/specs/profile/profile.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Page } from '@playwright/test';
import { TestAppPage } from '@tests/page-object-models/test-app.page';
import { UpdateProfileRequestPage } from '@tests/page-object-models/update-profile-request.page';

Expand All @@ -9,19 +8,6 @@ test.describe.configure({ mode: 'serial' });
test.describe('Profile updating', () => {
let testAppPage: TestAppPage;

function interceptGaiaRequest(page: Page): Promise<Buffer> {
return new Promise(resolve => {
page.on('request', request => {
if (request.url().startsWith('https://hub.blockstack.org/store')) {
const requestBody = request.postDataBuffer();
if (request.method() === 'GET') return;
if (requestBody === null) return;
resolve(requestBody);
}
});
});
}

test.beforeEach(async ({ extensionId, globalPage, onboardingPage, context }) => {

Check failure on line 11 in tests/specs/profile/profile.spec.ts

View workflow job for this annotation

GitHub Actions / Shard 3 of 8

[chromium] › specs/profile/profile.spec.ts:23:3 › Profile updating › should show profile details

1) [chromium] › specs/profile/profile.spec.ts:23:3 › Profile updating › should show profile details Test timeout of 30000ms exceeded while running "beforeEach" hook. 9 | let testAppPage: TestAppPage; 10 | > 11 | test.beforeEach(async ({ extensionId, globalPage, onboardingPage, context }) => { | ^ 12 | await globalPage.setupAndUseApiCalls(extensionId); 13 | await onboardingPage.signInWithTestAccount(extensionId); 14 | testAppPage = await TestAppPage.openDemoPage(context); at /home/runner/work/extension/extension/tests/specs/profile/profile.spec.ts:11:8
await globalPage.setupAndUseApiCalls(extensionId);
await onboardingPage.signInWithTestAccount(extensionId);
Expand Down Expand Up @@ -57,12 +43,21 @@ test.describe('Profile updating', () => {
await testAppPage.clickUpdateProfileButton();
const profileUpdatingPage = new UpdateProfileRequestPage(await context.waitForEvent('page'));

const [gaiaRequestBody] = await Promise.all([
interceptGaiaRequest(profileUpdatingPage.page),
profileUpdatingPage.clickUpdateProfileButton(),
]);
const requestPromise = profileUpdatingPage.page.waitForRequest('https://hub.blockstack.org/*');

await profileUpdatingPage.page.route('https://hub.blockstack.org/*', async route => {
await route.abort();
});

await profileUpdatingPage.clickUpdateProfileButton();

const request = await requestPromise;
const requestBody = request.postDataBuffer();
if (!requestBody) return;

const { decodedToken } = JSON.parse(requestBody.toString())[0];

const { decodedToken } = JSON.parse(gaiaRequestBody.toString())[0];
test.expect(decodedToken).toBeDefined();

test.expect(decodedToken?.header?.alg).toEqual('ES256K');
test.expect(decodedToken?.payload?.claim?.name).toContain('Name ');
Expand Down

0 comments on commit 4c9c532

Please sign in to comment.