2019-01-29 04:46:24 +00:00
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
2019-04-07 12:50:36 +00:00
|
|
|
import * as assert from 'assert';
|
|
|
|
import * as childProcess from 'child_process';
|
2023-06-01 21:21:03 +00:00
|
|
|
import { async, signup, request, post, startServer, shutdownServer } from './utils.mjs';
|
2019-01-29 04:46:24 +00:00
|
|
|
|
2023-05-31 10:42:13 +00:00
|
|
|
describe('API visibility', function() {
|
|
|
|
this.timeout(20*60*1000);
|
|
|
|
|
2023-06-01 21:21:03 +00:00
|
|
|
let p;
|
2019-04-07 12:50:36 +00:00
|
|
|
|
2021-06-12 13:40:17 +00:00
|
|
|
before(async () => {
|
|
|
|
p = await startServer();
|
|
|
|
});
|
2019-01-29 04:46:24 +00:00
|
|
|
|
2021-06-05 05:54:07 +00:00
|
|
|
after(async () => {
|
|
|
|
await shutdownServer(p);
|
2019-01-29 04:46:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Note visibility', async () => {
|
|
|
|
//#region vars
|
2023-05-07 21:37:47 +00:00
|
|
|
/** protagonist */
|
2023-06-01 21:21:03 +00:00
|
|
|
let alice;
|
2023-05-07 21:37:47 +00:00
|
|
|
/** follower */
|
2023-06-01 21:21:03 +00:00
|
|
|
let follower;
|
2023-05-07 21:37:47 +00:00
|
|
|
/** non-follower */
|
2023-06-01 21:21:03 +00:00
|
|
|
let other;
|
2023-05-07 21:37:47 +00:00
|
|
|
/** non-follower who has been replied to or mentioned */
|
2023-06-01 21:21:03 +00:00
|
|
|
let target;
|
2023-05-07 21:37:47 +00:00
|
|
|
/** actor for which a specified visibility was set */
|
2023-06-01 21:21:03 +00:00
|
|
|
let target2;
|
2019-01-29 04:46:24 +00:00
|
|
|
|
|
|
|
/** public-post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let pub;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** home-post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let home;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** followers-post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let fol;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** specified-post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let spe;
|
2019-01-29 04:46:24 +00:00
|
|
|
|
|
|
|
/** public-reply to target's post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let pubR;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** home-reply to target's post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let homeR;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** followers-reply to target's post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let folR;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** specified-reply to target's post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let speR;
|
2019-01-29 04:46:24 +00:00
|
|
|
|
|
|
|
/** public-mention to target */
|
2023-06-01 21:21:03 +00:00
|
|
|
let pubM;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** home-mention to target */
|
2023-06-01 21:21:03 +00:00
|
|
|
let homeM;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** followers-mention to target */
|
2023-06-01 21:21:03 +00:00
|
|
|
let folM;
|
2019-01-29 04:46:24 +00:00
|
|
|
/** specified-mention to target */
|
2023-06-01 21:21:03 +00:00
|
|
|
let speM;
|
2019-01-29 04:46:24 +00:00
|
|
|
|
|
|
|
/** reply target post */
|
2023-06-01 21:21:03 +00:00
|
|
|
let tgt;
|
2019-01-29 04:46:24 +00:00
|
|
|
//#endregion
|
|
|
|
|
2023-06-01 21:21:03 +00:00
|
|
|
const show = async (noteId, by) => {
|
2019-01-29 04:46:24 +00:00
|
|
|
return await request('/notes/show', {
|
2022-05-21 13:21:41 +00:00
|
|
|
noteId,
|
2019-01-29 04:46:24 +00:00
|
|
|
}, by);
|
|
|
|
};
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
//#region prepare
|
|
|
|
// signup
|
2022-05-21 13:21:41 +00:00
|
|
|
alice = await signup({ username: 'alice' });
|
2019-01-29 04:46:24 +00:00
|
|
|
follower = await signup({ username: 'follower' });
|
2022-05-21 13:21:41 +00:00
|
|
|
other = await signup({ username: 'other' });
|
|
|
|
target = await signup({ username: 'target' });
|
|
|
|
target2 = await signup({ username: 'target2' });
|
2019-01-29 04:46:24 +00:00
|
|
|
|
|
|
|
// follow alice <= follower
|
|
|
|
await request('/following/create', { userId: alice.id }, follower);
|
|
|
|
|
|
|
|
// normal posts
|
2022-05-21 13:21:41 +00:00
|
|
|
pub = await post(alice, { text: 'x', visibility: 'public' });
|
2019-01-29 04:46:24 +00:00
|
|
|
home = await post(alice, { text: 'x', visibility: 'home' });
|
2022-05-21 13:21:41 +00:00
|
|
|
fol = await post(alice, { text: 'x', visibility: 'followers' });
|
|
|
|
spe = await post(alice, { text: 'x', visibility: 'specified', visibleUserIds: [target.id] });
|
2019-01-29 04:46:24 +00:00
|
|
|
|
|
|
|
// replies
|
|
|
|
tgt = await post(target, { text: 'y', visibility: 'public' });
|
2022-05-21 13:21:41 +00:00
|
|
|
pubR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'public' });
|
2019-01-29 04:46:24 +00:00
|
|
|
homeR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'home' });
|
2022-05-21 13:21:41 +00:00
|
|
|
folR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'followers' });
|
|
|
|
speR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'specified' });
|
2019-01-29 04:46:24 +00:00
|
|
|
|
|
|
|
// mentions
|
2022-05-21 13:21:41 +00:00
|
|
|
pubM = await post(alice, { text: '@target x', replyId: tgt.id, visibility: 'public' });
|
2019-01-29 04:46:24 +00:00
|
|
|
homeM = await post(alice, { text: '@target x', replyId: tgt.id, visibility: 'home' });
|
2022-05-21 13:21:41 +00:00
|
|
|
folM = await post(alice, { text: '@target x', replyId: tgt.id, visibility: 'followers' });
|
|
|
|
speM = await post(alice, { text: '@target2 x', replyId: tgt.id, visibility: 'specified' });
|
2019-01-29 04:46:24 +00:00
|
|
|
//#endregion
|
|
|
|
});
|
|
|
|
|
|
|
|
//#region show post
|
|
|
|
// public
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public post can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pub.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public post can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pub.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public post can be seen by non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pub.id, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public post can be seen unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pub.id, null);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// home
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home post can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(home.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home post can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(home.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home post can be seen by non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(home.id, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home post can be seen unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(home.id, null);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// followers
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers post can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(fol.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers post can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(fol.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers post is hidden from non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(fol.id, other);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers post is hidden when unathenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(fol.id, null);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// specified
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified post can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(spe.id, alice);
|
2023-05-07 21:38:29 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified post can be seen by designated user', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(spe.id, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified post is hidden from non-specified follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(spe.id, follower);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified post is hidden from non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(spe.id, other);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified post is hidden when unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(spe.id, null);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region show reply
|
|
|
|
// public
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public reply can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubR.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public reply can be seen by replied to author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubR.id, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public reply can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubR.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public reply can be seen by non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubR.id, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public reply can be seen unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubR.id, null);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// home
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home reply can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeR.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home reply can be seen by replied to author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeR.id, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home reply can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeR.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home reply can be seen by non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeR.id, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home reply can be seen unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeR.id, null);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// followers
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers reply can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folR.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers reply can be seen by replied to author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folR.id, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers reply can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folR.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers reply is hidden from non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folR.id, other);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers reply is hidden when unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folR.id, null);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// specified
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified reply can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speR.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified reply can be seen by replied to user', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speR.id, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified reply is hidden from follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speR.id, follower);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified reply is hidden from non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speR.id, other);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified reply is hidden when unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speR.id, null);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region show mention
|
|
|
|
// public
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public-mention can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubM.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public mention can be seen by mentioned', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubM.id, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public mention can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubM.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public mention can be seen by non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubM.id, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] public mention can be seen unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(pubM.id, null);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// home
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home mention can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeM.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home mention can be seen by mentioned', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeM.id, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home mention can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeM.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home mention can be seen by non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeM.id, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] home mention can be seen unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(homeM.id, null);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// followers
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers mention can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folM.id, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers mention can be seen by non-follower mentioned', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folM.id, target);
|
2020-01-09 05:35:04 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers mention can be seen by follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folM.id, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers mention is hidden from non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folM.id, other);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] followers mention is hidden when unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(folM.id, null);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
|
|
|
// specified
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified mention can be seen by author', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speM.id, alice);
|
2020-01-09 05:35:04 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target2 x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified mention can be seen by specified actor', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speM.id, target);
|
2020-01-09 05:35:04 +00:00
|
|
|
assert.strictEqual(res.body.text, '@target2 x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified mention is hidden from mentioned but not specified actor', async(async () => {
|
2020-01-09 05:35:04 +00:00
|
|
|
const res = await show(speM.id, target2);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified mention is hidden from follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speM.id, follower);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified mention is hidden from non-follower', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speM.id, other);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[show] specified mention is hidden when unauthenticated', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await show(speM.id, null);
|
2022-06-01 08:51:11 +00:00
|
|
|
assert.strictEqual(res.status, 404);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
//#region Home Timeline
|
|
|
|
it('[TL] public post on author home TL', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await request('/notes/timeline', { limit: 100 }, alice);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == pub.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[TL] public post absent from non-follower home TL', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await request('/notes/timeline', { limit: 100 }, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == pub.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes.length, 0);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[TL] followers post on follower home TL', async(async () => {
|
2019-01-29 04:46:24 +00:00
|
|
|
const res = await request('/notes/timeline', { limit: 100 }, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == fol.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
//#region replies timeline
|
|
|
|
it('[TL] followers reply on follower reply TL', async(async () => {
|
2019-01-29 08:34:43 +00:00
|
|
|
const res = await request('/notes/replies', { noteId: tgt.id, limit: 100 }, follower);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == folR.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[TL] followers reply absent from not replied to non-follower reply TL', async(async () => {
|
2019-01-29 08:34:43 +00:00
|
|
|
const res = await request('/notes/replies', { noteId: tgt.id, limit: 100 }, other);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == folR.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes.length, 0);
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[TL] followers reply on replied to actor reply TL', async(async () => {
|
2019-01-29 08:34:43 +00:00
|
|
|
const res = await request('/notes/replies', { noteId: tgt.id, limit: 100 }, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == folR.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
2019-01-29 08:34:43 +00:00
|
|
|
//#endregion
|
2019-01-29 04:46:24 +00:00
|
|
|
|
2019-01-29 08:34:43 +00:00
|
|
|
//#region MTL
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[TL] followers reply on replied to non-follower mention TL', async(async () => {
|
2019-01-29 08:34:43 +00:00
|
|
|
const res = await request('/notes/mentions', { limit: 100 }, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == folR.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
|
2023-05-07 21:37:47 +00:00
|
|
|
it('[TL] followers mention on mentioned non-follower mention TL', async(async () => {
|
2019-01-29 08:34:43 +00:00
|
|
|
const res = await request('/notes/mentions', { limit: 100 }, target);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(res.status, 200);
|
2023-06-01 21:21:03 +00:00
|
|
|
const notes = res.body.filter((n) => n.id == folM.id);
|
2019-04-07 12:50:36 +00:00
|
|
|
assert.strictEqual(notes[0].text, '@target x');
|
2019-01-29 04:46:24 +00:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
});
|
|
|
|
});
|