]> Untitled Git - lemmy.git/commitdiff
Trying to fix API tests.
authorDessalines <tyhou13@gmx.com>
Fri, 12 Mar 2021 19:09:03 +0000 (14:09 -0500)
committerDessalines <tyhou13@gmx.com>
Fri, 12 Mar 2021 19:09:03 +0000 (14:09 -0500)
api_tests/package.json
api_tests/src/community.spec.ts
api_tests/src/post.spec.ts
api_tests/src/shared.ts
api_tests/src/user.spec.ts
api_tests/yarn.lock

index e2c4f37a0e4000145e0bad2cdd9c357c66da3ea8..d4232ed5360c405e60af1316ac8cc10a57a385aa 100644 (file)
@@ -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",
index 25d8109c3694e13a66b0a1e16fe24ae28914b1bf..7be6f4c59f142a2095d0ab784d3605a8dfebaa51 100644 (file)
@@ -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);
 }
index 01befa60cff84a15408986655112183c2c103791..a79ee198b4be7abacca68075dd67c4ea0c8ebaf2 100644 (file)
@@ -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
   );
index 0c12d29c0f8cfae82b761dbbe006585317dda353..c11fa3b0e96d5055ef2b25552c58ded649aa3ea5 100644 (file)
@@ -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,
   };
index 4352aa4232a980169e4743429dad5079680e07b2..a10876cf5e435ad346b2dd45390a14b931189244 100644 (file)
@@ -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 () => {
index 8e29aa041725b9902bcf79a2646a1f4104e01631..a6d1be5a34f9489944625e2f2aa78c6b1bc10905 100644 (file)
@@ -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"