mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-08 09:24:17 +00:00
add api test
This commit is contained in:
parent
3818a4ad8f
commit
ee945fec98
|
@ -27,7 +27,7 @@
|
|||
"eslint": "^9.8.0",
|
||||
"eslint-plugin-prettier": "^5.1.3",
|
||||
"jest": "^29.5.0",
|
||||
"lemmy-js-client": "0.19.5-alpha.1",
|
||||
"lemmy-js-client": "link:../../lemmy-js-client",
|
||||
"prettier": "^3.2.5",
|
||||
"ts-jest": "^29.1.0",
|
||||
"typescript": "^5.5.4",
|
||||
|
|
|
@ -11,7 +11,7 @@ killall -s1 lemmy_server || true
|
|||
popd
|
||||
|
||||
pnpm i
|
||||
pnpm api-test || true
|
||||
pnpm api-test-post || true
|
||||
|
||||
killall -s1 lemmy_server || true
|
||||
killall -s1 pict-rs || true
|
||||
|
|
|
@ -40,7 +40,7 @@ import {
|
|||
createCommunity,
|
||||
} from "./shared";
|
||||
import { PostView } from "lemmy-js-client/dist/types/PostView";
|
||||
import { EditSite, ResolveObject } from "lemmy-js-client";
|
||||
import { CreatePost, EditSite, GetPost, ResolveObject } from "lemmy-js-client";
|
||||
|
||||
let betaCommunity: CommunityView | undefined;
|
||||
|
||||
|
@ -789,3 +789,36 @@ test("Fetch post with redirect", async () => {
|
|||
let gammaPost2 = await gamma.resolveObject(form);
|
||||
expect(gammaPost2.post).toBeDefined();
|
||||
});
|
||||
|
||||
// TODO: havent managed to run this yet, path dependency in package.json isnt working
|
||||
test.only("Schedule post", async () => {
|
||||
let form: CreatePost = {
|
||||
name: randomString(5),
|
||||
community_id: betaCommunity!.community.id,
|
||||
scheduled_time: new Date(new Date().getTime() + 5),
|
||||
};
|
||||
let postRes = await alpha.createPost(form);
|
||||
expect(postRes.post_view.post).toBeDefined();
|
||||
expect(postRes.post_view.counts.score).toBe(1);
|
||||
|
||||
// scheduled post cant be seen by other users
|
||||
let otherUser = await registerUser(alpha, alphaUrl);
|
||||
const getPostForm: GetPost = { id: postRes.post_view.post.id };
|
||||
const otherUserPost1 = await otherUser.getPost(getPostForm);
|
||||
expect(otherUserPost1).toBeUndefined();
|
||||
|
||||
// scheduled post is not federated yet
|
||||
const betaPost1 = resolvePost(beta, postRes.post_view.post);
|
||||
expect(betaPost1).toBeUndefined();
|
||||
|
||||
// wait until scheduled time is over
|
||||
await delay(5000);
|
||||
|
||||
// now post can be seen by other users and be federated
|
||||
const otherUserPost2 = await otherUser.getPost(getPostForm);
|
||||
expect(otherUserPost2.post_view.post.name).toBe(form.name);
|
||||
expect(otherUserPost2.post_view.counts.score).toBe(1);
|
||||
|
||||
const betaPost2 = await resolvePost(beta, postRes.post_view.post);
|
||||
expect(betaPost2.post?.counts.score).toBe(1);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue