mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-10 06:54:12 +00:00
Trying to fix API tests.
This commit is contained in:
parent
75a95acf04
commit
434fb53dd1
6 changed files with 39 additions and 43 deletions
|
@ -16,7 +16,7 @@
|
|||
"eslint": "^7.18.0",
|
||||
"eslint-plugin-jane": "^9.0.3",
|
||||
"jest": "^26.6.3",
|
||||
"lemmy-js-client": "0.9.1-rc.1",
|
||||
"lemmy-js-client": "0.10.0-rc.4",
|
||||
"node-fetch": "^2.6.1",
|
||||
"prettier": "^2.1.2",
|
||||
"ts-jest": "^26.4.4",
|
||||
|
|
|
@ -33,9 +33,6 @@ function assertCommunityFederation(
|
|||
);
|
||||
expect(communityOne.creator.actor_id).toBe(communityTwo.creator.actor_id);
|
||||
expect(communityOne.community.nsfw).toBe(communityTwo.community.nsfw);
|
||||
expect(communityOne.community.category_id).toBe(
|
||||
communityTwo.community.category_id
|
||||
);
|
||||
expect(communityOne.community.removed).toBe(communityTwo.community.removed);
|
||||
expect(communityOne.community.deleted).toBe(communityTwo.community.deleted);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ import {
|
|||
getPost,
|
||||
unfollowRemotes,
|
||||
searchForUser,
|
||||
banUserFromSite,
|
||||
banPersonFromSite,
|
||||
searchPostLocal,
|
||||
banUserFromCommunity,
|
||||
banPersonFromCommunity,
|
||||
} from './shared';
|
||||
import { PostView, CommunityView } from 'lemmy-js-client';
|
||||
|
||||
|
@ -305,7 +305,7 @@ test('Enforce site ban for federated user', async () => {
|
|||
expect(alphaUser).toBeDefined();
|
||||
|
||||
// ban alpha from beta site
|
||||
let banAlpha = await banUserFromSite(beta, alphaUser.user.id, true);
|
||||
let banAlpha = await banPersonFromSite(beta, alphaUser.person.id, true);
|
||||
expect(banAlpha.banned).toBe(true);
|
||||
|
||||
// Alpha makes post on beta
|
||||
|
@ -321,7 +321,7 @@ test('Enforce site ban for federated user', async () => {
|
|||
expect(betaPost).toBeUndefined();
|
||||
|
||||
// Unban alpha
|
||||
let unBanAlpha = await banUserFromSite(beta, alphaUser.user.id, false);
|
||||
let unBanAlpha = await banPersonFromSite(beta, alphaUser.person.id, false);
|
||||
expect(unBanAlpha.banned).toBe(false);
|
||||
});
|
||||
|
||||
|
@ -332,8 +332,8 @@ test('Enforce community ban for federated user', async () => {
|
|||
expect(alphaUser).toBeDefined();
|
||||
|
||||
// ban alpha from beta site
|
||||
await banUserFromCommunity(beta, alphaUser.user.id, 2, false);
|
||||
let banAlpha = await banUserFromCommunity(beta, alphaUser.user.id, 2, true);
|
||||
await banPersonFromCommunity(beta, alphaUser.person.id, 2, false);
|
||||
let banAlpha = await banPersonFromCommunity(beta, alphaUser.person.id, 2, true);
|
||||
expect(banAlpha.banned).toBe(true);
|
||||
|
||||
// Alpha makes post on beta
|
||||
|
@ -349,9 +349,9 @@ test('Enforce community ban for federated user', async () => {
|
|||
expect(betaPost).toBeUndefined();
|
||||
|
||||
// Unban alpha
|
||||
let unBanAlpha = await banUserFromCommunity(
|
||||
let unBanAlpha = await banPersonFromCommunity(
|
||||
beta,
|
||||
alphaUser.user.id,
|
||||
alphaUser.person.id,
|
||||
2,
|
||||
false
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ import {
|
|||
CreateCommunity,
|
||||
DeleteCommunity,
|
||||
RemoveCommunity,
|
||||
GetUserMentions,
|
||||
GetPersonMentions,
|
||||
CreateCommentLike,
|
||||
CreatePostLike,
|
||||
EditPrivateMessage,
|
||||
|
@ -36,15 +36,15 @@ import {
|
|||
GetPost,
|
||||
PrivateMessageResponse,
|
||||
PrivateMessagesResponse,
|
||||
GetUserMentionsResponse,
|
||||
GetPersonMentionsResponse,
|
||||
SaveUserSettings,
|
||||
SortType,
|
||||
ListingType,
|
||||
GetSiteResponse,
|
||||
SearchType,
|
||||
LemmyHttp,
|
||||
BanUserResponse,
|
||||
BanUser,
|
||||
BanPersonResponse,
|
||||
BanPerson,
|
||||
BanFromCommunity,
|
||||
BanFromCommunityResponse,
|
||||
Post,
|
||||
|
@ -289,32 +289,32 @@ export async function searchForUser(
|
|||
return api.client.search(form);
|
||||
}
|
||||
|
||||
export async function banUserFromSite(
|
||||
export async function banPersonFromSite(
|
||||
api: API,
|
||||
user_id: number,
|
||||
person_id: number,
|
||||
ban: boolean
|
||||
): Promise<BanUserResponse> {
|
||||
): Promise<BanPersonResponse> {
|
||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||
// Use short-hand search url
|
||||
let form: BanUser = {
|
||||
user_id,
|
||||
let form: BanPerson = {
|
||||
person_id,
|
||||
ban,
|
||||
remove_data: false,
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.banUser(form);
|
||||
return api.client.banPerson(form);
|
||||
}
|
||||
|
||||
export async function banUserFromCommunity(
|
||||
export async function banPersonFromCommunity(
|
||||
api: API,
|
||||
user_id: number,
|
||||
person_id: number,
|
||||
community_id: number,
|
||||
ban: boolean
|
||||
): Promise<BanFromCommunityResponse> {
|
||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||
// Use short-hand search url
|
||||
let form: BanFromCommunity = {
|
||||
user_id,
|
||||
person_id,
|
||||
community_id,
|
||||
remove_data: false,
|
||||
ban,
|
||||
|
@ -413,13 +413,13 @@ export async function removeComment(
|
|||
return api.client.removeComment(form);
|
||||
}
|
||||
|
||||
export async function getMentions(api: API): Promise<GetUserMentionsResponse> {
|
||||
let form: GetUserMentions = {
|
||||
export async function getMentions(api: API): Promise<GetPersonMentionsResponse> {
|
||||
let form: GetPersonMentions = {
|
||||
sort: SortType.New,
|
||||
unread_only: false,
|
||||
auth: api.auth,
|
||||
};
|
||||
return api.client.getUserMentions(form);
|
||||
return api.client.getPersonMentions(form);
|
||||
}
|
||||
|
||||
export async function likeComment(
|
||||
|
@ -448,7 +448,6 @@ export async function createCommunity(
|
|||
description,
|
||||
icon,
|
||||
banner,
|
||||
category_id: 1,
|
||||
nsfw: false,
|
||||
auth: api.auth,
|
||||
};
|
||||
|
|
|
@ -8,7 +8,7 @@ import {
|
|||
getSite,
|
||||
} from './shared';
|
||||
import {
|
||||
UserViewSafe,
|
||||
PersonViewSafe,
|
||||
SaveUserSettings,
|
||||
SortType,
|
||||
ListingType,
|
||||
|
@ -17,14 +17,14 @@ import {
|
|||
let auth: string;
|
||||
let apShortname: string;
|
||||
|
||||
function assertUserFederation(userOne: UserViewSafe, userTwo: UserViewSafe) {
|
||||
expect(userOne.user.name).toBe(userTwo.user.name);
|
||||
expect(userOne.user.preferred_username).toBe(userTwo.user.preferred_username);
|
||||
expect(userOne.user.bio).toBe(userTwo.user.bio);
|
||||
expect(userOne.user.actor_id).toBe(userTwo.user.actor_id);
|
||||
expect(userOne.user.avatar).toBe(userTwo.user.avatar);
|
||||
expect(userOne.user.banner).toBe(userTwo.user.banner);
|
||||
expect(userOne.user.published).toBe(userTwo.user.published);
|
||||
function assertUserFederation(userOne: PersonViewSafe, userTwo: PersonViewSafe) {
|
||||
expect(userOne.person.name).toBe(userTwo.person.name);
|
||||
expect(userOne.person.preferred_username).toBe(userTwo.person.preferred_username);
|
||||
expect(userOne.person.bio).toBe(userTwo.person.bio);
|
||||
expect(userOne.person.actor_id).toBe(userTwo.person.actor_id);
|
||||
expect(userOne.person.avatar).toBe(userTwo.person.avatar);
|
||||
expect(userOne.person.banner).toBe(userTwo.person.banner);
|
||||
expect(userOne.person.published).toBe(userTwo.person.published);
|
||||
}
|
||||
|
||||
test('Create user', async () => {
|
||||
|
@ -34,7 +34,7 @@ test('Create user', async () => {
|
|||
|
||||
let site = await getSite(alpha, auth);
|
||||
expect(site.my_user).toBeDefined();
|
||||
apShortname = `@${site.my_user.name}@lemmy-alpha:8541`;
|
||||
apShortname = `@${site.my_user.person.name}@lemmy-alpha:8541`;
|
||||
});
|
||||
|
||||
test('Set some user settings, check that they are federated', async () => {
|
||||
|
|
|
@ -3233,10 +3233,10 @@ language-tags@^1.0.5:
|
|||
dependencies:
|
||||
language-subtag-registry "~0.3.2"
|
||||
|
||||
lemmy-js-client@0.9.1-rc.1:
|
||||
version "0.9.1-rc.1"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.9.1-rc.1.tgz#afe3cb0d4852f849dd087a4756a3771bc920a907"
|
||||
integrity sha512-aVvo4IeJvIPUvypipk4GnyLB6nVQVLfB0arYrMkVV4L7zrZ/0pGtpkMDLaOAj/KpA6O0u9eLmaou5RberZQolA==
|
||||
lemmy-js-client@0.10.0-rc.4:
|
||||
version "0.10.0-rc.4"
|
||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.10.0-rc.4.tgz#ac6fe6940fc5f73260ddb166ce0ef3c0520901fc"
|
||||
integrity sha512-yJPnvGaWneOOwjKEqb4qXtQk+4DbRgO+hEzSin2GgUgnxluY43gemwiCPt6EnV+j4ueKoi0+QORVg2RuRC2PaQ==
|
||||
|
||||
leven@^3.1.0:
|
||||
version "3.1.0"
|
||||
|
|
Loading…
Reference in a new issue