Fix to feeds view in profiles (#1171)
* Fix load of feeds tab * Add e2e test for profile feedszio/stable
parent
a3af2a2b85
commit
f4891a47a1
|
@ -53,6 +53,10 @@ async function main() {
|
||||||
await server.mocker.users[user].agent.post({text: 'Post'})
|
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) {
|
if ('thread' in url.query) {
|
||||||
console.log('Generating mock posts')
|
console.log('Generating mock posts')
|
||||||
const res = await server.mocker.users.bob.agent.post({
|
const res = await server.mocker.users.bob.agent.post({
|
||||||
|
|
|
@ -5,7 +5,7 @@ import {openApp, login, createServer, sleep} from '../util'
|
||||||
describe('Profile screen', () => {
|
describe('Profile screen', () => {
|
||||||
let service: string
|
let service: string
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
service = await createServer('?users&posts')
|
service = await createServer('?users&posts&feeds')
|
||||||
await openApp({
|
await openApp({
|
||||||
permissions: {notifications: 'YES', medialibrary: 'YES', photos: 'YES'},
|
permissions: {notifications: 'YES', medialibrary: 'YES', photos: 'YES'},
|
||||||
})
|
})
|
||||||
|
@ -17,6 +17,12 @@ describe('Profile screen', () => {
|
||||||
await element(by.id('bottomBarProfileBtn')).tap()
|
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 () => {
|
it('Open and close edit profile modal', async () => {
|
||||||
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()
|
||||||
|
|
|
@ -2,7 +2,7 @@ import net from 'net'
|
||||||
import path from 'path'
|
import path from 'path'
|
||||||
import fs from 'fs'
|
import fs from 'fs'
|
||||||
import {TestPds as DevEnvTestPDS, TestNetworkNoAppView} from '@atproto/dev-env'
|
import {TestPds as DevEnvTestPDS, TestNetworkNoAppView} from '@atproto/dev-env'
|
||||||
import {BskyAgent} from '@atproto/api'
|
import {AtUri, BskyAgent} from '@atproto/api'
|
||||||
|
|
||||||
export interface TestUser {
|
export interface TestUser {
|
||||||
email: string
|
email: string
|
||||||
|
@ -212,6 +212,31 @@ class Mocker {
|
||||||
return await agent.like(uri, cid)
|
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) {
|
async createInvite(forAccount: string) {
|
||||||
const agent = new BskyAgent({service: this.agent.service})
|
const agent = new BskyAgent({service: this.agent.service})
|
||||||
await agent.api.com.atproto.server.createInviteCode(
|
await agent.api.com.atproto.server.createInviteCode(
|
||||||
|
|
|
@ -114,32 +114,25 @@ export class ProfileUiModel {
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
} else {
|
} else {
|
||||||
// not loading, no error, show content
|
|
||||||
if (
|
if (
|
||||||
this.selectedView === Sections.PostsNoReplies ||
|
this.selectedView === Sections.PostsNoReplies ||
|
||||||
this.selectedView === Sections.PostsWithReplies ||
|
this.selectedView === Sections.PostsWithReplies ||
|
||||||
this.selectedView === Sections.PostsWithMedia ||
|
this.selectedView === Sections.PostsWithMedia
|
||||||
this.selectedView === Sections.CustomAlgorithms
|
|
||||||
) {
|
) {
|
||||||
if (this.feed.hasContent) {
|
if (this.feed.hasContent) {
|
||||||
if (this.selectedView === Sections.CustomAlgorithms) {
|
arr = this.feed.slices.slice()
|
||||||
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()
|
|
||||||
}
|
|
||||||
if (!this.feed.hasMore) {
|
if (!this.feed.hasMore) {
|
||||||
arr = arr.concat([ProfileUiModel.END_ITEM])
|
arr = arr.concat([ProfileUiModel.END_ITEM])
|
||||||
}
|
}
|
||||||
} else if (this.feed.isEmpty) {
|
} else if (this.feed.isEmpty) {
|
||||||
arr = arr.concat([ProfileUiModel.EMPTY_ITEM])
|
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) {
|
} else if (this.selectedView === Sections.Lists) {
|
||||||
if (this.lists.hasContent) {
|
if (this.lists.hasContent) {
|
||||||
arr = this.lists.lists
|
arr = this.lists.lists
|
||||||
|
|
|
@ -69,6 +69,7 @@ export const CustomFeed = observer(
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
|
testID={`feed-${item.displayName}`}
|
||||||
accessibilityRole="button"
|
accessibilityRole="button"
|
||||||
style={[styles.container, pal.border, style]}
|
style={[styles.container, pal.border, style]}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
|
Loading…
Reference in New Issue