diff options
Diffstat (limited to 'server/tests')
-rw-r--r-- | server/tests/api/check-params/follows.ts | 44 | ||||
-rw-r--r-- | server/tests/api/server/follows.ts | 26 |
2 files changed, 65 insertions, 5 deletions
diff --git a/server/tests/api/check-params/follows.ts b/server/tests/api/check-params/follows.ts index 2eb54cb0a..488666a75 100644 --- a/server/tests/api/check-params/follows.ts +++ b/server/tests/api/check-params/follows.ts | |||
@@ -6,7 +6,7 @@ import { | |||
6 | cleanupTests, | 6 | cleanupTests, |
7 | createUser, | 7 | createUser, |
8 | flushAndRunServer, | 8 | flushAndRunServer, |
9 | makeDeleteRequest, | 9 | makeDeleteRequest, makeGetRequest, |
10 | makePostBodyRequest, | 10 | makePostBodyRequest, |
11 | ServerInfo, | 11 | ServerInfo, |
12 | setAccessTokensToServers, | 12 | setAccessTokensToServers, |
@@ -131,6 +131,27 @@ describe('Test server follows API validators', function () { | |||
131 | it('Should fail with an incorrect sort', async function () { | 131 | it('Should fail with an incorrect sort', async function () { |
132 | await checkBadSortPagination(server.url, path) | 132 | await checkBadSortPagination(server.url, path) |
133 | }) | 133 | }) |
134 | |||
135 | it('Should fail with an incorrect state', async function () { | ||
136 | await makeGetRequest({ | ||
137 | url: server.url, | ||
138 | path, | ||
139 | query: { | ||
140 | state: 'blabla' | ||
141 | } | ||
142 | }) | ||
143 | }) | ||
144 | |||
145 | it('Should fail succeed with the correct params', async function () { | ||
146 | await makeGetRequest({ | ||
147 | url: server.url, | ||
148 | path, | ||
149 | statusCodeExpected: 200, | ||
150 | query: { | ||
151 | state: 'accepted' | ||
152 | } | ||
153 | }) | ||
154 | }) | ||
134 | }) | 155 | }) |
135 | 156 | ||
136 | describe('When listing followers', function () { | 157 | describe('When listing followers', function () { |
@@ -147,6 +168,27 @@ describe('Test server follows API validators', function () { | |||
147 | it('Should fail with an incorrect sort', async function () { | 168 | it('Should fail with an incorrect sort', async function () { |
148 | await checkBadSortPagination(server.url, path) | 169 | await checkBadSortPagination(server.url, path) |
149 | }) | 170 | }) |
171 | |||
172 | it('Should fail with an incorrect state', async function () { | ||
173 | await makeGetRequest({ | ||
174 | url: server.url, | ||
175 | path, | ||
176 | query: { | ||
177 | state: 'blabla' | ||
178 | } | ||
179 | }) | ||
180 | }) | ||
181 | |||
182 | it('Should fail succeed with the correct params', async function () { | ||
183 | await makeGetRequest({ | ||
184 | url: server.url, | ||
185 | path, | ||
186 | statusCodeExpected: 200, | ||
187 | query: { | ||
188 | state: 'accepted' | ||
189 | } | ||
190 | }) | ||
191 | }) | ||
150 | }) | 192 | }) |
151 | 193 | ||
152 | describe('When removing a follower', function () { | 194 | describe('When removing a follower', function () { |
diff --git a/server/tests/api/server/follows.ts b/server/tests/api/server/follows.ts index e8d6f5138..36a061926 100644 --- a/server/tests/api/server/follows.ts +++ b/server/tests/api/server/follows.ts | |||
@@ -97,14 +97,23 @@ describe('Test follows', function () { | |||
97 | expect(server3Follow.state).to.equal('accepted') | 97 | expect(server3Follow.state).to.equal('accepted') |
98 | }) | 98 | }) |
99 | 99 | ||
100 | it('Should search followings on server 1', async function () { | 100 | it('Should search/filter followings on server 1', async function () { |
101 | { | 101 | { |
102 | const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', ':' + servers[1].port) | 102 | const search = ':' + servers[1].port |
103 | const res = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', search) | ||
103 | const follows = res.body.data | 104 | const follows = res.body.data |
104 | 105 | ||
105 | expect(res.body.total).to.equal(1) | 106 | expect(res.body.total).to.equal(1) |
106 | expect(follows.length).to.equal(1) | 107 | expect(follows.length).to.equal(1) |
107 | expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[1].port) | 108 | expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[1].port) |
109 | |||
110 | const res2 = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', search, 'accepted') | ||
111 | expect(res2.body.total).to.equal(1) | ||
112 | expect(res2.body.data).to.have.lengthOf(1) | ||
113 | |||
114 | const res3 = await getFollowingListPaginationAndSort(servers[ 0 ].url, 0, 1, 'createdAt', search, 'pending') | ||
115 | expect(res3.body.total).to.equal(0) | ||
116 | expect(res3.body.data).to.have.lengthOf(0) | ||
108 | } | 117 | } |
109 | 118 | ||
110 | { | 119 | { |
@@ -139,14 +148,23 @@ describe('Test follows', function () { | |||
139 | } | 148 | } |
140 | }) | 149 | }) |
141 | 150 | ||
142 | it('Should search followers on server 2', async function () { | 151 | it('Should search/filter followers on server 2', async function () { |
143 | { | 152 | { |
144 | const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', servers[0].port + '') | 153 | const search = servers[0].port + '' |
154 | const res = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', search) | ||
145 | const follows = res.body.data | 155 | const follows = res.body.data |
146 | 156 | ||
147 | expect(res.body.total).to.equal(1) | 157 | expect(res.body.total).to.equal(1) |
148 | expect(follows.length).to.equal(1) | 158 | expect(follows.length).to.equal(1) |
149 | expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[2].port) | 159 | expect(follows[ 0 ].following.host).to.equal('localhost:' + servers[2].port) |
160 | |||
161 | const res2 = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', search, 'accepted') | ||
162 | expect(res2.body.total).to.equal(1) | ||
163 | expect(res2.body.data).to.have.lengthOf(1) | ||
164 | |||
165 | const res3 = await getFollowersListPaginationAndSort(servers[ 2 ].url, 0, 5, 'createdAt', search, 'pending') | ||
166 | expect(res3.body.total).to.equal(0) | ||
167 | expect(res3.body.data).to.have.lengthOf(0) | ||
150 | } | 168 | } |
151 | 169 | ||
152 | { | 170 | { |