Fix to feeds view in profiles (#1171)

* Fix load of feeds tab

* Add e2e test for profile feeds
zio/stable
Paul Frazee 2023-08-15 09:59:49 -07:00 committed by GitHub
parent a3af2a2b85
commit f4891a47a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 17 deletions

View File

@ -53,6 +53,10 @@ async function main() {
await server.mocker.users[user].agent.post({text: 'Post'})
}
}
if ('feeds' in url.query) {
console.log('Generating mock feed')
await server.mocker.createFeed('alice')
}
if ('thread' in url.query) {
console.log('Generating mock posts')
const res = await server.mocker.users.bob.agent.post({

View File

@ -5,7 +5,7 @@ import {openApp, login, createServer, sleep} from '../util'
describe('Profile screen', () => {
let service: string
beforeAll(async () => {
service = await createServer('?users&posts')
service = await createServer('?users&posts&feeds')
await openApp({
permissions: {notifications: 'YES', medialibrary: 'YES', photos: 'YES'},
})
@ -17,6 +17,12 @@ describe('Profile screen', () => {
await element(by.id('bottomBarProfileBtn')).tap()
})
it('Can see feeds', async () => {
await element(by.id('selector-3')).tap()
await expect(element(by.id('feed-alices feed'))).toBeVisible()
await element(by.id('selector-0')).tap()
})
it('Open and close edit profile modal', async () => {
await element(by.id('profileHeaderEditProfileButton')).tap()
await expect(element(by.id('editProfileModal'))).toBeVisible()

View File

@ -2,7 +2,7 @@ import net from 'net'
import path from 'path'
import fs from 'fs'
import {TestPds as DevEnvTestPDS, TestNetworkNoAppView} from '@atproto/dev-env'
import {BskyAgent} from '@atproto/api'
import {AtUri, BskyAgent} from '@atproto/api'
export interface TestUser {
email: string
@ -212,6 +212,31 @@ class Mocker {
return await agent.like(uri, cid)
}
async createFeed(user: string) {
const agent = this.users[user]?.agent
if (!agent) {
throw new Error(`Not a user: ${user}`)
}
const fg1Uri = AtUri.make(
this.users[user].did,
'app.bsky.feed.generator',
'alice-favs',
)
const avatarRes = await agent.api.com.atproto.repo.uploadBlob(this.pic, {
encoding: 'image/png',
})
return await agent.api.app.bsky.feed.generator.create(
{repo: this.users[user].did, rkey: fg1Uri.rkey},
{
did: 'did:web:fake.com',
displayName: 'alices feed',
description: 'all my fav stuff',
avatar: avatarRes.data.blob,
createdAt: new Date().toISOString(),
},
)
}
async createInvite(forAccount: string) {
const agent = new BskyAgent({service: this.agent.service})
await agent.api.com.atproto.server.createInviteCode(

View File

@ -114,32 +114,25 @@ export class ProfileUiModel {
},
])
} else {
// not loading, no error, show content
if (
this.selectedView === Sections.PostsNoReplies ||
this.selectedView === Sections.PostsWithReplies ||
this.selectedView === Sections.PostsWithMedia ||
this.selectedView === Sections.CustomAlgorithms
this.selectedView === Sections.PostsWithMedia
) {
if (this.feed.hasContent) {
if (this.selectedView === Sections.CustomAlgorithms) {
arr = this.algos.feeds
} else if (
this.selectedView === Sections.PostsNoReplies ||
this.selectedView === Sections.PostsWithReplies ||
this.selectedView === Sections.PostsWithMedia
) {
arr = this.feed.slices.slice()
} else {
// posts with replies is also default
arr = this.feed.slices.slice()
}
arr = this.feed.slices.slice()
if (!this.feed.hasMore) {
arr = arr.concat([ProfileUiModel.END_ITEM])
}
} else if (this.feed.isEmpty) {
arr = arr.concat([ProfileUiModel.EMPTY_ITEM])
}
} else if (this.selectedView === Sections.CustomAlgorithms) {
if (this.algos.hasContent) {
arr = this.algos.feeds
} else if (this.algos.isEmpty) {
arr = arr.concat([ProfileUiModel.EMPTY_ITEM])
}
} else if (this.selectedView === Sections.Lists) {
if (this.lists.hasContent) {
arr = this.lists.lists

View File

@ -69,6 +69,7 @@ export const CustomFeed = observer(
return (
<TouchableOpacity
testID={`feed-${item.displayName}`}
accessibilityRole="button"
style={[styles.container, pal.border, style]}
onPress={() => {