mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
1/* eslint-env detox/detox */
2
3import {openApp, loginAsAlice, createServer, sleep} from '../util'
4
5describe('Profile screen', () => {
6 beforeAll(async () => {
7 await createServer('?users&posts&feeds')
8 await openApp({
9 permissions: {notifications: 'YES', medialibrary: 'YES', photos: 'YES'},
10 })
11 })
12
13 it('Login and navigate to my profile', async () => {
14 await expect(element(by.id('signInButton'))).toBeVisible()
15 await loginAsAlice()
16 await element(by.id('bottomBarProfileBtn')).tap()
17 })
18
19 it('Can see feeds', async () => {
20 await element(by.id('selector')).swipe('left')
21 await element(by.id('selector-4')).tap()
22 await expect(element(by.id('feed-alice-favs'))).toBeVisible()
23 await element(by.id('selector')).swipe('right')
24 await element(by.id('selector-0')).tap()
25 })
26
27 it('Open and close edit profile modal', async () => {
28 await element(by.id('profileHeaderEditProfileButton')).tap()
29 await expect(element(by.id('editProfileModal'))).toBeVisible()
30 await element(by.id('editProfileCancelBtn')).tap()
31 await expect(element(by.id('editProfileModal'))).not.toBeVisible()
32 })
33
34 it('Edit display name and description via the edit profile modal', async () => {
35 await element(by.id('profileHeaderEditProfileButton')).tap()
36 await expect(element(by.id('editProfileModal'))).toBeVisible()
37 await element(by.id('editProfileDisplayNameInput')).clearText()
38 await element(by.id('editProfileDisplayNameInput')).typeText('Alicia')
39 await element(by.id('editProfileDescriptionInput')).clearText()
40 await element(by.id('editProfileDescriptionInput')).typeText(
41 'One cool hacker',
42 )
43 await element(by.id('editProfileSaveBtn')).tap()
44 await expect(element(by.id('editProfileModal'))).not.toBeVisible()
45 await expect(element(by.id('profileHeaderDisplayName'))).toHaveText(
46 'Alicia',
47 )
48 await expect(element(by.id('profileHeaderDescription'))).toHaveText(
49 'One cool hacker',
50 )
51 })
52
53 it('Remove display name and description via the edit profile modal', async () => {
54 await element(by.id('profileHeaderEditProfileButton')).tap()
55 await expect(element(by.id('editProfileModal'))).toBeVisible()
56 await element(by.id('editProfileDisplayNameInput')).clearText()
57 await element(by.id('editProfileDescriptionInput')).clearText()
58 await element(by.id('editProfileSaveBtn')).tap()
59 await expect(element(by.id('editProfileModal'))).not.toBeVisible()
60 await expect(element(by.id('profileHeaderDisplayName'))).toHaveText(
61 'alice.test',
62 )
63 await expect(element(by.id('profileHeaderDescription'))).not.toExist()
64 })
65
66 it('Set avi and banner via the edit profile modal', async () => {
67 await expect(element(by.id('userBannerFallback'))).toExist()
68 await expect(element(by.id('userAvatarFallback'))).toExist()
69 await element(by.id('profileHeaderEditProfileButton')).tap()
70 await expect(element(by.id('editProfileModal'))).toBeVisible()
71 await element(by.id('changeBannerBtn')).tap()
72 await element(by.text('Library')).tap()
73 await sleep(3e3)
74 await element(by.id('changeAvatarBtn')).tap()
75 await element(by.text('Library')).tap()
76 await sleep(3e3)
77 await element(by.id('editProfileSaveBtn')).tap()
78 await expect(element(by.id('editProfileModal'))).not.toBeVisible()
79 await expect(element(by.id('userBannerImage'))).toExist()
80 await expect(element(by.id('userAvatarImage'))).toExist()
81 })
82
83 it('Remove avi and banner via the edit profile modal', async () => {
84 await expect(element(by.id('userBannerImage'))).toExist()
85 await expect(element(by.id('userAvatarImage'))).toExist()
86 await element(by.id('profileHeaderEditProfileButton')).tap()
87 await expect(element(by.id('editProfileModal'))).toBeVisible()
88 await element(by.id('changeBannerBtn')).tap()
89 await element(by.text('Remove')).tap()
90 await element(by.id('changeAvatarBtn')).tap()
91 await element(by.text('Remove')).tap()
92 await element(by.id('editProfileSaveBtn')).tap()
93 await expect(element(by.id('editProfileModal'))).not.toBeVisible()
94 await expect(element(by.id('userBannerFallback'))).toExist()
95 await expect(element(by.id('userAvatarFallback'))).toExist()
96 })
97
98 it('Navigate to another user profile', async () => {
99 await element(by.id('bottomBarSearchBtn')).tap()
100 // have to wait for the toast to clear
101 await waitFor(element(by.id('searchTextInput')))
102 .toBeVisible()
103 .withTimeout(5000)
104 await element(by.id('searchTextInput')).typeText('bob')
105 await element(by.id('searchAutoCompleteResult-bob.test')).tap()
106 await expect(element(by.id('profileView'))).toBeVisible()
107 })
108
109 it('Can follow/unfollow another user', async () => {
110 await element(by.id('followBtn')).tap()
111 await expect(element(by.id('unfollowBtn'))).toBeVisible()
112 await element(by.id('unfollowBtn')).tap()
113 await expect(element(by.id('followBtn'))).toBeVisible()
114 })
115
116 it('Can mute/unmute another user', async () => {
117 await expect(element(by.id('profileHeaderAlert'))).not.toExist()
118 await element(by.id('profileHeaderDropdownBtn')).tap()
119 await element(by.text('Mute Account')).tap()
120 await expect(element(by.id('profileHeaderAlert'))).toBeVisible()
121 await element(by.id('profileHeaderDropdownBtn')).tap()
122 await element(by.text('Unmute Account')).tap()
123 await expect(element(by.id('profileHeaderAlert'))).not.toExist()
124 })
125
126 it('Can report another user', async () => {
127 await element(by.id('profileHeaderDropdownBtn')).tap()
128 await element(by.text('Report Account')).tap()
129 await expect(element(by.id('reportModal'))).toBeVisible()
130 await element(
131 by.id('reportReasonRadios-com.atproto.moderation.defs#reasonSpam'),
132 ).tap()
133 await element(by.id('sendReportBtn')).tap()
134 await expect(element(by.id('reportModal'))).not.toBeVisible()
135 })
136
137 it('Can like posts', async () => {
138 const posts = by.id('feedItem-by-bob.test')
139 await expect(
140 element(by.id('likeCount').withAncestor(posts)).atIndex(0),
141 ).toHaveText('0')
142 await element(by.id('likeBtn').withAncestor(posts)).atIndex(0).tap()
143 await expect(
144 element(by.id('likeCount').withAncestor(posts)).atIndex(0),
145 ).toHaveText('1')
146 await element(by.id('likeBtn').withAncestor(posts)).atIndex(0).tap()
147 await expect(
148 element(by.id('likeCount').withAncestor(posts)).atIndex(0),
149 ).toHaveText('0')
150 })
151
152 it('Can repost posts', async () => {
153 const posts = by.id('feedItem-by-bob.test')
154 await expect(
155 element(by.id('repostCount').withAncestor(posts)).atIndex(0),
156 ).toHaveText('0')
157 await element(by.id('repostBtn').withAncestor(posts)).atIndex(0).tap()
158 await expect(element(by.id('repostModal'))).toBeVisible()
159 await element(by.id('repostBtn').withAncestor(by.id('repostModal'))).tap()
160 await expect(element(by.id('repostModal'))).not.toBeVisible()
161 await expect(
162 element(by.id('repostCount').withAncestor(posts)).atIndex(0),
163 ).toHaveText('1')
164 await element(by.id('repostBtn').withAncestor(posts)).atIndex(0).tap()
165 await expect(element(by.id('repostModal'))).toBeVisible()
166 await element(by.id('repostBtn').withAncestor(by.id('repostModal'))).tap()
167 await expect(element(by.id('repostModal'))).not.toBeVisible()
168 await expect(
169 element(by.id('repostCount').withAncestor(posts)).atIndex(0),
170 ).toHaveText('0')
171 })
172
173 it('Can report posts', async () => {
174 const posts = by.id('feedItem-by-bob.test')
175 await element(by.id('postDropdownBtn').withAncestor(posts)).atIndex(0).tap()
176 await element(by.text('Report post')).tap()
177 await expect(element(by.id('reportModal'))).toBeVisible()
178 await element(
179 by.id('reportReasonRadios-com.atproto.moderation.defs#reasonSpam'),
180 ).tap()
181 await element(by.id('sendReportBtn')).tap()
182 await expect(element(by.id('reportModal'))).not.toBeVisible()
183 })
184})