Adding a federation test for community deletes / removes.
This commit is contained in:
parent
c631dc58ce
commit
2b51fbb6d6
3 changed files with 75 additions and 25 deletions
|
@ -8,7 +8,10 @@ import {
|
||||||
createCommunity,
|
createCommunity,
|
||||||
deleteCommunity,
|
deleteCommunity,
|
||||||
removeCommunity,
|
removeCommunity,
|
||||||
|
getCommunity,
|
||||||
|
followCommunity,
|
||||||
delay,
|
delay,
|
||||||
|
longDelay,
|
||||||
} from './shared';
|
} from './shared';
|
||||||
import {
|
import {
|
||||||
Community,
|
Community,
|
||||||
|
@ -55,6 +58,21 @@ test('Create community', async () => {
|
||||||
test('Delete community', async () => {
|
test('Delete community', async () => {
|
||||||
let communityRes = await createCommunity(beta);
|
let communityRes = await createCommunity(beta);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
|
// Cache the community on Alpha
|
||||||
|
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
||||||
|
let search = await searchForCommunity(alpha, searchShort);
|
||||||
|
let communityOnAlpha = search.communities[0];
|
||||||
|
assertCommunityFederation(communityOnAlpha, communityRes.community);
|
||||||
|
await delay();
|
||||||
|
|
||||||
|
// Follow the community from alpha
|
||||||
|
let follow = await followCommunity(alpha, true, communityOnAlpha.id);
|
||||||
|
|
||||||
|
// Make sure the follow response went through
|
||||||
|
expect(follow.community.local).toBe(false);
|
||||||
|
await delay();
|
||||||
|
|
||||||
let deleteCommunityRes = await deleteCommunity(
|
let deleteCommunityRes = await deleteCommunity(
|
||||||
beta,
|
beta,
|
||||||
true,
|
true,
|
||||||
|
@ -64,11 +82,9 @@ test('Delete community', async () => {
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure it got deleted on A
|
// Make sure it got deleted on A
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let communityOnAlphaDeleted = await getCommunity(alpha, communityOnAlpha.id);
|
||||||
let communityA = search.communities[0];
|
expect(communityOnAlphaDeleted.community.deleted).toBe(true);
|
||||||
// TODO this fails currently, because no updates are pushed
|
await delay();
|
||||||
// expect(communityA.deleted).toBe(true);
|
|
||||||
// assertCommunityFederation(communityA, communityRes.community);
|
|
||||||
|
|
||||||
// Undelete
|
// Undelete
|
||||||
let undeleteCommunityRes = await deleteCommunity(
|
let undeleteCommunityRes = await deleteCommunity(
|
||||||
|
@ -80,29 +96,39 @@ test('Delete community', async () => {
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure it got undeleted on A
|
// Make sure it got undeleted on A
|
||||||
let search2 = await searchForBetaCommunity(alpha);
|
let communityOnAlphaUnDeleted = await getCommunity(alpha, communityOnAlpha.id);
|
||||||
let communityA2 = search2.communities[0];
|
expect(communityOnAlphaUnDeleted.community.deleted).toBe(false);
|
||||||
// TODO this fails currently, because no updates are pushed
|
|
||||||
// expect(communityA2.deleted).toBe(false);
|
|
||||||
// assertCommunityFederation(communityA2, undeleteCommunityRes.community);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Remove community', async () => {
|
test('Remove community', async () => {
|
||||||
let communityRes = await createCommunity(beta);
|
let communityRes = await createCommunity(beta);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
|
// Cache the community on Alpha
|
||||||
|
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
||||||
|
let search = await searchForCommunity(alpha, searchShort);
|
||||||
|
let communityOnAlpha = search.communities[0];
|
||||||
|
assertCommunityFederation(communityOnAlpha, communityRes.community);
|
||||||
|
await delay();
|
||||||
|
|
||||||
|
// Follow the community from alpha
|
||||||
|
let follow = await followCommunity(alpha, true, communityOnAlpha.id);
|
||||||
|
|
||||||
|
// Make sure the follow response went through
|
||||||
|
expect(follow.community.local).toBe(false);
|
||||||
|
await delay();
|
||||||
|
|
||||||
let removeCommunityRes = await removeCommunity(
|
let removeCommunityRes = await removeCommunity(
|
||||||
beta,
|
beta,
|
||||||
true,
|
true,
|
||||||
communityRes.community.id
|
communityRes.community.id
|
||||||
);
|
);
|
||||||
expect(removeCommunityRes.community.removed).toBe(true);
|
expect(removeCommunityRes.community.removed).toBe(true);
|
||||||
|
await delay();
|
||||||
|
|
||||||
// Make sure it got removed on A
|
// Make sure it got Removed on A
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let communityOnAlphaRemoved = await getCommunity(alpha, communityOnAlpha.id);
|
||||||
let communityA = search.communities[0];
|
expect(communityOnAlphaRemoved.community.removed).toBe(true);
|
||||||
// TODO this fails currently, because no updates are pushed
|
|
||||||
// expect(communityA.removed).toBe(true);
|
|
||||||
// assertCommunityFederation(communityA, communityRes.community);
|
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// unremove
|
// unremove
|
||||||
|
@ -114,15 +140,18 @@ test('Remove community', async () => {
|
||||||
expect(unremoveCommunityRes.community.removed).toBe(false);
|
expect(unremoveCommunityRes.community.removed).toBe(false);
|
||||||
await delay();
|
await delay();
|
||||||
|
|
||||||
// Make sure it got unremoved on A
|
// Make sure it got undeleted on A
|
||||||
let search2 = await searchForBetaCommunity(alpha);
|
let communityOnAlphaUnRemoved = await getCommunity(alpha, communityOnAlpha.id);
|
||||||
let communityA2 = search2.communities[0];
|
expect(communityOnAlphaUnRemoved.community.removed).toBe(false);
|
||||||
// TODO this fails currently, because no updates are pushed
|
|
||||||
// expect(communityA2.removed).toBe(false);
|
|
||||||
// assertCommunityFederation(communityA2, unremoveCommunityRes.community);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Search for beta community', async () => {
|
test('Search for beta community', async () => {
|
||||||
let search = await searchForBetaCommunity(alpha);
|
let communityRes = await createCommunity(beta);
|
||||||
expect(search.communities[0].name).toBe('main');
|
expect(communityRes.community.name).toBeDefined();
|
||||||
|
await delay();
|
||||||
|
|
||||||
|
let searchShort = `!${communityRes.community.name}@lemmy-beta:8551`;
|
||||||
|
let search = await searchForCommunity(alpha, searchShort);
|
||||||
|
let communityOnAlpha = search.communities[0];
|
||||||
|
assertCommunityFederation(communityOnAlpha, communityRes.community);
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,6 +20,7 @@ import {
|
||||||
RemoveCommentForm,
|
RemoveCommentForm,
|
||||||
SearchForm,
|
SearchForm,
|
||||||
CommentResponse,
|
CommentResponse,
|
||||||
|
GetCommunityForm,
|
||||||
CommunityForm,
|
CommunityForm,
|
||||||
DeleteCommunityForm,
|
DeleteCommunityForm,
|
||||||
RemoveCommunityForm,
|
RemoveCommunityForm,
|
||||||
|
@ -402,6 +403,16 @@ export async function createCommunity(
|
||||||
return api.client.createCommunity(form);
|
return api.client.createCommunity(form);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function getCommunity(
|
||||||
|
api: API,
|
||||||
|
id: number,
|
||||||
|
): Promise<CommunityResponse> {
|
||||||
|
let form: GetCommunityForm = {
|
||||||
|
id,
|
||||||
|
};
|
||||||
|
return api.client.getCommunity(form);
|
||||||
|
}
|
||||||
|
|
||||||
export async function deleteCommunity(
|
export async function deleteCommunity(
|
||||||
api: API,
|
api: API,
|
||||||
deleted: boolean,
|
deleted: boolean,
|
||||||
|
|
|
@ -8,4 +8,14 @@ for Item in alpha beta gamma delta epsilon ; do
|
||||||
sudo chown -R 991:991 volumes/pictrs_$Item
|
sudo chown -R 991:991 volumes/pictrs_$Item
|
||||||
done
|
done
|
||||||
|
|
||||||
sudo docker-compose up
|
sudo docker-compose up -d
|
||||||
|
|
||||||
|
echo "Waiting for Lemmy to start..."
|
||||||
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8541/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||||
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8551/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||||
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8561/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||||
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8571/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||||
|
while [[ "$(curl -s -o /dev/null -w '%{http_code}' 'localhost:8581/api/v1/site')" != "200" ]]; do sleep 1; done
|
||||||
|
echo "All instances started."
|
||||||
|
|
||||||
|
sudo docker-compose logs -f
|
||||||
|
|
Loading…
Reference in a new issue