2023-03-31 20:17:26 +02:00
|
|
|
/* eslint-env detox/detox */
|
|
|
|
|
2023-12-05 21:50:56 +01:00
|
|
|
import {describe, beforeAll, it} from '@jest/globals'
|
|
|
|
import {expect} from 'detox'
|
2023-09-21 04:47:56 +02:00
|
|
|
import {openApp, loginAsAlice, createServer} from '../util'
|
2023-03-31 20:17:26 +02:00
|
|
|
|
|
|
|
describe('Home screen', () => {
|
|
|
|
beforeAll(async () => {
|
2023-11-30 01:28:35 +01:00
|
|
|
await createServer('?users&follows&posts&feeds')
|
2023-03-31 20:17:26 +02:00
|
|
|
await openApp({permissions: {notifications: 'YES'}})
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Login', async () => {
|
2023-09-21 04:47:56 +02:00
|
|
|
await loginAsAlice()
|
2023-03-31 20:17:26 +02:00
|
|
|
await element(by.id('homeScreenFeedTabs-Following')).tap()
|
|
|
|
})
|
|
|
|
|
2023-11-30 01:28:35 +01:00
|
|
|
it('Can go to feeds page using feeds button in tab bar', async () => {
|
|
|
|
await element(by.id('homeScreenFeedTabs-Feeds ✨')).tap()
|
|
|
|
await expect(element(by.text('Discover new feeds'))).toBeVisible()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Feeds button disappears after pinning a feed', async () => {
|
|
|
|
await element(by.id('bottomBarProfileBtn')).tap()
|
|
|
|
await element(by.id('profilePager-selector')).swipe('left')
|
|
|
|
await element(by.id('profilePager-selector-4')).tap()
|
|
|
|
await element(by.id('feed-alice-favs')).tap()
|
|
|
|
await element(by.id('pinBtn')).tap()
|
|
|
|
await element(by.id('bottomBarHomeBtn')).tap()
|
|
|
|
await expect(
|
|
|
|
element(by.id('homeScreenFeedTabs-Feeds ✨')),
|
|
|
|
).not.toBeVisible()
|
|
|
|
})
|
|
|
|
|
2023-03-31 20:17:26 +02:00
|
|
|
it('Can like posts', async () => {
|
|
|
|
const carlaPosts = by.id('feedItem-by-carla.test')
|
|
|
|
await expect(
|
|
|
|
element(by.id('likeCount').withAncestor(carlaPosts)).atIndex(0),
|
|
|
|
).toHaveText('0')
|
|
|
|
await element(by.id('likeBtn').withAncestor(carlaPosts)).atIndex(0).tap()
|
|
|
|
await expect(
|
|
|
|
element(by.id('likeCount').withAncestor(carlaPosts)).atIndex(0),
|
|
|
|
).toHaveText('1')
|
|
|
|
await element(by.id('likeBtn').withAncestor(carlaPosts)).atIndex(0).tap()
|
|
|
|
await expect(
|
|
|
|
element(by.id('likeCount').withAncestor(carlaPosts)).atIndex(0),
|
|
|
|
).toHaveText('0')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Can repost posts', async () => {
|
|
|
|
const carlaPosts = by.id('feedItem-by-carla.test')
|
|
|
|
await expect(
|
|
|
|
element(by.id('repostCount').withAncestor(carlaPosts)).atIndex(0),
|
|
|
|
).toHaveText('0')
|
|
|
|
await element(by.id('repostBtn').withAncestor(carlaPosts)).atIndex(0).tap()
|
|
|
|
await expect(element(by.id('repostModal'))).toBeVisible()
|
|
|
|
await element(by.id('repostBtn').withAncestor(by.id('repostModal'))).tap()
|
|
|
|
await expect(element(by.id('repostModal'))).not.toBeVisible()
|
|
|
|
await expect(
|
|
|
|
element(by.id('repostCount').withAncestor(carlaPosts)).atIndex(0),
|
|
|
|
).toHaveText('1')
|
|
|
|
await element(by.id('repostBtn').withAncestor(carlaPosts)).atIndex(0).tap()
|
|
|
|
await expect(element(by.id('repostModal'))).toBeVisible()
|
|
|
|
await element(by.id('repostBtn').withAncestor(by.id('repostModal'))).tap()
|
|
|
|
await expect(element(by.id('repostModal'))).not.toBeVisible()
|
|
|
|
await expect(
|
|
|
|
element(by.id('repostCount').withAncestor(carlaPosts)).atIndex(0),
|
|
|
|
).toHaveText('0')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Can report posts', async () => {
|
|
|
|
const carlaPosts = by.id('feedItem-by-carla.test')
|
|
|
|
await element(by.id('postDropdownBtn').withAncestor(carlaPosts))
|
|
|
|
.atIndex(0)
|
|
|
|
.tap()
|
2023-07-28 23:00:37 +02:00
|
|
|
await element(by.text('Report post')).tap()
|
2023-08-15 23:32:06 +02:00
|
|
|
await expect(element(by.id('reportModal'))).toBeVisible()
|
2023-04-26 04:25:49 +02:00
|
|
|
await element(
|
2023-08-15 23:32:06 +02:00
|
|
|
by.id('reportReasonRadios-com.atproto.moderation.defs#reasonSpam'),
|
2023-04-26 04:25:49 +02:00
|
|
|
).tap()
|
2023-03-31 20:17:26 +02:00
|
|
|
await element(by.id('sendReportBtn')).tap()
|
2023-08-15 23:32:06 +02:00
|
|
|
await expect(element(by.id('reportModal'))).not.toBeVisible()
|
2023-03-31 20:17:26 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Can swipe between feeds', async () => {
|
|
|
|
await element(by.id('homeScreen')).swipe('left', 'fast', 0.75)
|
2023-11-30 01:28:35 +01:00
|
|
|
await expect(element(by.id('customFeedPage'))).toBeVisible()
|
2023-03-31 20:17:26 +02:00
|
|
|
await element(by.id('homeScreen')).swipe('right', 'fast', 0.75)
|
|
|
|
await expect(element(by.id('followingFeedPage'))).toBeVisible()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Can tap between feeds', async () => {
|
2023-11-30 01:28:35 +01:00
|
|
|
await element(by.id('homeScreenFeedTabs-alice-favs')).tap()
|
|
|
|
await expect(element(by.id('customFeedPage'))).toBeVisible()
|
2023-03-31 20:17:26 +02:00
|
|
|
await element(by.id('homeScreenFeedTabs-Following')).tap()
|
|
|
|
await expect(element(by.id('followingFeedPage'))).toBeVisible()
|
|
|
|
})
|
|
|
|
|
|
|
|
it('Can delete posts', async () => {
|
|
|
|
const alicePosts = by.id('feedItem-by-alice.test')
|
|
|
|
await expect(element(alicePosts.withDescendant(by.text('Post')))).toExist()
|
|
|
|
await element(by.id('postDropdownBtn').withAncestor(alicePosts))
|
|
|
|
.atIndex(0)
|
|
|
|
.tap()
|
2023-07-28 23:00:37 +02:00
|
|
|
await element(by.text('Delete post')).tap()
|
2023-03-31 20:17:26 +02:00
|
|
|
await expect(element(by.id('confirmModal'))).toBeVisible()
|
|
|
|
await element(by.id('confirmBtn')).tap()
|
|
|
|
await expect(
|
|
|
|
element(alicePosts.withDescendant(by.text('Post'))),
|
|
|
|
).not.toExist()
|
|
|
|
})
|
|
|
|
})
|