-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Just use the first picture every time * Add missing testIDs * Various test fixes * Use simplified link fetcher for e2e * Disable tests for now-n * Update test-env creation
- Loading branch information
Showing
10 changed files
with
101 additions
and
19 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
File renamed without changes.
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 |
---|---|---|
|
@@ -72,6 +72,7 @@ export async function createServer( | |
const phoneParams = phoneRequired | ||
? { | ||
phoneVerificationRequired: true, | ||
phoneVerificationProvider: 'twilio', | ||
twilioAccountSid: 'ACXXXXXXX', | ||
twilioAuthToken: 'AUTH', | ||
twilioServiceSid: 'VAXXXXXXXX', | ||
|
@@ -95,6 +96,35 @@ export async function createServer( | |
}) | ||
mockTwilio(testNet.pds) | ||
|
||
// add the test mod authority | ||
if (!phoneRequired) { | ||
const agent = new BskyAgent({service: pdsUrl}) | ||
const res = await agent.api.com.atproto.server.createAccount({ | ||
email: '[email protected]', | ||
handle: 'mod-authority.test', | ||
password: 'hunter2', | ||
}) | ||
agent.api.setHeader('Authorization', `Bearer ${res.data.accessJwt}`) | ||
await agent.api.app.bsky.actor.profile.create( | ||
{repo: res.data.did}, | ||
{ | ||
displayName: 'Dev-env Moderation', | ||
description: `The pretend version of mod.bsky.app`, | ||
}, | ||
) | ||
|
||
await agent.api.app.bsky.labeler.service.create( | ||
{repo: res.data.did, rkey: 'self'}, | ||
{ | ||
policies: { | ||
labelValues: ['!hide', '!warn'], | ||
labelValueDefinitions: [], | ||
}, | ||
createdAt: new Date().toISOString(), | ||
}, | ||
) | ||
} | ||
|
||
const pic = fs.readFileSync( | ||
path.join(__dirname, '..', 'assets', 'default-avatar.png'), | ||
) | ||
|
@@ -455,13 +485,13 @@ async function getPort(start = 3000) { | |
} | ||
|
||
export const mockTwilio = (pds: TestPds) => { | ||
if (!pds.ctx.twilio) return | ||
if (!pds.ctx.phoneVerifier) return | ||
|
||
pds.ctx.twilio.sendCode = async (_number: string) => { | ||
pds.ctx.phoneVerifier.sendCode = async (_number: string) => { | ||
// do nothing | ||
} | ||
|
||
pds.ctx.twilio.verifyCode = async (_number: string, code: string) => { | ||
pds.ctx.phoneVerifier.verifyCode = async (_number: string, code: string) => { | ||
return code === '000000' | ||
} | ||
} |
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,45 @@ | ||
import {useState, useEffect} from 'react' | ||
import * as apilib from 'lib/api/index' | ||
import {getLinkMeta} from 'lib/link-meta/link-meta' | ||
import {ComposerOpts} from 'state/shell/composer' | ||
import {getAgent} from '#/state/session' | ||
|
||
export function useExternalLinkFetch({}: { | ||
setQuote: (opts: ComposerOpts['quote']) => void | ||
}) { | ||
const [extLink, setExtLink] = useState<apilib.ExternalEmbedDraft | undefined>( | ||
undefined, | ||
) | ||
|
||
useEffect(() => { | ||
let aborted = false | ||
const cleanup = () => { | ||
aborted = true | ||
} | ||
if (!extLink) { | ||
return cleanup | ||
} | ||
if (!extLink.meta) { | ||
getLinkMeta(getAgent(), extLink.uri).then(meta => { | ||
if (aborted) { | ||
return | ||
} | ||
setExtLink({ | ||
uri: extLink.uri, | ||
isLoading: !!meta.image, | ||
meta, | ||
}) | ||
}) | ||
return cleanup | ||
} | ||
if (extLink.isLoading) { | ||
setExtLink({ | ||
...extLink, | ||
isLoading: false, // done | ||
}) | ||
} | ||
return cleanup | ||
}, [extLink]) | ||
|
||
return {extLink, setExtLink} | ||
} |
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