api tests

This commit is contained in:
Felix Ableitner 2024-09-23 15:14:27 +02:00
parent 525cb710b1
commit 00e557f606
5 changed files with 16 additions and 18 deletions

View file

@ -27,7 +27,7 @@
"eslint": "^9.8.0",
"eslint-plugin-prettier": "^5.1.3",
"jest": "^29.5.0",
"lemmy-js-client": "0.20.0-alpha.4",
"lemmy-js-client": "0.20.0-alpha.11",
"prettier": "^3.2.5",
"ts-jest": "^29.1.0",
"typescript": "^5.5.4",

View file

@ -30,8 +30,8 @@ importers:
specifier: ^29.5.0
version: 29.7.0(@types/node@22.3.0)
lemmy-js-client:
specifier: 0.20.0-alpha.4
version: 0.20.0-alpha.4
specifier: 0.20.0-alpha.11
version: 0.20.0-alpha.11
prettier:
specifier: ^3.2.5
version: 3.3.3
@ -1175,8 +1175,8 @@ packages:
resolution: {integrity: sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==}
engines: {node: '>=6'}
lemmy-js-client@0.20.0-alpha.4:
resolution: {integrity: sha512-MuVE8u/IFz59ks2vxOUXMRU8x6SIz3Keu4zRhmhNt+n+gI25JAggsTDrtxVCBtrqBhFEe+a3PdXdwm+fXbs0Dw==}
lemmy-js-client@0.20.0-alpha.11:
resolution: {integrity: sha512-iRSG4xHMjPDIreQqVIoJ5JrMY71uk07G0Zbgyf068xKbib22J3+i1x/XgCTs6tiHlqTnw1Ig/KRq7p7qJoA4uw==}
leven@3.1.0:
resolution: {integrity: sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==}
@ -3107,7 +3107,7 @@ snapshots:
kleur@3.0.3: {}
lemmy-js-client@0.20.0-alpha.4: {}
lemmy-js-client@0.20.0-alpha.11: {}
leven@3.1.0: {}

View file

@ -92,7 +92,7 @@ test("Create a comment", async () => {
test("Create a comment in a non-existent post", async () => {
await expect(createComment(alpha, -1)).rejects.toStrictEqual(
Error("couldnt_find_post"),
Error("not_found"),
);
});
@ -143,7 +143,7 @@ test("Delete a comment", async () => {
await waitUntil(
() =>
resolveComment(gamma, commentRes.comment_view.comment).catch(e => e),
r => r.message !== "couldnt_find_object",
r => r.message !== "not_found",
)
).comment;
if (!gammaComment) {
@ -161,13 +161,13 @@ test("Delete a comment", async () => {
// Make sure that comment is undefined on beta
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment).catch(e => e),
e => e.message == "couldnt_find_object",
e => e.message == "not_found",
);
// Make sure that comment is undefined on gamma after delete
await waitUntil(
() => resolveComment(gamma, commentRes.comment_view.comment).catch(e => e),
e => e.message === "couldnt_find_object",
e => e.message === "not_found",
);
// Test undeleting the comment
@ -182,7 +182,7 @@ test("Delete a comment", async () => {
let betaComment2 = (
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment).catch(e => e),
e => e.message !== "couldnt_find_object",
e => e.message !== "not_found",
)
).comment;
expect(betaComment2?.comment.deleted).toBe(false);

View file

@ -527,12 +527,12 @@ test("Content in local-only community doesn't federate", async () => {
// cant resolve the community from another instance
await expect(
resolveCommunity(beta, communityRes.actor_id),
).rejects.toStrictEqual(Error("couldnt_find_object"));
).rejects.toStrictEqual(Error("not_found"));
// create a post, also cant resolve it
let postRes = await createPost(alpha, communityRes.id);
await expect(resolvePost(beta, postRes.post_view.post)).rejects.toStrictEqual(
Error("couldnt_find_object"),
Error("not_found"),
);
});

View file

@ -125,12 +125,12 @@ test("Create a post", async () => {
// Delta only follows beta, so it should not see an alpha ap_id
await expect(
resolvePost(delta, postRes.post_view.post),
).rejects.toStrictEqual(Error("couldnt_find_object"));
).rejects.toStrictEqual(Error("not_found"));
// Epsilon has alpha blocked, it should not see the alpha post
await expect(
resolvePost(epsilon, postRes.post_view.post),
).rejects.toStrictEqual(Error("couldnt_find_object"));
).rejects.toStrictEqual(Error("not_found"));
// remove added allow/blocklists
editSiteForm.allowed_instances = [];
@ -140,9 +140,7 @@ test("Create a post", async () => {
});
test("Create a post in a non-existent community", async () => {
await expect(createPost(alpha, -2)).rejects.toStrictEqual(
Error("couldnt_find_community"),
);
await expect(createPost(alpha, -2)).rejects.toStrictEqual(Error("not_found"));
});
test("Unlike a post", async () => {