2020-09-15 19:26:47 +00:00
|
|
|
jest.setTimeout(120000);
|
2020-08-04 15:06:27 +00:00
|
|
|
import {
|
|
|
|
alpha,
|
|
|
|
beta,
|
|
|
|
registerUser,
|
|
|
|
searchForUser,
|
2020-09-17 15:41:51 +00:00
|
|
|
saveUserSettings,
|
2020-08-04 15:06:27 +00:00
|
|
|
getSite,
|
|
|
|
} from './shared';
|
2020-09-17 15:41:51 +00:00
|
|
|
import {
|
2020-12-20 21:16:57 +00:00
|
|
|
UserViewSafe,
|
|
|
|
SaveUserSettings,
|
|
|
|
SortType,
|
|
|
|
ListingType,
|
2020-09-17 15:41:51 +00:00
|
|
|
} from 'lemmy-js-client';
|
2020-08-04 15:06:27 +00:00
|
|
|
|
|
|
|
let auth: string;
|
|
|
|
let apShortname: string;
|
|
|
|
|
2020-12-20 21:16:57 +00:00
|
|
|
function assertUserFederation(userOne: UserViewSafe, userTwo: UserViewSafe) {
|
|
|
|
expect(userOne.user.name).toBe(userTwo.user.name);
|
|
|
|
expect(userOne.user.preferred_username).toBe(userTwo.user.preferred_username);
|
|
|
|
expect(userOne.user.bio).toBe(userTwo.user.bio);
|
|
|
|
expect(userOne.user.actor_id).toBe(userTwo.user.actor_id);
|
|
|
|
expect(userOne.user.avatar).toBe(userTwo.user.avatar);
|
|
|
|
expect(userOne.user.banner).toBe(userTwo.user.banner);
|
|
|
|
expect(userOne.user.published).toBe(userTwo.user.published);
|
2020-09-17 15:41:51 +00:00
|
|
|
}
|
|
|
|
|
2020-08-04 15:06:27 +00:00
|
|
|
test('Create user', async () => {
|
|
|
|
let userRes = await registerUser(alpha);
|
|
|
|
expect(userRes.jwt).toBeDefined();
|
|
|
|
auth = userRes.jwt;
|
|
|
|
|
|
|
|
let site = await getSite(alpha, auth);
|
|
|
|
expect(site.my_user).toBeDefined();
|
2020-09-15 19:26:47 +00:00
|
|
|
apShortname = `@${site.my_user.name}@lemmy-alpha:8541`;
|
2020-08-04 15:06:27 +00:00
|
|
|
});
|
|
|
|
|
2020-12-17 19:01:33 +00:00
|
|
|
test('Set some user settings, check that they are federated', async () => {
|
2020-09-17 15:41:51 +00:00
|
|
|
let avatar = 'https://image.flaticon.com/icons/png/512/35/35896.png';
|
|
|
|
let banner = 'https://image.flaticon.com/icons/png/512/36/35896.png';
|
2020-12-17 19:01:33 +00:00
|
|
|
let bio = 'a changed bio';
|
2020-12-20 21:16:57 +00:00
|
|
|
let form: SaveUserSettings = {
|
2020-09-17 15:41:51 +00:00
|
|
|
show_nsfw: false,
|
2020-12-20 21:16:57 +00:00
|
|
|
theme: '',
|
|
|
|
default_sort_type: SortType.Hot,
|
|
|
|
default_listing_type: ListingType.All,
|
|
|
|
lang: '',
|
2020-09-17 15:41:51 +00:00
|
|
|
avatar,
|
|
|
|
banner,
|
2020-12-20 21:16:57 +00:00
|
|
|
preferred_username: 'user321',
|
2020-09-17 15:41:51 +00:00
|
|
|
show_avatars: false,
|
|
|
|
send_notifications_to_email: false,
|
2020-12-17 19:01:33 +00:00
|
|
|
bio,
|
2020-09-17 15:41:51 +00:00
|
|
|
auth,
|
2020-12-20 21:16:57 +00:00
|
|
|
};
|
2020-12-17 19:01:33 +00:00
|
|
|
await saveUserSettings(alpha, form);
|
2020-09-17 15:41:51 +00:00
|
|
|
|
2020-12-17 19:01:33 +00:00
|
|
|
let searchAlpha = await searchForUser(alpha, apShortname);
|
2020-09-17 15:41:51 +00:00
|
|
|
let userOnAlpha = searchAlpha.users[0];
|
|
|
|
let searchBeta = await searchForUser(beta, apShortname);
|
|
|
|
let userOnBeta = searchBeta.users[0];
|
|
|
|
assertUserFederation(userOnAlpha, userOnBeta);
|
2020-09-18 11:04:12 +00:00
|
|
|
});
|