-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d36d021
commit cd2f52c
Showing
6 changed files
with
260 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { account } from '@lens-protocol/metadata'; | ||
import { assertOk } from '@lens-protocol/types'; | ||
import { describe, it } from 'vitest'; | ||
|
||
import { loginAsOnboardingUser, signerWallet } from '../../testing-utils'; | ||
import { handleWith } from '../viem'; | ||
import { createAccountWithUsername, fetchAccount } from './account'; | ||
import { switchAccount } from './authentication'; | ||
|
||
const walletClient = signerWallet(); | ||
const metadata = account({ | ||
name: 'John Doe', | ||
bio: 'A test account', | ||
}); | ||
const metadataUri = `data:application/json,${JSON.stringify(metadata)}`; | ||
|
||
const handler = handleWith(walletClient); | ||
|
||
describe('Given an onboarding user', () => { | ||
describe('When switching to the newly created account', () => { | ||
it('Then it should be authenticated', async () => { | ||
// Login as onboarding user | ||
const result = await loginAsOnboardingUser().andThen((sessionClient) => | ||
// Create an account with username | ||
createAccountWithUsername(sessionClient, { | ||
username: { localName: `testname${Date.now()}` }, | ||
metadataUri, | ||
}) | ||
// Sign if necessary | ||
.andThen(handler) | ||
|
||
// Wait for the transaction to be mined | ||
.andThen(sessionClient.waitForTransaction as any) | ||
|
||
// Fetch the account | ||
.andThen((txHash) => fetchAccount(sessionClient, { txHash })) | ||
|
||
// Switch to the newly created account | ||
.andThen((account) => switchAccount(sessionClient, { account: account?.address })), | ||
); | ||
|
||
console.log(result); | ||
|
||
assertOk(result); | ||
Check failure on line 44 in packages/client/src/actions/onboarding.test.ts GitHub Actions / Verify / Testsrc/actions/onboarding.test.ts > Given an onboarding user > When switching to the newly created account > Then it should be authenticated
|
||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.