-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: gaia profile test #5073
fix: gaia profile test #5073
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
export const mockGaiaProfileResponse = [ | ||
{ | ||
token: | ||
'eyJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NksifQ.eyJqdGkiOiIwYTFkNGVhZC01YmQyLTQzYWYtYmQ5YS0wMWRiNTcxZTA0NmUiLCJpYXQiOiIyMDI0LTAzLTEzVDE4OjI5OjQxLjI1N1oiLCJleHAiOiIyMDI1LTAzLTEzVDE4OjI5OjQxLjI1N1oiLCJzdWJqZWN0Ijp7InB1YmxpY0tleSI6IjAzMjliMDc2YmMyMGY3YjE1OTJiMmExYTVjYjkxZGZlZmU4Yzk2NmU1MGUyNTY0NThlMjNkZDJjNWQ2M2Y4ZjFhZiJ9LCJpc3N1ZXIiOnsicHVibGljS2V5IjoiMDMyOWIwNzZiYzIwZjdiMTU5MmIyYTFhNWNiOTFkZmVmZThjOTY2ZTUwZTI1NjQ1OGUyM2RkMmM1ZDYzZjhmMWFmIn0sImNsYWltIjp7IkB0eXBlIjoiUGVyc29uIiwiQGNvbnRleHQiOiJodHRwOi8vc2NoZW1hLm9yZyIsImFwcHMiOnsiaHR0cDovL2xvY2FsaG9zdDozMDAwIjoiaHR0cHM6Ly9nYWlhLmhpcm8uc28vaHViLzFKdmkxTmlZSGFNdmpVZFRhbTRITHJQU2RVakg1TXFONUYvIn0sImFwcHNNZXRhIjp7Imh0dHA6Ly9sb2NhbGhvc3Q6MzAwMCI6eyJzdG9yYWdlIjoiaHR0cHM6Ly9nYWlhLmhpcm8uc28vaHViLzFKdmkxTmlZSG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| ||
}, | ||
payload: { | ||
jti: '0a1d4ead-5bd2-43af-bd9a-01db571e046e', | ||
iat: '2024-03-13T18:29:41.257Z', | ||
exp: '2025-03-13T18:29:41.257Z', | ||
subject: { | ||
publicKey: '0329b076bc20f7b1592b2a1a5cb91dfefe8c966e50e256458e23dd2c5d63f8f1af', | ||
}, | ||
issuer: { | ||
publicKey: '0329b076bc20f7b1592b2a1a5cb91dfefe8c966e50e256458e23dd2c5d63f8f1af', | ||
}, | ||
claim: { | ||
'@type': 'Person', | ||
'@context': 'http://schema.org', | ||
apps: { | ||
'http://localhost:3000': 'https://gaia.hiro.so/hub/1Jvi1NiYHaMvjUdTam4HLrPSdUjH5MqN5F/', | ||
}, | ||
appsMeta: { | ||
'http://localhost:3000': { | ||
storage: 'https://gaia.hiro.so/hub/1Jvi1NiYHaMvjUdTam4HLrPSdUjH5MqN5F/', | ||
publicKey: '03d4d6806c776051ac42bf8385fbcb6da84ec7169194d6e8d6e1bc74ecb9bc40ce', | ||
}, | ||
}, | ||
name: 'Name 1710351212509', | ||
image: [ | ||
{ | ||
'@type': 'ImageObject', | ||
name: 'avatar', | ||
contentUrl: | ||
'https://byzantion.mypinata.cloud/ipfs/Qmb84UcaMr1MUwNbYBnXWHM3kEaDcYrKuPWwyRLVTNKELC/2256.png', | ||
}, | ||
{ | ||
'@type': 'ImageObject', | ||
name: 'background', | ||
contentUrl: | ||
'https://unsplash.com/photos/h0Vxgz5tyXA/download?ixid=MnwxMjA3fDB8MXxzZWFyY2h8Mnx8YmFja2dyb3VuZHxlbnwwfDB8fHwxNjY2NDA0Nzkx&force=true&w=640', | ||
}, | ||
], | ||
sameAs: ['https://twitter.com/twitterHandle', 'https://instagram.com/instaHandle'], | ||
owns: [ | ||
{ | ||
'@type': 'OwnershipInfo', | ||
identifier: | ||
'bip122:000000000019d6689c085ae165831e93:12cbQLTFMXRnSzktFkuoG3eHoMeFtpTu3S', | ||
}, | ||
], | ||
}, | ||
}, | ||
signature: | ||
'I0qDc2l6iZrRVXAc7GLPxngmRloZfCukugj3GuFHyZHxJtsy3oIs3sroQcXGzkLlxAI35HAra4BH0uO5hMpWeA', | ||
}, | ||
}, | ||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { mockGaiaProfileResponse } from '@tests/mocks/mock-profile'; | ||
import { TestAppPage } from '@tests/page-object-models/test-app.page'; | ||
import { UpdateProfileRequestPage } from '@tests/page-object-models/update-profile-request.page'; | ||
|
||
|
@@ -8,28 +9,22 @@ | |
test.describe('Profile updating', () => { | ||
let testAppPage: TestAppPage; | ||
|
||
test.beforeEach(async ({ extensionId, globalPage, onboardingPage, context }) => { | ||
Check failure on line 12 in tests/specs/profile/profile.spec.ts GitHub Actions / Shard 3 of 8[chromium] βΊ specs/profile/profile.spec.ts:19:3 βΊ Profile updating βΊ should show an error for invalid profile
|
||
await globalPage.setupAndUseApiCalls(extensionId); | ||
await onboardingPage.signInWithTestAccount(extensionId); | ||
testAppPage = await TestAppPage.openDemoPage(context); | ||
await testAppPage.signIn(); | ||
}); | ||
|
||
test('should show an error for invalid profile', async ({ context }) => { | ||
const accountsPage = await context.waitForEvent('page'); | ||
await accountsPage.locator('text="Account 1"').click({ force: true }); | ||
await testAppPage.page.bringToFront(); | ||
await testAppPage.page.click('text=Profile'); | ||
await testAppPage.page.click('text=Profile', { | ||
timeout: 30000, | ||
}); | ||
await accountsPage.close(); | ||
}); | ||
|
||
test('should show profile details', async ({ context }) => { | ||
await testAppPage.clickUpdateProfileButton(); | ||
const profileUpdatingPage = new UpdateProfileRequestPage(await context.waitForEvent('page')); | ||
const name = profileUpdatingPage.page.getByText('twitter'); | ||
const nameText = await name.innerText(); | ||
test.expect(nameText).toBe('https://twitter.com/twitterHandle'); | ||
await profileUpdatingPage.page.close(); | ||
}); | ||
|
||
test('should show an error for invalid profile', async ({ context }) => { | ||
await testAppPage.clickUpdateInvalidProfileButton(); | ||
const profileUpdatingPage = new UpdateProfileRequestPage(await context.waitForEvent('page')); | ||
const error = await profileUpdatingPage.waitForUpdateProfileRequestError( | ||
|
@@ -41,40 +36,52 @@ | |
}); | ||
}); | ||
|
||
// Skipping this for now to see if shard 3 passes | ||
test.describe('Gaia request', () => { | ||
test.describe('Gaia profile request', () => { | ||
let testAppPage: TestAppPage; | ||
|
||
test.beforeEach(async ({ extensionId, globalPage, onboardingPage, context }) => { | ||
await globalPage.setupAndUseApiCalls(extensionId); | ||
await onboardingPage.signInWithTestAccount(extensionId); | ||
testAppPage = await TestAppPage.openDemoPage(context); | ||
await testAppPage.signIn(); | ||
}); | ||
|
||
test('should send a signed profile token to gaia', async ({ context }) => { | ||
const accountsPage = await context.waitForEvent('page'); | ||
await accountsPage.locator('text="Account 2"').click({ force: true }); | ||
await testAppPage.page.bringToFront(); | ||
await testAppPage.page.click('text=Profile'); | ||
await accountsPage.close(); | ||
}); | ||
await testAppPage.page.click('text=Profile', { | ||
timeout: 30000, | ||
}); | ||
|
||
test.skip('should send a signed profile token to gaia', async ({ context }) => { | ||
await testAppPage.clickUpdateProfileButton(); | ||
const profileUpdatingPage = new UpdateProfileRequestPage(await context.waitForEvent('page')); | ||
|
||
const requestPromise = profileUpdatingPage.page.waitForRequest('https://hub.blockstack.org/*'); | ||
|
||
await profileUpdatingPage.page.route('https://gaia.hiro.so/hub/*', async route => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we can use this approach to add some mocks for Ordinals so we can test the send BRC20 / ordinal flow? I need to do that soon as it suprised me again on containers. I have this task for a while |
||
await route.fulfill({ | ||
status: 200, | ||
contentType: 'application/octet-stream', | ||
body: JSON.stringify(mockGaiaProfileResponse), | ||
}); | ||
}); | ||
|
||
await profileUpdatingPage.page.route('https://hub.blockstack.org/*', async route => { | ||
await route.abort(); | ||
}); | ||
|
||
const name = profileUpdatingPage.page.getByText('twitter'); | ||
const nameText = await name.innerText(); | ||
test.expect(nameText).toBe('https://twitter.com/twitterHandle'); | ||
|
||
await profileUpdatingPage.clickUpdateProfileButton(); | ||
|
||
const request = await requestPromise; | ||
const requestBody = request.postDataBuffer(); | ||
if (!requestBody) return; | ||
|
||
const { decodedToken } = JSON.parse(requestBody.toString())[0]; | ||
|
||
test.expect(decodedToken).toBeDefined(); | ||
|
||
test.expect(decodedToken?.header?.alg).toEqual('ES256K'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this trigger at all? I half-looked into this and couldn't get this to log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did see the log when using
--ui
flag running tests in UI mode.