Fixing unit tests.
This commit is contained in:
parent
4db6585da0
commit
0b551ecbac
6 changed files with 15 additions and 8 deletions
|
@ -61,7 +61,9 @@ impl Crud<CommentForm> for Comment {
|
|||
}
|
||||
|
||||
fn create(conn: &PgConnection, comment_form: &CommentForm) -> Result<Self, Error> {
|
||||
// println!("creating {}", &comment_form.ap_id.as_ref().unwrap());
|
||||
if let Some(for_ap_id) = &comment_form.ap_id {
|
||||
println!("creating {}", for_ap_id);
|
||||
}
|
||||
use crate::schema::comment::dsl::*;
|
||||
insert_into(comment)
|
||||
.values(comment_form)
|
||||
|
|
2
ui/src/api_tests/comment.spec.ts
vendored
2
ui/src/api_tests/comment.spec.ts
vendored
|
@ -99,10 +99,10 @@ test('Delete a comment', async () => {
|
|||
// let betaComment = searchBeta.comments[0];
|
||||
// Create a fake post, just to get the previous new post id
|
||||
let createdBetaPostJustToGetId = await createPost(beta, 2);
|
||||
await delay();
|
||||
let betaPost = await getPost(beta, createdBetaPostJustToGetId.post.id - 1);
|
||||
let betaComment = betaPost.comments[0];
|
||||
expect(betaComment.deleted).toBe(true);
|
||||
await delay();
|
||||
|
||||
let undeleteCommentRes = await deleteComment(
|
||||
alpha,
|
||||
|
|
1
ui/src/api_tests/community.spec.ts
vendored
1
ui/src/api_tests/community.spec.ts
vendored
|
@ -71,6 +71,7 @@ test('Remove community', async () => {
|
|||
let communityA = search.communities[0];
|
||||
// TODO this fails currently, because no updates are pushed
|
||||
// expect(communityA.removed).toBe(true);
|
||||
await delay();
|
||||
|
||||
// unremove
|
||||
let unremoveCommunityRes = await removeCommunity(
|
||||
|
|
10
ui/src/api_tests/post.spec.ts
vendored
10
ui/src/api_tests/post.spec.ts
vendored
|
@ -1,3 +1,4 @@
|
|||
jest.setTimeout(120000);
|
||||
import {
|
||||
alpha,
|
||||
beta,
|
||||
|
@ -203,13 +204,14 @@ test('Delete a post', async () => {
|
|||
|
||||
let deletedPost = await deletePost(alpha, true, postRes.post);
|
||||
expect(deletedPost.post.deleted).toBe(true);
|
||||
await delay();
|
||||
await delay(5000);
|
||||
|
||||
// Make sure lemmy beta sees post is deleted
|
||||
let createFakeBetaPostToGetId = (await createPost(beta, 2)).post.id - 1;
|
||||
await delay();
|
||||
let betaPost = await getPost(beta, createFakeBetaPostToGetId);
|
||||
expect(betaPost.post.deleted).toBe(true);
|
||||
await delay();
|
||||
|
||||
// Undelete
|
||||
let undeletedPost = await deletePost(alpha, false, postRes.post);
|
||||
|
@ -239,6 +241,7 @@ test('Remove a post from admin and community on different instance', async () =>
|
|||
await delay();
|
||||
let betaPost = await getPost(beta, createFakeBetaPostToGetId);
|
||||
expect(betaPost.post.removed).toBe(false);
|
||||
await delay();
|
||||
|
||||
// Undelete
|
||||
let undeletedPost = await removePost(alpha, false, postRes.post);
|
||||
|
@ -257,17 +260,18 @@ test('Remove a post from admin and community on same instance', async () => {
|
|||
|
||||
// Get the id for beta
|
||||
let createFakeBetaPostToGetId = (await createPost(beta, 2)).post.id - 1;
|
||||
await delay();
|
||||
let betaPost = await getPost(beta, createFakeBetaPostToGetId);
|
||||
await delay();
|
||||
|
||||
// The beta admin removes it (the community lives on beta)
|
||||
let removePostRes = await removePost(beta, true, betaPost.post);
|
||||
expect(removePostRes.post.removed).toBe(true);
|
||||
await delay();
|
||||
await delay(5000);
|
||||
|
||||
// Make sure lemmy alpha sees post is removed
|
||||
let alphaPost = await getPost(alpha, postRes.post.id);
|
||||
expect(alphaPost.post.removed).toBe(true);
|
||||
await delay();
|
||||
|
||||
// Undelete
|
||||
let undeletedPost = await removePost(beta, false, betaPost.post);
|
||||
|
|
4
ui/src/api_tests/private_message.spec.ts
vendored
4
ui/src/api_tests/private_message.spec.ts
vendored
|
@ -41,10 +41,9 @@ test('Update a private message', async () => {
|
|||
let updatedContent = 'A jest test federated private message edited';
|
||||
|
||||
let pmRes = await createPrivateMessage(alpha, recipient_id);
|
||||
await delay();
|
||||
let pmUpdated = await updatePrivateMessage(alpha, pmRes.message.id);
|
||||
await delay();
|
||||
expect(pmUpdated.message.content).toBe(updatedContent);
|
||||
await delay();
|
||||
|
||||
let betaPms = await listPrivateMessages(beta);
|
||||
expect(betaPms.messages[0].content).toBe(updatedContent);
|
||||
|
@ -63,6 +62,7 @@ test('Delete a private message', async () => {
|
|||
// no reason to show them
|
||||
let betaPms2 = await listPrivateMessages(beta);
|
||||
expect(betaPms2.messages.length).toBe(betaPms1.messages.length - 1);
|
||||
await delay();
|
||||
|
||||
// Undelete
|
||||
let undeletedPmRes = await deletePrivateMessage(
|
||||
|
|
2
ui/src/api_tests/shared.ts
vendored
2
ui/src/api_tests/shared.ts
vendored
|
@ -524,7 +524,7 @@ export async function followBeta(api: API): Promise<CommunityResponse> {
|
|||
}
|
||||
}
|
||||
|
||||
export const delay = (millis: number = 500) =>
|
||||
export const delay = (millis: number = 1000) =>
|
||||
new Promise((resolve, _reject) => {
|
||||
setTimeout(_ => resolve(), millis);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue