Merge branch 'main' into rate_limit_algorithm_desc

This commit is contained in:
Nutomic 2022-03-23 14:33:03 +00:00 committed by GitHub
commit 0d0772a48a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 19 deletions

View file

@ -23,6 +23,7 @@ import {
listCommentReports, listCommentReports,
randomString, randomString,
API, API,
unfollows,
} from './shared'; } from './shared';
import { CommentView } from 'lemmy-js-client'; import { CommentView } from 'lemmy-js-client';
@ -32,6 +33,7 @@ let postRes: PostResponse;
beforeAll(async () => { beforeAll(async () => {
await setupLogins(); await setupLogins();
await unfollows();
await followBeta(alpha); await followBeta(alpha);
await followBeta(gamma); await followBeta(gamma);
let betaCommunity = (await resolveBetaCommunity(alpha)).community; let betaCommunity = (await resolveBetaCommunity(alpha)).community;
@ -42,8 +44,7 @@ beforeAll(async () => {
}); });
afterAll(async () => { afterAll(async () => {
await unfollowRemotes(alpha); await unfollows();
await unfollowRemotes(gamma);
}); });
function assertCommentFederation( function assertCommentFederation(

View file

@ -29,7 +29,8 @@ import {
randomString, randomString,
registerUser, registerUser,
API, API,
getSite getSite,
unfollows
} from './shared'; } from './shared';
import { PostView, CommunityView } from 'lemmy-js-client'; import { PostView, CommunityView } from 'lemmy-js-client';
@ -46,13 +47,6 @@ afterAll(async () => {
await unfollows(); await unfollows();
}); });
async function unfollows() {
await unfollowRemotes(alpha);
await unfollowRemotes(gamma);
await unfollowRemotes(delta);
await unfollowRemotes(epsilon);
}
function assertPostFederation(postOne: PostView, postTwo: PostView) { function assertPostFederation(postOne: PostView, postTwo: PostView) {
expect(postOne.post.ap_id).toBe(postTwo.post.ap_id); expect(postOne.post.ap_id).toBe(postTwo.post.ap_id);
expect(postOne.post.name).toBe(postTwo.post.name); expect(postOne.post.name).toBe(postTwo.post.name);
@ -291,14 +285,6 @@ test('Search for a post', async () => {
expect(betaPost.post.name).toBeDefined(); expect(betaPost.post.name).toBeDefined();
}); });
test('A and G subscribe to B (center) A posts, it gets announced to G', async () => {
let postRes = await createPost(alpha, betaCommunity.community.id);
expect(postRes.post_view.post).toBeDefined();
let betaPost = (await resolvePost(gamma, postRes.post_view.post)).post;
expect(betaPost.post.name).toBeDefined();
});
test('Enforce site ban for federated user', async () => { test('Enforce site ban for federated user', async () => {
// create a test user // create a test user
let alphaUserJwt = await registerUser(alpha); let alphaUserJwt = await registerUser(alpha);
@ -384,6 +370,15 @@ test('Enforce community ban for federated user', async () => {
expect(searchBeta2.posts[0]).toBeDefined(); expect(searchBeta2.posts[0]).toBeDefined();
}); });
test('A and G subscribe to B (center) A posts, it gets announced to G', async () => {
let postRes = await createPost(alpha, betaCommunity.community.id);
expect(postRes.post_view.post).toBeDefined();
let betaPost = (await resolvePost(gamma, postRes.post_view.post)).post;
expect(betaPost.post.name).toBeDefined();
});
test('Report a post', async () => { test('Report a post', async () => {
let betaCommunity = (await resolveBetaCommunity(beta)).community; let betaCommunity = (await resolveBetaCommunity(beta)).community;
let postRes = await createPost(beta, betaCommunity.community.id); let postRes = await createPost(beta, betaCommunity.community.id);
@ -400,4 +395,4 @@ test('Report a post', async () => {
expect(betaReport.original_post_url).toBe(alphaReport.original_post_url); expect(betaReport.original_post_url).toBe(alphaReport.original_post_url);
expect(betaReport.original_post_body).toBe(alphaReport.original_post_body); expect(betaReport.original_post_body).toBe(alphaReport.original_post_body);
expect(betaReport.reason).toBe(alphaReport.reason); expect(betaReport.reason).toBe(alphaReport.reason);
}); });

View file

@ -653,3 +653,10 @@ export function randomString(length: number): string {
} }
return result; return result;
} }
export async function unfollows() {
await unfollowRemotes(alpha);
await unfollowRemotes(gamma);
await unfollowRemotes(delta);
await unfollowRemotes(epsilon);
}