Various e2e test fixes (#3284)

* 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
This commit is contained in:
Paul Frazee 2024-03-19 17:54:40 -07:00 committed by GitHub
parent a90566d864
commit 54f424d047
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 104 additions and 22 deletions

View file

@ -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: 'mod-authority@test.com',
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'
}
}