Add test cases for community with non-ascii name (ref #5239) (#5246)

* Add test cases for community with non-ascii name (ref #5239)

* fmt

* Update run-federation-test.sh
This commit is contained in:
Nutomic 2024-12-03 17:19:01 +00:00 committed by GitHub
parent dcf1cfca9b
commit f065215e74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 8 deletions

View file

@ -35,7 +35,7 @@ import {
userBlockInstance, userBlockInstance,
} from "./shared"; } from "./shared";
import { AdminAllowInstanceParams } from "lemmy-js-client/dist/types/AdminAllowInstanceParams"; import { AdminAllowInstanceParams } from "lemmy-js-client/dist/types/AdminAllowInstanceParams";
import { EditCommunity, EditSite } from "lemmy-js-client"; import { EditCommunity, EditSite, GetPosts } from "lemmy-js-client";
beforeAll(setupLogins); beforeAll(setupLogins);
afterAll(unfollows); afterAll(unfollows);
@ -576,3 +576,29 @@ test("Remote mods can edit communities", async () => {
"Example description", "Example description",
); );
}); });
test("Community name with non-ascii chars", async () => {
const name = овае_ядосва" + Math.random().toString().slice(2, 6);
let communityRes = await createCommunity(alpha, name);
let betaCommunity1 = await resolveCommunity(
beta,
communityRes.community_view.community.actor_id,
);
expect(betaCommunity1.community!.community.name).toBe(name);
let alphaCommunity2 = await getCommunityByName(alpha, name);
expect(alphaCommunity2.community_view.community.name).toBe(name);
let fediName = `${communityRes.community_view.community.name}@LEMMY-ALPHA:8541`;
let betaCommunity2 = await getCommunityByName(beta, fediName);
expect(betaCommunity2.community_view.community.name).toBe(name);
let postRes = await createPost(beta, betaCommunity1.community!.community.id);
let form: GetPosts = {
community_name: fediName,
};
let posts = await beta.getPosts(form);
expect(posts.posts[0].post.name).toBe(postRes.post_view.post.name);
});

View file

@ -22,6 +22,7 @@ import {
alphaImage, alphaImage,
unfollows, unfollows,
saveUserSettingsBio, saveUserSettingsBio,
getPersonDetails,
} from "./shared"; } from "./shared";
import { import {
EditSite, EditSite,
@ -136,11 +137,9 @@ test("Requests with invalid auth should be treated as unauthenticated", async ()
}); });
test("Create user with Arabic name", async () => { test("Create user with Arabic name", async () => {
let user = await registerUser( // less than actor_name_max_length
alpha, const name = "تجريب" + Math.random().toString().slice(2, 10);
alphaUrl, let user = await registerUser(alpha, alphaUrl, name);
"تجريب" + Math.random().toString().slice(2, 10), // less than actor_name_max_length
);
let site = await getSite(user); let site = await getSite(user);
expect(site.my_user).toBeDefined(); expect(site.my_user).toBeDefined();
@ -149,8 +148,11 @@ test("Create user with Arabic name", async () => {
} }
apShortname = `${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`; apShortname = `${site.my_user.local_user_view.person.name}@lemmy-alpha:8541`;
let alphaPerson = (await resolvePerson(alpha, apShortname)).person; let betaPerson1 = (await resolvePerson(beta, apShortname)).person;
expect(alphaPerson).toBeDefined(); expect(betaPerson1!.person.name).toBe(name);
let betaPerson2 = await getPersonDetails(beta, betaPerson1!.person.id);
expect(betaPerson2!.person_view.person.name).toBe(name);
}); });
test("Create user with accept-language", async () => { test("Create user with accept-language", async () => {