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
zio/stable
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

@ -64,7 +64,7 @@ describe('Curate lists', () => {
await element(by.text('Edit list details')).tap() await element(by.text('Edit list details')).tap()
await expect(element(by.id('createOrEditListModal'))).toBeVisible() await expect(element(by.id('createOrEditListModal'))).toBeVisible()
await element(by.id('changeAvatarBtn')).tap() await element(by.id('changeAvatarBtn')).tap()
await element(by.text('Library')).tap() await element(by.text('Upload from Library')).tap()
await sleep(3e3) await sleep(3e3)
await element(by.id('saveBtn')).tap() await element(by.id('saveBtn')).tap()
await expect(element(by.id('createOrEditListModal'))).not.toBeVisible() await expect(element(by.id('createOrEditListModal'))).not.toBeVisible()
@ -81,7 +81,7 @@ describe('Curate lists', () => {
await element(by.text('Edit list details')).tap() await element(by.text('Edit list details')).tap()
await expect(element(by.id('createOrEditListModal'))).toBeVisible() await expect(element(by.id('createOrEditListModal'))).toBeVisible()
await element(by.id('changeAvatarBtn')).tap() await element(by.id('changeAvatarBtn')).tap()
await element(by.text('Remove')).tap() await element(by.text('Remove Avatar')).tap()
await element(by.id('saveBtn')).tap() await element(by.id('saveBtn')).tap()
await expect(element(by.id('createOrEditListModal'))).not.toBeVisible() await expect(element(by.id('createOrEditListModal'))).not.toBeVisible()
await expect(element(by.id('userAvatarFallback'))).toExist() await expect(element(by.id('userAvatarFallback'))).toExist()

View File

@ -17,7 +17,7 @@ describe('Home screen', () => {
it('Can go to feeds page using feeds button in tab bar', async () => { it('Can go to feeds page using feeds button in tab bar', async () => {
await element(by.id('homeScreenFeedTabs-Feeds ✨')).tap() await element(by.id('homeScreenFeedTabs-Feeds ✨')).tap()
await expect(element(by.text('Discover new feeds'))).toBeVisible() await expect(element(by.text('Discover New Feeds'))).toBeVisible()
}) })
it('Feeds button disappears after pinning a feed', async () => { it('Feeds button disappears after pinning a feed', async () => {

View File

@ -70,10 +70,10 @@ describe('Profile screen', () => {
await element(by.id('profileHeaderEditProfileButton')).tap() await element(by.id('profileHeaderEditProfileButton')).tap()
await expect(element(by.id('editProfileModal'))).toBeVisible() await expect(element(by.id('editProfileModal'))).toBeVisible()
await element(by.id('changeBannerBtn')).tap() await element(by.id('changeBannerBtn')).tap()
await element(by.text('Library')).tap() await element(by.text('Upload from Library')).tap()
await sleep(3e3) await sleep(3e3)
await element(by.id('changeAvatarBtn')).tap() await element(by.id('changeAvatarBtn')).tap()
await element(by.text('Library')).tap() await element(by.text('Upload from Library')).tap()
await sleep(3e3) await sleep(3e3)
await element(by.id('editProfileSaveBtn')).tap() await element(by.id('editProfileSaveBtn')).tap()
await expect(element(by.id('editProfileModal'))).not.toBeVisible() await expect(element(by.id('editProfileModal'))).not.toBeVisible()
@ -87,9 +87,9 @@ describe('Profile screen', () => {
await element(by.id('profileHeaderEditProfileButton')).tap() await element(by.id('profileHeaderEditProfileButton')).tap()
await expect(element(by.id('editProfileModal'))).toBeVisible() await expect(element(by.id('editProfileModal'))).toBeVisible()
await element(by.id('changeBannerBtn')).tap() await element(by.id('changeBannerBtn')).tap()
await element(by.text('Remove')).tap() await element(by.text('Remove Banner')).tap()
await element(by.id('changeAvatarBtn')).tap() await element(by.id('changeAvatarBtn')).tap()
await element(by.text('Remove')).tap() await element(by.text('Remove Avatar')).tap()
await element(by.id('editProfileSaveBtn')).tap() await element(by.id('editProfileSaveBtn')).tap()
await expect(element(by.id('editProfileModal'))).not.toBeVisible() await expect(element(by.id('editProfileModal'))).not.toBeVisible()
await expect(element(by.id('userBannerFallback'))).toExist() await expect(element(by.id('userBannerFallback'))).toExist()

View File

@ -12,6 +12,7 @@ describe('Create account', () => {
}) })
it('I can create a new account with text verification', async () => { it('I can create a new account with text verification', async () => {
console.log('SERVICE IS', service)
await element(by.id('e2eOpenLoggedOutView')).tap() await element(by.id('e2eOpenLoggedOutView')).tap()
await element(by.id('createAccountButton')).tap() await element(by.id('createAccountButton')).tap()
@ -28,16 +29,17 @@ describe('Create account', () => {
await device.takeScreenshot('4- entered account details') await device.takeScreenshot('4- entered account details')
await element(by.id('nextBtn')).tap() await element(by.id('nextBtn')).tap()
await element(by.id('phoneInput')).typeText('8042221111') await element(by.id('handleInput')).typeText('text-verification-test')
await element(by.id('requestCodeBtn')).tap() await device.takeScreenshot('5- entered handle')
await device.takeScreenshot('5- requested code')
await element(by.id('codeInput')).typeText('000000')
await device.takeScreenshot('6- entered code')
await element(by.id('nextBtn')).tap() await element(by.id('nextBtn')).tap()
await element(by.id('handleInput')).typeText('text-verification-test') await element(by.id('phoneInput')).typeText('8042221111')
await device.takeScreenshot('7- entered handle') await element(by.id('requestCodeBtn')).tap()
await device.takeScreenshot('6- requested code')
await element(by.id('codeInput')).typeText('000000')
await device.takeScreenshot('7- entered code')
await element(by.id('nextBtn')).tap()
await element(by.id('nextBtn')).tap() await element(by.id('nextBtn')).tap()

View File

@ -72,6 +72,7 @@ export async function createServer(
const phoneParams = phoneRequired const phoneParams = phoneRequired
? { ? {
phoneVerificationRequired: true, phoneVerificationRequired: true,
phoneVerificationProvider: 'twilio',
twilioAccountSid: 'ACXXXXXXX', twilioAccountSid: 'ACXXXXXXX',
twilioAuthToken: 'AUTH', twilioAuthToken: 'AUTH',
twilioServiceSid: 'VAXXXXXXXX', twilioServiceSid: 'VAXXXXXXXX',
@ -95,6 +96,35 @@ export async function createServer(
}) })
mockTwilio(testNet.pds) 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( const pic = fs.readFileSync(
path.join(__dirname, '..', 'assets', 'default-avatar.png'), path.join(__dirname, '..', 'assets', 'default-avatar.png'),
) )
@ -455,13 +485,13 @@ async function getPort(start = 3000) {
} }
export const mockTwilio = (pds: TestPds) => { 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 // do nothing
} }
pds.ctx.twilio.verifyCode = async (_number: string, code: string) => { pds.ctx.phoneVerifier.verifyCode = async (_number: string, code: string) => {
return code === '000000' return code === '000000'
} }
} }

View File

@ -3,7 +3,6 @@ import RNFS from 'react-native-fs'
import {CropperOptions} from './types' import {CropperOptions} from './types'
import {compressIfNeeded} from './manip' import {compressIfNeeded} from './manip'
let _imageCounter = 0
async function getFile() { async function getFile() {
let files = await RNFS.readDir( let files = await RNFS.readDir(
RNFS.LibraryDirectoryPath.split('/') RNFS.LibraryDirectoryPath.split('/')
@ -12,7 +11,7 @@ async function getFile() {
.join('/'), .join('/'),
) )
files = files.filter(file => file.path.endsWith('.JPG')) files = files.filter(file => file.path.endsWith('.JPG'))
const file = files[_imageCounter++ % files.length] const file = files[0]
return await compressIfNeeded({ return await compressIfNeeded({
path: file.path, path: file.path,
mime: 'image/jpeg', mime: 'image/jpeg',

View File

@ -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}
}

View File

@ -298,7 +298,10 @@ let EditableUserAvatar = ({
<Menu.Root> <Menu.Root>
<Menu.Trigger label={_(msg`Edit avatar`)}> <Menu.Trigger label={_(msg`Edit avatar`)}>
{({props}) => ( {({props}) => (
<TouchableOpacity {...props} activeOpacity={0.8}> <TouchableOpacity
{...props}
activeOpacity={0.8}
testID="changeAvatarBtn">
{avatar ? ( {avatar ? (
<HighPriorityImage <HighPriorityImage
testID="userAvatarImage" testID="userAvatarImage"

View File

@ -84,7 +84,10 @@ export function UserBanner({
<Menu.Root> <Menu.Root>
<Menu.Trigger label={_(msg`Edit avatar`)}> <Menu.Trigger label={_(msg`Edit avatar`)}>
{({props}) => ( {({props}) => (
<TouchableOpacity {...props} activeOpacity={0.8}> <TouchableOpacity
{...props}
activeOpacity={0.8}
testID="changeBannerBtn">
{banner ? ( {banner ? (
<Image <Image
testID="userBannerImage" testID="userBannerImage"