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