lemmy/api_tests/src/comment.spec.ts

720 lines
25 KiB
TypeScript
Raw Normal View History

2020-10-01 13:32:01 +00:00
jest.setTimeout(180000);
import { PostResponse } from "lemmy-js-client/dist/types/PostResponse";
import {
alpha,
beta,
gamma,
setupLogins,
createPost,
getPost,
resolveComment,
likeComment,
followBeta,
resolveBetaCommunity,
createComment,
2020-12-20 21:16:57 +00:00
editComment,
deleteComment,
removeComment,
getMentions,
resolvePost,
unfollowRemotes,
2020-08-06 18:30:01 +00:00
createCommunity,
registerUser,
reportComment,
listCommentReports,
randomString,
2020-08-06 18:30:01 +00:00
API,
2022-03-22 19:50:47 +00:00
unfollows,
getComments,
getCommentParentId,
resolveCommunity,
getPersonDetails,
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
getReplies,
getUnreadCount,
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
waitUntil,
delay,
} from "./shared";
import { CommentView } from "lemmy-js-client/dist/types/CommentView";
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let postOnAlphaRes: PostResponse;
beforeAll(async () => {
await setupLogins();
2022-03-22 19:50:47 +00:00
await unfollows();
2023-09-18 16:29:08 +00:00
await Promise.all([followBeta(alpha), followBeta(gamma)]);
let betaCommunity = (await resolveBetaCommunity(alpha)).community;
if (betaCommunity) {
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
postOnAlphaRes = await createPost(alpha, betaCommunity.community.id);
}
});
afterAll(async () => {
2022-03-22 19:50:47 +00:00
await unfollows();
});
function assertCommentFederation(
commentOne?: CommentView,
commentTwo?: CommentView,
2020-12-20 21:16:57 +00:00
) {
expect(commentOne?.comment.ap_id).toBe(commentTwo?.comment.ap_id);
expect(commentOne?.comment.content).toBe(commentTwo?.comment.content);
expect(commentOne?.creator.name).toBe(commentTwo?.creator.name);
expect(commentOne?.community.actor_id).toBe(commentTwo?.community.actor_id);
expect(commentOne?.comment.published).toBe(commentTwo?.comment.published);
expect(commentOne?.comment.updated).toBe(commentOne?.comment.updated);
expect(commentOne?.comment.deleted).toBe(commentOne?.comment.deleted);
expect(commentOne?.comment.removed).toBe(commentOne?.comment.removed);
}
test("Create a comment", async () => {
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
2020-12-20 21:16:57 +00:00
expect(commentRes.comment_view.comment.content).toBeDefined();
expect(commentRes.comment_view.community.local).toBe(false);
expect(commentRes.comment_view.creator.local).toBe(true);
expect(commentRes.comment_view.counts.score).toBe(1);
// Make sure that comment is liked on beta
let betaComment = (
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment),
c => c.comment?.counts.score === 1,
)
).comment;
expect(betaComment).toBeDefined();
expect(betaComment?.community.local).toBe(true);
expect(betaComment?.creator.local).toBe(false);
expect(betaComment?.counts.score).toBe(1);
2020-12-20 21:16:57 +00:00
assertCommentFederation(betaComment, commentRes.comment_view);
});
test("Create a comment in a non-existent post", async () => {
await expect(createComment(alpha, -1)).rejects.toBe("couldnt_find_post");
});
test("Update a comment", async () => {
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
// Federate the comment first
let betaComment = (
await resolveComment(beta, commentRes.comment_view.comment)
).comment;
assertCommentFederation(betaComment, commentRes.comment_view);
2020-12-20 21:16:57 +00:00
let updateCommentRes = await editComment(
alpha,
commentRes.comment_view.comment.id,
2020-12-20 21:16:57 +00:00
);
expect(updateCommentRes.comment_view.comment.content).toBe(
"A jest test federated comment update",
);
2020-12-20 21:16:57 +00:00
expect(updateCommentRes.comment_view.community.local).toBe(false);
expect(updateCommentRes.comment_view.creator.local).toBe(true);
// Make sure that post is updated on beta
let betaCommentUpdated = (
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment),
c =>
c.comment?.comment.content === "A jest test federated comment update",
)
).comment;
assertCommentFederation(betaCommentUpdated, updateCommentRes.comment_view);
});
test("Delete a comment", async () => {
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
// creating a comment on alpha (remote from home of community)
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
// Find the comment on beta (home of community)
let betaComment = (
await resolveComment(beta, commentRes.comment_view.comment)
).comment;
if (!betaComment) {
throw "Missing beta comment before delete";
}
// Find the comment on remote instance gamma
let gammaComment = (
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() =>
resolveComment(gamma, commentRes.comment_view.comment).catch(e => e),
r => r !== "couldnt_find_object",
)
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
).comment;
if (!gammaComment) {
throw "Missing gamma comment (remote-home-remote replication) before delete";
}
let deleteCommentRes = await deleteComment(
alpha,
true,
commentRes.comment_view.comment.id,
);
2020-12-20 21:16:57 +00:00
expect(deleteCommentRes.comment_view.comment.deleted).toBe(true);
// Make sure that comment is undefined on beta
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment).catch(e => e),
e => e === "couldnt_find_object",
);
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
// Make sure that comment is undefined on gamma after delete
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(gamma, commentRes.comment_view.comment).catch(e => e),
e => e === "couldnt_find_object",
);
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
// Test undeleting the comment
let undeleteCommentRes = await deleteComment(
alpha,
false,
commentRes.comment_view.comment.id,
);
2020-12-20 21:16:57 +00:00
expect(undeleteCommentRes.comment_view.comment.deleted).toBe(false);
// Make sure that comment is undeleted on beta
let betaComment2 = (
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment).catch(e => e),
e => e !== "couldnt_find_object",
)
).comment;
expect(betaComment2?.comment.deleted).toBe(false);
assertCommentFederation(betaComment2, undeleteCommentRes.comment_view);
});
test.skip("Remove a comment from admin and community on the same instance", async () => {
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
2020-08-06 18:30:01 +00:00
// Get the id for beta
2020-12-20 21:16:57 +00:00
let betaCommentId = (
await resolveComment(beta, commentRes.comment_view.comment)
).comment?.comment.id;
if (!betaCommentId) {
throw "beta comment id is missing";
}
2020-08-06 18:30:01 +00:00
// The beta admin removes it (the community lives on beta)
let removeCommentRes = await removeComment(beta, true, betaCommentId);
2020-12-20 21:16:57 +00:00
expect(removeCommentRes.comment_view.comment.removed).toBe(true);
2020-08-06 18:30:01 +00:00
// Make sure that comment is removed on alpha (it gets pushed since an admin from beta removed it)
let refetchedPostComments = await getPersonDetails(
alpha,
commentRes.comment_view.comment.creator_id,
);
expect(refetchedPostComments.comments[0].comment.removed).toBe(true);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// beta will unremove the comment
2020-08-06 18:30:01 +00:00
let unremoveCommentRes = await removeComment(beta, false, betaCommentId);
2020-12-20 21:16:57 +00:00
expect(unremoveCommentRes.comment_view.comment.removed).toBe(false);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// Make sure that comment is unremoved on alpha
let refetchedPostComments2 = await getComments(
alpha,
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
postOnAlphaRes.post_view.post.id,
);
expect(refetchedPostComments2.comments[0].comment.removed).toBe(false);
2020-12-20 21:16:57 +00:00
assertCommentFederation(
refetchedPostComments2.comments[0],
unremoveCommentRes.comment_view,
2020-12-20 21:16:57 +00:00
);
2020-08-06 18:30:01 +00:00
});
test("Remove a comment from admin and community on different instance", async () => {
let alpha_user = await registerUser(alpha);
2020-08-06 18:30:01 +00:00
let newAlphaApi: API = {
client: alpha.client,
auth: alpha_user.jwt ?? "",
2020-08-06 18:30:01 +00:00
};
// New alpha user creates a community, post, and comment.
let newCommunity = await createCommunity(newAlphaApi);
2020-12-20 21:16:57 +00:00
let newPost = await createPost(
newAlphaApi,
newCommunity.community_view.community.id,
2020-12-20 21:16:57 +00:00
);
let commentRes = await createComment(newAlphaApi, newPost.post_view.post.id);
2020-12-20 21:16:57 +00:00
expect(commentRes.comment_view.comment.content).toBeDefined();
2020-08-06 18:30:01 +00:00
// Beta searches that to cache it, then removes it
let betaComment = (
await resolveComment(beta, commentRes.comment_view.comment)
).comment;
if (!betaComment) {
throw "beta comment missing";
}
2020-12-20 21:16:57 +00:00
let removeCommentRes = await removeComment(
beta,
true,
betaComment.comment.id,
2020-12-20 21:16:57 +00:00
);
expect(removeCommentRes.comment_view.comment.removed).toBe(true);
2020-08-06 18:30:01 +00:00
// Make sure its not removed on alpha
let refetchedPostComments = await getComments(
alpha,
newPost.post_view.post.id,
);
expect(refetchedPostComments.comments[0].comment.removed).toBe(false);
assertCommentFederation(
refetchedPostComments.comments[0],
commentRes.comment_view,
);
});
test("Unlike a comment", async () => {
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
// Lemmy automatically creates 1 like (vote) by author of comment.
// Make sure that comment is liked (voted up) on gamma, downstream peer
// This is testing replication from remote-home-remote (alpha-beta-gamma)
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
let gammaComment1 = (
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(gamma, commentRes.comment_view.comment),
c => c.comment?.counts.score === 1,
)
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
).comment;
expect(gammaComment1).toBeDefined();
expect(gammaComment1?.community.local).toBe(false);
expect(gammaComment1?.creator.local).toBe(false);
expect(gammaComment1?.counts.score).toBe(1);
2020-12-20 21:16:57 +00:00
let unlike = await likeComment(alpha, 0, commentRes.comment_view.comment);
expect(unlike.comment_view.counts.score).toBe(0);
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
// Make sure that comment is unliked on beta
let betaComment = (
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment),
c => c.comment?.counts.score === 0,
)
).comment;
expect(betaComment).toBeDefined();
expect(betaComment?.community.local).toBe(true);
expect(betaComment?.creator.local).toBe(false);
expect(betaComment?.counts.score).toBe(0);
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
// Make sure that comment is unliked on gamma, downstream peer
// This is testing replication from remote-home-remote (alpha-beta-gamma)
let gammaComment = (
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(gamma, commentRes.comment_view.comment),
c => c.comment?.counts.score === 0,
)
Federation tests replication round1 - demonstrate absent replication of comment deletes (#3657) * more robust test of unlike a comment, confirm replication to instance downstream from community home * more robust 'delete a comment' test, confirm replication * Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report * typo and actually have Gamma comment check use gamma, not alpha * prepare-drone-federation-test.sh has some more echo output and note about the LEMMY_DATABASE_URL format (#3651) * Add http cache for webfingers (#3317) * Add http cache for webfingers * Remove the outgoing cache middleware & adjust the cache headers directive * Use 1h & 3day cache header * Update routes and adjust the cache headers location * revert apub caching --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com> * Rewrite activity lists to fix delete federation (fixes #3625) * Revert "typo and actually have Gamma comment check use gamma, not alpha" This reverts commit 7dfb6ee0f4885da3a2d10316422f5b510772806c. * Revert "Far more robust "Report a comment" test. Many comments about situation, this is currently failing because gamma does not get the report" This reverts commit 7bd3b20ae08a64324029491ddb3ce4295ba16787. * prettier TypeScript * revised comments, as ResolveObject isn't using routine replication * fmt * fix api tests * remove comment --------- Co-authored-by: cetra3 <cetra3@hotmail.com> Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-07-27 10:17:40 +00:00
).comment;
expect(gammaComment).toBeDefined();
expect(gammaComment?.community.local).toBe(false);
expect(gammaComment?.creator.local).toBe(false);
expect(gammaComment?.counts.score).toBe(0);
});
test("Federated comment like", async () => {
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveComment(beta, commentRes.comment_view.comment),
c => c.comment?.counts.score === 1,
);
// Find the comment on beta
let betaComment = (
await resolveComment(beta, commentRes.comment_view.comment)
).comment;
if (!betaComment) {
throw "Missing beta comment";
}
2020-12-20 21:16:57 +00:00
let like = await likeComment(beta, 1, betaComment.comment);
expect(like.comment_view.counts.score).toBe(2);
// Get the post from alpha, check the likes
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let postComments = await waitUntil(
() => getComments(alpha, postOnAlphaRes.post_view.post.id),
c => c.comments[0].counts.score === 2,
);
expect(postComments.comments[0].counts.score).toBe(2);
});
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
test("Reply to a comment from another instance, get notification", async () => {
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let betaCommunity = (await resolveBetaCommunity(alpha)).community;
if (!betaCommunity) {
throw "Missing beta community";
}
const postOnAlphaRes = await createPost(alpha, betaCommunity.community.id);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// Create a root-level trunk-branch comment on alpha
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
// find that comment id on beta
let betaComment = (
await resolveComment(beta, commentRes.comment_view.comment)
).comment;
if (!betaComment) {
throw "Missing beta comment";
}
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// Reply from beta, extending the branch
2020-12-20 21:16:57 +00:00
let replyRes = await createComment(
beta,
betaComment.post.id,
betaComment.comment.id,
2020-12-20 21:16:57 +00:00
);
expect(replyRes.comment_view.comment.content).toBeDefined();
expect(replyRes.comment_view.community.local).toBe(true);
expect(replyRes.comment_view.creator.local).toBe(true);
expect(getCommentParentId(replyRes.comment_view.comment)).toBe(
betaComment.comment.id,
);
2020-12-20 21:16:57 +00:00
expect(replyRes.comment_view.counts.score).toBe(1);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// Make sure that reply comment is seen on alpha
// TODO not sure why, but a searchComment back to alpha, for the ap_id of betas
// comment, isn't working.
// let searchAlpha = await searchComment(alpha, replyRes.comment);
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let postComments = await waitUntil(
() => getComments(alpha, postOnAlphaRes.post_view.post.id),
pc => pc.comments.length >= 2,
);
// Note: this test fails when run twice and this count will differ
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
expect(postComments.comments.length).toBeGreaterThanOrEqual(2);
let alphaComment = postComments.comments[0];
2020-12-20 21:16:57 +00:00
expect(alphaComment.comment.content).toBeDefined();
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
expect(getCommentParentId(alphaComment.comment)).toBe(
postComments.comments[1].comment.id,
);
2020-12-20 21:16:57 +00:00
expect(alphaComment.community.local).toBe(false);
expect(alphaComment.creator.local).toBe(false);
expect(alphaComment.counts.score).toBe(1);
assertCommentFederation(alphaComment, replyRes.comment_view);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// Did alpha get notified of the reply from beta?
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let alphaUnreadCountRes = await waitUntil(
() => getUnreadCount(alpha),
e => e.replies >= 1,
);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
expect(alphaUnreadCountRes.replies).toBe(1);
// check inbox of replies on alpha, fetching read/unread both
let alphaRepliesRes = await getReplies(alpha);
expect(alphaRepliesRes.replies.length).toBe(1);
expect(alphaRepliesRes.replies[0].comment.content).toBeDefined();
expect(alphaRepliesRes.replies[0].community.local).toBe(false);
expect(alphaRepliesRes.replies[0].creator.local).toBe(false);
expect(alphaRepliesRes.replies[0].counts.score).toBe(1);
// ToDo: interesting alphaRepliesRes.replies[0].comment_reply.id is 1, meaning? how did that come about?
expect(alphaRepliesRes.replies[0].comment.id).toBe(alphaComment.comment.id);
// this is a new notification, getReplies fetch was for read/unread both, confirm it is unread.
expect(alphaRepliesRes.replies[0].comment_reply.read).toBe(false);
assertCommentFederation(alphaRepliesRes.replies[0], replyRes.comment_view);
});
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
test("Mention beta from alpha", async () => {
// Create a new branch, trunk-level comment branch, from alpha instance
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
// Create a reply comment to previous comment, this has a mention in body
let mentionContent = "A test mention of @lemmy_beta@lemmy-beta:8551";
let mentionRes = await createComment(
alpha,
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
postOnAlphaRes.post_view.post.id,
commentRes.comment_view.comment.id,
mentionContent,
);
2020-12-20 21:16:57 +00:00
expect(mentionRes.comment_view.comment.content).toBeDefined();
expect(mentionRes.comment_view.community.local).toBe(false);
expect(mentionRes.comment_view.creator.local).toBe(true);
expect(mentionRes.comment_view.counts.score).toBe(1);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// get beta's localized copy of the alpha post
let betaPost = (await resolvePost(beta, postOnAlphaRes.post_view.post)).post;
if (!betaPost) {
throw "unable to locate post on beta";
}
expect(betaPost.post.ap_id).toBe(postOnAlphaRes.post_view.post.ap_id);
expect(betaPost.post.name).toBe(postOnAlphaRes.post_view.post.name);
// Make sure that both new comments are seen on beta and have parent/child relationship
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let betaPostComments = await waitUntil(
() => getComments(beta, betaPost!.post.id),
c => c.comments[1].counts.score === 1,
);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
expect(betaPostComments.comments.length).toBeGreaterThanOrEqual(2);
// the trunk-branch root comment will be older than the mention reply comment, so index 1
let betaRootComment = betaPostComments.comments[1];
// the trunk-branch root comment should not have a parent
expect(getCommentParentId(betaRootComment.comment)).toBeUndefined();
expect(betaRootComment.comment.content).toBeDefined();
// the mention reply comment should have parent that points to the branch root level comment
expect(getCommentParentId(betaPostComments.comments[0].comment)).toBe(
betaPostComments.comments[1].comment.id,
);
expect(betaRootComment.community.local).toBe(true);
expect(betaRootComment.creator.local).toBe(false);
expect(betaRootComment.counts.score).toBe(1);
assertCommentFederation(betaRootComment, commentRes.comment_view);
let mentionsRes = await getMentions(beta);
2020-12-20 21:16:57 +00:00
expect(mentionsRes.mentions[0].comment.content).toBeDefined();
expect(mentionsRes.mentions[0].community.local).toBe(true);
expect(mentionsRes.mentions[0].creator.local).toBe(false);
expect(mentionsRes.mentions[0].counts.score).toBe(1);
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
// the reply comment with mention should be the most fresh, newest, index 0
expect(mentionsRes.mentions[0].person_mention.comment_id).toBe(
betaPostComments.comments[0].comment.id,
);
});
test("Comment Search", async () => {
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let commentRes = await createComment(alpha, postOnAlphaRes.post_view.post.id);
let betaComment = (
await resolveComment(beta, commentRes.comment_view.comment)
).comment;
assertCommentFederation(betaComment, commentRes.comment_view);
});
test("A and G subscribe to B (center) A posts, G mentions B, it gets announced to A", async () => {
// Create a local post
let alphaCommunity = (await resolveCommunity(alpha, "!main@lemmy-alpha:8541"))
.community;
if (!alphaCommunity) {
throw "Missing alpha community";
}
let alphaPost = await createPost(alpha, alphaCommunity.community.id);
2020-12-20 21:16:57 +00:00
expect(alphaPost.post_view.community.local).toBe(true);
// Make sure gamma sees it
let gammaPost = (await resolvePost(gamma, alphaPost.post_view.post)).post;
if (!gammaPost) {
throw "Missing gamma post";
}
let commentContent =
"A jest test federated comment announce, lets mention @lemmy_beta@lemmy-beta:8551";
let commentRes = await createComment(
gamma,
2020-12-20 21:16:57 +00:00
gammaPost.post.id,
undefined,
commentContent,
);
2020-12-20 21:16:57 +00:00
expect(commentRes.comment_view.comment.content).toBe(commentContent);
expect(commentRes.comment_view.community.local).toBe(false);
expect(commentRes.comment_view.creator.local).toBe(true);
expect(commentRes.comment_view.counts.score).toBe(1);
// Make sure alpha sees it
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let alphaPostComments2 = await waitUntil(
() => getComments(alpha, alphaPost.post_view.post.id),
2023-09-18 17:04:46 +00:00
e => e.comments[0]?.counts.score === 1,
);
expect(alphaPostComments2.comments[0].comment.content).toBe(commentContent);
expect(alphaPostComments2.comments[0].community.local).toBe(true);
expect(alphaPostComments2.comments[0].creator.local).toBe(false);
expect(alphaPostComments2.comments[0].counts.score).toBe(1);
assertCommentFederation(
alphaPostComments2.comments[0],
commentRes.comment_view,
);
// Make sure beta has mentions
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let relevantMention = await waitUntil(
() =>
getMentions(beta).then(m =>
m.mentions.find(
m => m.comment.ap_id === commentRes.comment_view.comment.ap_id,
),
),
e => !!e,
);
if (!relevantMention) throw Error("could not find mention");
expect(relevantMention.comment.content).toBe(commentContent);
expect(relevantMention.community.local).toBe(false);
expect(relevantMention.creator.local).toBe(false);
// TODO this is failing because fetchInReplyTos aren't getting score
// expect(mentionsRes.mentions[0].score).toBe(1);
});
test("Check that activity from another instance is sent to third instance", async () => {
// Alpha and gamma users follow beta community
let alphaFollow = await followBeta(alpha);
expect(alphaFollow.community_view.community.local).toBe(false);
expect(alphaFollow.community_view.community.name).toBe("main");
let gammaFollow = await followBeta(gamma);
expect(gammaFollow.community_view.community.local).toBe(false);
expect(gammaFollow.community_view.community.name).toBe("main");
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
await waitUntil(
() => resolveBetaCommunity(alpha),
c => c.community?.subscribed === "Subscribed",
);
await waitUntil(
() => resolveBetaCommunity(gamma),
c => c.community?.subscribed === "Subscribed",
);
// Create a post on beta
let betaPost = await createPost(beta, 2);
expect(betaPost.post_view.community.local).toBe(true);
// Make sure gamma and alpha see it
let gammaPost = (await resolvePost(gamma, betaPost.post_view.post)).post;
if (!gammaPost) {
throw "Missing gamma post";
}
expect(gammaPost.post).toBeDefined();
let alphaPost = (await resolvePost(alpha, betaPost.post_view.post)).post;
if (!alphaPost) {
throw "Missing alpha post";
}
expect(alphaPost.post).toBeDefined();
// The bug: gamma comments, and alpha should see it.
let commentContent = "Comment from gamma";
let commentRes = await createComment(
gamma,
gammaPost.post.id,
undefined,
commentContent,
);
expect(commentRes.comment_view.comment.content).toBe(commentContent);
expect(commentRes.comment_view.community.local).toBe(false);
expect(commentRes.comment_view.creator.local).toBe(true);
expect(commentRes.comment_view.counts.score).toBe(1);
// Make sure alpha sees it
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let alphaPostComments2 = await waitUntil(
() => getComments(alpha, alphaPost!.post.id),
e => !!e.comments[0],
);
expect(alphaPostComments2.comments[0].comment.content).toBe(commentContent);
expect(alphaPostComments2.comments[0].community.local).toBe(false);
expect(alphaPostComments2.comments[0].creator.local).toBe(false);
expect(alphaPostComments2.comments[0].counts.score).toBe(1);
assertCommentFederation(
alphaPostComments2.comments[0],
commentRes.comment_view,
);
2023-09-18 16:29:08 +00:00
await Promise.all([unfollowRemotes(alpha), unfollowRemotes(gamma)]);
});
test("Fetch in_reply_tos: A is unsubbed from B, B makes a post, and some embedded comments, A subs to B, B updates the lowest level comment, A fetches both the post and all the inreplyto comments for that post.", async () => {
// Unfollow all remote communities
let site = await unfollowRemotes(alpha);
expect(
site.my_user?.follows.filter(c => c.community.local == false).length,
).toBe(0);
// B creates a post, and two comments, should be invisible to A
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let postOnBetaRes = await createPost(beta, 2);
expect(postOnBetaRes.post_view.post.name).toBeDefined();
let parentCommentContent = "An invisible top level comment from beta";
let parentCommentRes = await createComment(
beta,
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
postOnBetaRes.post_view.post.id,
undefined,
parentCommentContent,
);
2020-12-20 21:16:57 +00:00
expect(parentCommentRes.comment_view.comment.content).toBe(
parentCommentContent,
2020-12-20 21:16:57 +00:00
);
// B creates a comment, then a child one of that.
let childCommentContent = "An invisible child comment from beta";
let childCommentRes = await createComment(
beta,
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
postOnBetaRes.post_view.post.id,
parentCommentRes.comment_view.comment.id,
childCommentContent,
2020-12-20 21:16:57 +00:00
);
expect(childCommentRes.comment_view.comment.content).toBe(
childCommentContent,
);
// Follow beta again
let follow = await followBeta(alpha);
expect(follow.community_view.community.local).toBe(false);
expect(follow.community_view.community.name).toBe("main");
// 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";
2020-12-20 21:16:57 +00:00
let updateRes = await editComment(
beta,
2020-12-20 21:16:57 +00:00
childCommentRes.comment_view.comment.id,
updatedCommentContent,
);
expect(updateRes.comment_view.comment.content).toBe(updatedCommentContent);
// Get the post from alpha
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let alphaPostB = (await resolvePost(alpha, postOnBetaRes.post_view.post))
.post;
if (!alphaPostB) {
throw "Missing alpha post B";
}
2020-12-20 21:16:57 +00:00
let alphaPost = await getPost(alpha, alphaPostB.post.id);
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let alphaPostComments = await waitUntil(
() => getComments(alpha, alphaPostB!.post.id),
c =>
c.comments[1]?.comment.content ===
2023-09-18 16:29:08 +00:00
parentCommentRes.comment_view.comment.content &&
c.comments[0]?.comment.content === updateRes.comment_view.comment.content,
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
);
2020-12-20 21:16:57 +00:00
expect(alphaPost.post_view.post.name).toBeDefined();
assertCommentFederation(
alphaPostComments.comments[1],
parentCommentRes.comment_view,
);
assertCommentFederation(
alphaPostComments.comments[0],
updateRes.comment_view,
);
2020-12-20 21:16:57 +00:00
expect(alphaPost.post_view.community.local).toBe(false);
expect(alphaPost.post_view.creator.local).toBe(false);
2020-12-17 19:23:15 +00:00
await unfollowRemotes(alpha);
});
test("Report a comment", async () => {
let betaCommunity = (await resolveBetaCommunity(beta)).community;
if (!betaCommunity) {
throw "Missing beta community";
}
Enhanced testing of comments. Validate reply notifications, mentions (#3686) * shared.ts first test of getReplies * comment testing now validates reply notifications and mentions, some code comment cleanup in other functions * comments revised * first use of getUnreadCount in testing * test notification of new comment replies, clarify usage of getReplies * killall moved earlier in bash script * api-test jest run does not need directory prefix, make consistent with other jest runs * do not put my testing system password into script * fix, killall exits script when no process found * killall now moved to parent script to release locks before database create * need to run killall a second time, before database drop * first use of getReplies getPosts saveUserSettings * accidental duplication of functions, removed * try to sync shared library with main * Nutomic feedback: Better to rename the var instead of putting a comment which can easily get outdated. * Correct logic to meet join-lemmy requirement, don't have closed signups. Allows Open and Applications. (#3761) Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> * Fix fetch instance software version from nodeinfo (#3772) Fixes #3771 * remove unused code, revert killall change --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: figure-0e <133478007+figure-0e@users.noreply.github.com> Co-authored-by: Josh Bernardini <josh.bernardini@cologix.com> Co-authored-by: Denis Dzyubenko <denis@ddenis.info> Co-authored-by: Felix Ableitner <me@nutomic.com>
2023-08-01 13:14:40 +00:00
let postOnBetaRes = (await createPost(beta, betaCommunity.community.id))
.post_view.post;
expect(postOnBetaRes).toBeDefined();
let commentRes = (await createComment(beta, postOnBetaRes.id)).comment_view
.comment;
expect(commentRes).toBeDefined();
let alphaComment = (await resolveComment(alpha, commentRes)).comment?.comment;
if (!alphaComment) {
throw "Missing alpha comment";
}
let alphaReport = (
await reportComment(alpha, alphaComment.id, randomString(10))
).comment_report_view.comment_report;
Persistent, performant, reliable federation queue (#3605) * persistent activity queue * fixes * fixes * make federation workers function callable from outside * log federation instances * dead instance detection not needed here * taplo fmt * split federate bin/lib * minor fix * better logging * log * create struct to hold cancellable task for readability * use boxfuture for readability * reset submodule * fix * fix lint * swap * remove json column, use separate array columns instead * some review comments * make worker a struct for readability * minor readability * add local filter to community follower view * remove separate lemmy_federate entry point * fix remaining duration * address review comments mostly * fix lint * upgrade actitypub-fed to simpler interface * fix sql format * increase delays a bit * fixes after merge * remove selectable * fix instance selectable * add comment * start federation based on latest id at the time * rename federate process args * dead instances in one query * filter follow+report activities by local * remove synchronous federation remove activity sender queue * lint * fix federation tests by waiting for results to change * fix fed test * fix comment report * wait some more * Apply suggestions from code review Co-authored-by: SorteKanin <sortekanin@gmail.com> * fix most remaining tests * wait until private messages * fix community tests * fix community tests * move arg parse * use instance_id instead of domain in federation_queue_state table --------- Co-authored-by: Dessalines <dessalines@users.noreply.github.com> Co-authored-by: SorteKanin <sortekanin@gmail.com>
2023-09-09 16:25:03 +00:00
let betaReport = (
await waitUntil(
() => listCommentReports(beta),
e => !!e.comment_reports[0],
)
).comment_reports[0].comment_report;
expect(betaReport).toBeDefined();
expect(betaReport.resolved).toBe(false);
expect(betaReport.original_comment_text).toBe(
alphaReport.original_comment_text,
);
expect(betaReport.reason).toBe(alphaReport.reason);
});