mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-16 09:24:00 +00:00
Fixing API tests.
This commit is contained in:
parent
48f5a2ee5e
commit
ed9b66541e
8 changed files with 26 additions and 24 deletions
|
@ -16,7 +16,7 @@
|
||||||
"eslint": "^7.30.0",
|
"eslint": "^7.30.0",
|
||||||
"eslint-plugin-jane": "^9.0.3",
|
"eslint-plugin-jane": "^9.0.3",
|
||||||
"jest": "^27.0.6",
|
"jest": "^27.0.6",
|
||||||
"lemmy-js-client": "0.16.0-rc.1",
|
"lemmy-js-client": "0.17.0-rc.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"prettier": "^2.3.2",
|
"prettier": "^2.3.2",
|
||||||
"ts-jest": "^27.0.3",
|
"ts-jest": "^27.0.3",
|
||||||
|
|
|
@ -329,12 +329,12 @@ test('A and G subscribe to B (center) A posts, G mentions B, it gets announced t
|
||||||
test('Check that activity from another instance is sent to third instance', async () => {
|
test('Check that activity from another instance is sent to third instance', async () => {
|
||||||
// Alpha and gamma users follow beta community
|
// Alpha and gamma users follow beta community
|
||||||
let alphaFollow = await followBeta(alpha);
|
let alphaFollow = await followBeta(alpha);
|
||||||
expect(alphaFollow.community_view.community.local).toBe(false);
|
expect(alphaFollow.community_follower_view.community.local).toBe(false);
|
||||||
expect(alphaFollow.community_view.community.name).toBe('main');
|
expect(alphaFollow.community_follower_view.community.name).toBe('main');
|
||||||
|
|
||||||
let gammaFollow = await followBeta(gamma);
|
let gammaFollow = await followBeta(gamma);
|
||||||
expect(gammaFollow.community_view.community.local).toBe(false);
|
expect(gammaFollow.community_follower_view.community.local).toBe(false);
|
||||||
expect(gammaFollow.community_view.community.name).toBe('main');
|
expect(gammaFollow.community_follower_view.community.name).toBe('main');
|
||||||
|
|
||||||
// Create a post on beta
|
// Create a post on beta
|
||||||
let betaPost = await createPost(beta, 2);
|
let betaPost = await createPost(beta, 2);
|
||||||
|
@ -407,8 +407,8 @@ test('Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedde
|
||||||
|
|
||||||
// Follow beta again
|
// Follow beta again
|
||||||
let follow = await followBeta(alpha);
|
let follow = await followBeta(alpha);
|
||||||
expect(follow.community_view.community.local).toBe(false);
|
expect(follow.community_follower_view.community.local).toBe(false);
|
||||||
expect(follow.community_view.community.name).toBe('main');
|
expect(follow.community_follower_view.community.name).toBe('main');
|
||||||
|
|
||||||
// An update to the child comment on beta, should push the post, parent, and child to alpha now
|
// An update to the child comment on beta, should push the post, parent, and child to alpha now
|
||||||
let updatedCommentContent = 'An update child comment from beta';
|
let updatedCommentContent = 'An update child comment from beta';
|
||||||
|
|
|
@ -67,7 +67,7 @@ test('Delete community', async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community_view.community.local).toBe(false);
|
expect(follow.community_follower_view.community.local).toBe(false);
|
||||||
|
|
||||||
let deleteCommunityRes = await deleteCommunity(
|
let deleteCommunityRes = await deleteCommunity(
|
||||||
beta,
|
beta,
|
||||||
|
@ -118,7 +118,7 @@ test('Remove community', async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community_view.community.local).toBe(false);
|
expect(follow.community_follower_view.community.local).toBe(false);
|
||||||
|
|
||||||
let removeCommunityRes = await removeCommunity(
|
let removeCommunityRes = await removeCommunity(
|
||||||
beta,
|
beta,
|
||||||
|
|
|
@ -25,8 +25,9 @@ test('Follow federated community', async () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Make sure the follow response went through
|
// Make sure the follow response went through
|
||||||
expect(follow.community_view.community.local).toBe(false);
|
expect(follow.community_follower_view.community.local).toBe(false);
|
||||||
expect(follow.community_view.community.name).toBe('main');
|
expect(follow.community_follower_view.community.name).toBe('main');
|
||||||
|
expect(follow.community_follower_view.pending).toBe(true);
|
||||||
|
|
||||||
// Check it from local
|
// Check it from local
|
||||||
let site = await getSite(alpha);
|
let site = await getSite(alpha);
|
||||||
|
@ -37,7 +38,7 @@ test('Follow federated community', async () => {
|
||||||
|
|
||||||
// Test an unfollow
|
// Test an unfollow
|
||||||
let unfollow = await followCommunity(alpha, false, remoteCommunityId);
|
let unfollow = await followCommunity(alpha, false, remoteCommunityId);
|
||||||
expect(unfollow.community_view.community.local).toBe(false);
|
expect(unfollow.community_follower_view.community.local).toBe(false);
|
||||||
|
|
||||||
// Make sure you are unsubbed locally
|
// Make sure you are unsubbed locally
|
||||||
let siteUnfollowCheck = await getSite(alpha);
|
let siteUnfollowCheck = await getSite(alpha);
|
||||||
|
|
|
@ -261,7 +261,7 @@ test('Remove a post from admin and community on same instance', async () => {
|
||||||
expect(removePostRes.post_view.post.removed).toBe(true);
|
expect(removePostRes.post_view.post.removed).toBe(true);
|
||||||
|
|
||||||
// Make sure lemmy alpha sees post is removed
|
// Make sure lemmy alpha sees post is removed
|
||||||
let alphaPost = await getPost(alpha, postRes.post_view.post.id);
|
// let alphaPost = await getPost(alpha, postRes.post_view.post.id);
|
||||||
// expect(alphaPost.post_view.post.removed).toBe(true); // TODO this shouldn't be commented
|
// expect(alphaPost.post_view.post.removed).toBe(true); // TODO this shouldn't be commented
|
||||||
// assertPostFederation(alphaPost.post_view, removePostRes.post_view);
|
// assertPostFederation(alphaPost.post_view, removePostRes.post_view);
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import {
|
||||||
PostResponse,
|
PostResponse,
|
||||||
SearchResponse,
|
SearchResponse,
|
||||||
FollowCommunity,
|
FollowCommunity,
|
||||||
|
FollowCommunityResponse,
|
||||||
CommunityResponse,
|
CommunityResponse,
|
||||||
GetPostResponse,
|
GetPostResponse,
|
||||||
Register,
|
Register,
|
||||||
|
@ -298,7 +299,7 @@ export async function banPersonFromSite(
|
||||||
api: API,
|
api: API,
|
||||||
person_id: number,
|
person_id: number,
|
||||||
ban: boolean,
|
ban: boolean,
|
||||||
remove_data: boolean,
|
remove_data: boolean
|
||||||
): Promise<BanPersonResponse> {
|
): Promise<BanPersonResponse> {
|
||||||
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
// Make sure lemmy-beta/c/main is cached on lemmy_alpha
|
||||||
let form: BanPerson = {
|
let form: BanPerson = {
|
||||||
|
@ -331,7 +332,7 @@ export async function followCommunity(
|
||||||
api: API,
|
api: API,
|
||||||
follow: boolean,
|
follow: boolean,
|
||||||
community_id: number
|
community_id: number
|
||||||
): Promise<CommunityResponse> {
|
): Promise<FollowCommunityResponse> {
|
||||||
let form: FollowCommunity = {
|
let form: FollowCommunity = {
|
||||||
community_id,
|
community_id,
|
||||||
follow,
|
follow,
|
||||||
|
@ -558,7 +559,7 @@ export async function saveUserSettings(
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteUser(
|
export async function deleteUser(
|
||||||
api: API,
|
api: API
|
||||||
): Promise<DeleteAccountResponse> {
|
): Promise<DeleteAccountResponse> {
|
||||||
let form: DeleteAccount = {
|
let form: DeleteAccount = {
|
||||||
auth: api.auth,
|
auth: api.auth,
|
||||||
|
@ -602,7 +603,7 @@ export async function unfollowRemotes(
|
||||||
return siteRes;
|
return siteRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function followBeta(api: API): Promise<CommunityResponse> {
|
export async function followBeta(api: API): Promise<FollowCommunityResponse> {
|
||||||
let betaCommunity = (await resolveBetaCommunity(api)).community;
|
let betaCommunity = (await resolveBetaCommunity(api)).community;
|
||||||
if (betaCommunity) {
|
if (betaCommunity) {
|
||||||
let follow = await followCommunity(api, true, betaCommunity.community.id);
|
let follow = await followCommunity(api, true, betaCommunity.community.id);
|
||||||
|
@ -613,7 +614,7 @@ export async function followBeta(api: API): Promise<CommunityResponse> {
|
||||||
export async function reportPost(
|
export async function reportPost(
|
||||||
api: API,
|
api: API,
|
||||||
post_id: number,
|
post_id: number,
|
||||||
reason: string,
|
reason: string
|
||||||
): Promise<PostReportResponse> {
|
): Promise<PostReportResponse> {
|
||||||
let form: CreatePostReport = {
|
let form: CreatePostReport = {
|
||||||
post_id,
|
post_id,
|
||||||
|
@ -633,7 +634,7 @@ export async function listPostReports(api: API): Promise<ListPostReportsResponse
|
||||||
export async function reportComment(
|
export async function reportComment(
|
||||||
api: API,
|
api: API,
|
||||||
comment_id: number,
|
comment_id: number,
|
||||||
reason: string,
|
reason: string
|
||||||
): Promise<CommentReportResponse> {
|
): Promise<CommentReportResponse> {
|
||||||
let form: CreateCommentReport = {
|
let form: CreateCommentReport = {
|
||||||
comment_id,
|
comment_id,
|
||||||
|
|
|
@ -7,7 +7,7 @@ import {
|
||||||
saveUserSettings,
|
saveUserSettings,
|
||||||
getSite,
|
getSite,
|
||||||
createPost,
|
createPost,
|
||||||
gamma,
|
// gamma,
|
||||||
resolveCommunity,
|
resolveCommunity,
|
||||||
createComment,
|
createComment,
|
||||||
resolveBetaCommunity,
|
resolveBetaCommunity,
|
||||||
|
|
|
@ -3076,10 +3076,10 @@ language-tags@^1.0.5:
|
||||||
dependencies:
|
dependencies:
|
||||||
language-subtag-registry "~0.3.2"
|
language-subtag-registry "~0.3.2"
|
||||||
|
|
||||||
lemmy-js-client@0.16.0-rc.1:
|
lemmy-js-client@0.17.0-rc.1:
|
||||||
version "0.16.0-rc.1"
|
version "0.17.0-rc.1"
|
||||||
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.16.0-rc.1.tgz#14c4a526abf4b171c8afe4efbe2a62dcaf6a6f17"
|
resolved "https://registry.yarnpkg.com/lemmy-js-client/-/lemmy-js-client-0.17.0-rc.1.tgz#153fae5a06f047fe59a00847589b80736a30277b"
|
||||||
integrity sha512-0hR/gHHsokp46whIHGMBQO2zBKWM7bT6mwKNMZxPvyJo+YW9EbKTO5edjF5E4v8nf3FuIE+gFtm5NFAjCaeWJg==
|
integrity sha512-dHkL5eXHTSxchyxn8yXj33iuh1UQ8OmebUJY6PstQPxL8ZOFBKlVEJs8UlXBJgeDkDTc2OObNpUd2uFqhEt6jg==
|
||||||
|
|
||||||
leven@^3.1.0:
|
leven@^3.1.0:
|
||||||
version "3.1.0"
|
version "3.1.0"
|
||||||
|
|
Loading…
Reference in a new issue