]> Untitled Git - lemmy.git/blobdiff - api_tests/src/shared.ts
Isomorphic docker (#1124)
[lemmy.git] / api_tests / src / shared.ts
similarity index 92%
rename from ui/src/api_tests/shared.ts
rename to api_tests/src/shared.ts
index eb4c6da03a5d72631544b742cd0b72c4f8f04a5f..6444b8122ac03ba36ec0a61f8a88bf6a55be566e 100644 (file)
@@ -50,23 +50,23 @@ export interface API {
 }
 
 export let alpha: API = {
-  client: new LemmyHttp('http://localhost:8540/api/v1'),
+  client: new LemmyHttp('http://localhost:8541/api/v1'),
 };
 
 export let beta: API = {
-  client: new LemmyHttp('http://localhost:8550/api/v1'),
+  client: new LemmyHttp('http://localhost:8551/api/v1'),
 };
 
 export let gamma: API = {
-  client: new LemmyHttp('http://localhost:8560/api/v1'),
+  client: new LemmyHttp('http://localhost:8561/api/v1'),
 };
 
 export let delta: API = {
-  client: new LemmyHttp('http://localhost:8570/api/v1'),
+  client: new LemmyHttp('http://localhost:8571/api/v1'),
 };
 
 export let epsilon: API = {
-  client: new LemmyHttp('http://localhost:8580/api/v1'),
+  client: new LemmyHttp('http://localhost:8581/api/v1'),
 };
 
 export async function setupLogins() {
@@ -120,8 +120,12 @@ export async function createPost(
   community_id: number
 ): Promise<PostResponse> {
   let name = 'A jest test post';
+  let body = 'Some body';
+  let url = 'https://google.com/';
   let form: PostForm = {
     name,
+    url,
+    body,
     auth: api.auth,
     community_id,
     nsfw: false,
@@ -232,7 +236,20 @@ export async function searchForBetaCommunity(
   // Make sure lemmy-beta/c/main is cached on lemmy_alpha
   // Use short-hand search url
   let form: SearchForm = {
-    q: '!main@lemmy-beta:8550',
+    q: '!main@lemmy-beta:8551',
+    type_: SearchType.Communities,
+    sort: SortType.TopAll,
+  };
+  return api.client.search(form);
+}
+
+export async function searchForCommunity(
+  api: API,
+  q: string,
+): Promise<SearchResponse> {
+  // Use short-hand search url
+  let form: SearchForm = {
+    q,
     type_: SearchType.Communities,
     sort: SortType.TopAll,
   };
@@ -369,9 +386,15 @@ export async function createCommunity(
   api: API,
   name_: string = randomString(5)
 ): Promise<CommunityResponse> {
+  let description = 'a sample description';
+  let icon = 'https://image.flaticon.com/icons/png/512/35/35896.png';
+  let banner = 'https://image.flaticon.com/icons/png/512/35/35896.png';
   let form: CommunityForm = {
     name: name_,
     title: name_,
+    description,
+    icon,
+    banner,
     category_id: 1,
     nsfw: false,
     auth: api.auth,