mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-28 23:31:21 +00:00
fixes
This commit is contained in:
parent
ff2a7c5136
commit
6a2629e997
5 changed files with 18 additions and 20 deletions
|
@ -25,17 +25,16 @@ import {
|
||||||
getComments,
|
getComments,
|
||||||
createComment,
|
createComment,
|
||||||
getCommunityByName,
|
getCommunityByName,
|
||||||
blockInstance,
|
|
||||||
waitUntil,
|
waitUntil,
|
||||||
alphaUrl,
|
alphaUrl,
|
||||||
delta,
|
delta,
|
||||||
betaAllowedInstances,
|
|
||||||
searchPostLocal,
|
searchPostLocal,
|
||||||
longDelay,
|
longDelay,
|
||||||
editCommunity,
|
editCommunity,
|
||||||
unfollows,
|
unfollows,
|
||||||
allowInstance,
|
userBlockInstance,
|
||||||
} from "./shared";
|
} from "./shared";
|
||||||
|
import { AdminAllowInstanceParams } from "lemmy-js-client/dist/types/AdminAllowInstanceParams";
|
||||||
import { EditCommunity, EditSite } from "lemmy-js-client";
|
import { EditCommunity, EditSite } from "lemmy-js-client";
|
||||||
|
|
||||||
beforeAll(setupLogins);
|
beforeAll(setupLogins);
|
||||||
|
@ -364,7 +363,7 @@ test("User blocks instance, communities are hidden", async () => {
|
||||||
expect(listing_ids).toContain(postRes.post_view.post.ap_id);
|
expect(listing_ids).toContain(postRes.post_view.post.ap_id);
|
||||||
|
|
||||||
// block the beta instance
|
// block the beta instance
|
||||||
await blockInstance(alpha, alphaPost.community.instance_id, true);
|
await userBlockInstance(alpha, alphaPost.community.instance_id, true);
|
||||||
|
|
||||||
// after blocking, post should not be in listing
|
// after blocking, post should not be in listing
|
||||||
let listing2 = await getPosts(alpha, "All");
|
let listing2 = await getPosts(alpha, "All");
|
||||||
|
@ -372,7 +371,7 @@ test("User blocks instance, communities are hidden", async () => {
|
||||||
expect(listing_ids2.indexOf(postRes.post_view.post.ap_id)).toBe(-1);
|
expect(listing_ids2.indexOf(postRes.post_view.post.ap_id)).toBe(-1);
|
||||||
|
|
||||||
// unblock instance again
|
// unblock instance again
|
||||||
await blockInstance(alpha, alphaPost.community.instance_id, false);
|
await userBlockInstance(alpha, alphaPost.community.instance_id, false);
|
||||||
|
|
||||||
// post should be included in listing
|
// post should be included in listing
|
||||||
let listing3 = await getPosts(alpha, "All");
|
let listing3 = await getPosts(alpha, "All");
|
||||||
|
|
|
@ -40,6 +40,7 @@ import {
|
||||||
createCommunity,
|
createCommunity,
|
||||||
} from "./shared";
|
} from "./shared";
|
||||||
import { PostView } from "lemmy-js-client/dist/types/PostView";
|
import { PostView } from "lemmy-js-client/dist/types/PostView";
|
||||||
|
import { AdminBlockInstanceParams} from "lemmy-js-client/dist/types/AdminBlockInstanceParams";
|
||||||
import { EditSite, ResolveObject } from "lemmy-js-client";
|
import { EditSite, ResolveObject } from "lemmy-js-client";
|
||||||
|
|
||||||
let betaCommunity: CommunityView | undefined;
|
let betaCommunity: CommunityView | undefined;
|
||||||
|
@ -87,12 +88,13 @@ async function assertPostFederation(
|
||||||
}
|
}
|
||||||
|
|
||||||
test("Create a post", async () => {
|
test("Create a post", async () => {
|
||||||
// Setup some allowlists and blocklists
|
// Block alpha
|
||||||
const editSiteForm: EditSite = {};
|
var block_instance_params: AdminBlockInstanceParams = {
|
||||||
|
instance: "lemmy-alpha",
|
||||||
editSiteForm.allowed_instances = [];
|
block: true,
|
||||||
editSiteForm.blocked_instances = ["lemmy-alpha"];
|
reason: undefined,
|
||||||
await epsilon.editSite(editSiteForm);
|
};
|
||||||
|
await epsilon.adminBlockInstance(block_instance_params);
|
||||||
|
|
||||||
if (!betaCommunity) {
|
if (!betaCommunity) {
|
||||||
throw "Missing beta community";
|
throw "Missing beta community";
|
||||||
|
@ -132,11 +134,9 @@ test("Create a post", async () => {
|
||||||
resolvePost(epsilon, postRes.post_view.post),
|
resolvePost(epsilon, postRes.post_view.post),
|
||||||
).rejects.toStrictEqual(Error("not_found"));
|
).rejects.toStrictEqual(Error("not_found"));
|
||||||
|
|
||||||
// remove added allow/blocklists
|
// remove blocked instance
|
||||||
editSiteForm.allowed_instances = [];
|
block_instance_params.block= false;
|
||||||
editSiteForm.blocked_instances = [];
|
await epsilon.adminBlockInstance(block_instance_params);
|
||||||
await delta.editSite(editSiteForm);
|
|
||||||
await epsilon.editSite(editSiteForm);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Create a post in a non-existent community", async () => {
|
test("Create a post in a non-existent community", async () => {
|
||||||
|
|
|
@ -184,7 +184,6 @@ export async function setupLogins() {
|
||||||
await allowInstance(gamma, "lemmy-delta");
|
await allowInstance(gamma, "lemmy-delta");
|
||||||
await allowInstance(gamma, "lemmy-epsilon");
|
await allowInstance(gamma, "lemmy-epsilon");
|
||||||
|
|
||||||
// Setup delta allowed instance
|
|
||||||
await allowInstance(delta, "lemmy-beta");
|
await allowInstance(delta, "lemmy-beta");
|
||||||
|
|
||||||
// Create the main alpha/beta communities
|
// Create the main alpha/beta communities
|
||||||
|
@ -202,7 +201,7 @@ export async function setupLogins() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function allowInstance(api: LemmyHttp, instance: string) {
|
async function allowInstance(api: LemmyHttp, instance: string) {
|
||||||
const params: AdminAllowInstanceParams = {
|
const params: AdminAllowInstanceParams = {
|
||||||
instance,
|
instance,
|
||||||
allow: true,
|
allow: true,
|
||||||
|
|
|
@ -32,7 +32,7 @@ pub async fn admin_allow_instance(
|
||||||
.await?
|
.await?
|
||||||
.id;
|
.id;
|
||||||
let form = FederationAllowListForm {
|
let form = FederationAllowListForm {
|
||||||
instance_id: instance_id,
|
instance_id,
|
||||||
updated: None,
|
updated: None,
|
||||||
};
|
};
|
||||||
if data.allow {
|
if data.allow {
|
||||||
|
|
|
@ -44,7 +44,7 @@ pub async fn admin_block_instance(
|
||||||
}
|
}
|
||||||
|
|
||||||
let mod_log_form = AdminBlockInstanceForm {
|
let mod_log_form = AdminBlockInstanceForm {
|
||||||
instance_id: instance_id,
|
instance_id,
|
||||||
admin_person_id: local_user_view.person.id,
|
admin_person_id: local_user_view.person.id,
|
||||||
blocked: data.block,
|
blocked: data.block,
|
||||||
reason: data.reason.clone(),
|
reason: data.reason.clone(),
|
||||||
|
|
Loading…
Reference in a new issue