Adding some more tests, some still broken.
This commit is contained in:
parent
554d6beafa
commit
d4492a573a
5 changed files with 42 additions and 0 deletions
13
api_tests/src/community.spec.ts
vendored
13
api_tests/src/community.spec.ts
vendored
|
@ -1,8 +1,10 @@
|
|||
jest.setTimeout(120000);
|
||||
import {
|
||||
alpha,
|
||||
beta,
|
||||
setupLogins,
|
||||
searchForBetaCommunity,
|
||||
searchForCommunity,
|
||||
createCommunity,
|
||||
deleteCommunity,
|
||||
removeCommunity,
|
||||
|
@ -21,6 +23,17 @@ test('Create community', async () => {
|
|||
let prevName = communityRes.community.name;
|
||||
let communityRes2 = await createCommunity(alpha, prevName);
|
||||
expect(communityRes2['error']).toBe('community_already_exists');
|
||||
await delay();
|
||||
|
||||
// Cache the community on beta, make sure it has the other fields
|
||||
let searchShort = `!${prevName}@lemmy-alpha:8540`;
|
||||
let search = await searchForCommunity(beta, searchShort);
|
||||
let communityOnBeta = search.communities[0];
|
||||
expect(communityOnBeta.name).toBe(communityRes.community.name);
|
||||
expect(communityOnBeta.title).toBe(communityRes.community.title);
|
||||
expect(communityOnBeta.description).toBe(communityRes.community.description);
|
||||
expect(communityOnBeta.icon).toBe(communityRes.community.icon);
|
||||
expect(communityOnBeta.banner).toBe(communityRes.community.banner);
|
||||
});
|
||||
|
||||
test('Delete community', async () => {
|
||||
|
|
4
api_tests/src/post.spec.ts
vendored
4
api_tests/src/post.spec.ts
vendored
|
@ -56,6 +56,10 @@ test('Create a post', async () => {
|
|||
expect(betaPost.community_local).toBe(true);
|
||||
expect(betaPost.creator_local).toBe(false);
|
||||
expect(betaPost.score).toBe(1);
|
||||
expect(betaPost.name).toBe(postRes.post.name);
|
||||
expect(betaPost.body).toBe(postRes.post.body);
|
||||
expect(betaPost.url).toBe(postRes.post.url);
|
||||
expect(betaPost.nsfw).toBe(postRes.post.nsfw);
|
||||
|
||||
// Delta only follows beta, so it should not see an alpha ap_id
|
||||
let searchDelta = await searchPost(delta, postRes.post);
|
||||
|
|
23
api_tests/src/shared.ts
vendored
23
api_tests/src/shared.ts
vendored
|
@ -120,8 +120,12 @@ export async function createPost(
|
|||
community_id: number
|
||||
): Promise<PostResponse> {
|
||||
let name = 'A jest test post';
|
||||
let body = 'Some body';
|
||||
let url = 'https://google.com/';
|
||||
let form: PostForm = {
|
||||
name,
|
||||
url,
|
||||
body,
|
||||
auth: api.auth,
|
||||
community_id,
|
||||
nsfw: false,
|
||||
|
@ -239,6 +243,19 @@ export async function searchForBetaCommunity(
|
|||
return api.client.search(form);
|
||||
}
|
||||
|
||||
export async function searchForCommunity(
|
||||
api: API,
|
||||
q: string,
|
||||
): Promise<SearchResponse> {
|
||||
// Use short-hand search url
|
||||
let form: SearchForm = {
|
||||
q,
|
||||
type_: SearchType.Communities,
|
||||
sort: SortType.TopAll,
|
||||
};
|
||||
return api.client.search(form);
|
||||
}
|
||||
|
||||
export async function searchForUser(
|
||||
api: API,
|
||||
apShortname: string
|
||||
|
@ -369,9 +386,15 @@ export async function createCommunity(
|
|||
api: API,
|
||||
name_: string = randomString(5)
|
||||
): Promise<CommunityResponse> {
|
||||
let description = 'a sample description';
|
||||
let icon = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
||||
let banner = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
||||
let form: CommunityForm = {
|
||||
name: name_,
|
||||
title: name_,
|
||||
description,
|
||||
icon,
|
||||
banner,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
auth: api.auth,
|
||||
|
|
1
api_tests/src/user.spec.ts
vendored
1
api_tests/src/user.spec.ts
vendored
|
@ -1,3 +1,4 @@
|
|||
jest.setTimeout(120000);
|
||||
import {
|
||||
alpha,
|
||||
beta,
|
||||
|
|
1
docker/federation/run-tests.sh
vendored
1
docker/federation/run-tests.sh
vendored
|
@ -22,6 +22,7 @@ while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8550/api/v1/site')
|
|||
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8560/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8570/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8580/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||
yarn
|
||||
yarn api-test || true
|
||||
popd
|
||||
|
||||
|
|
Loading…
Reference in a new issue