2019-01-29 06:46:24 +02:00
|
|
|
/*
|
|
|
|
* Tests of API (visibility)
|
|
|
|
*
|
|
|
|
* How to run the tests:
|
2020-03-06 17:12:23 +02:00
|
|
|
* > npx cross-env TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true npx mocha test/api-visibility.ts --require ts-node/register
|
2019-01-29 06:46:24 +02:00
|
|
|
*
|
|
|
|
* To specify test:
|
2020-03-06 17:12:23 +02:00
|
|
|
* > npx cross-env TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true npx mocha test/api-visibility.ts --require ts-node/register -g 'test name'
|
2019-01-29 06:46:24 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
process.env.NODE_ENV = 'test';
|
|
|
|
|
2019-04-07 15:50:36 +03:00
|
|
|
import * as assert from 'assert';
|
|
|
|
import * as childProcess from 'child_process';
|
2020-01-09 07:35:04 +02:00
|
|
|
import { async, signup, request, post, launchServer } from './utils';
|
2019-01-29 06:46:24 +02:00
|
|
|
|
|
|
|
describe('API visibility', () => {
|
2019-04-07 15:50:36 +03:00
|
|
|
let p: childProcess.ChildProcess;
|
|
|
|
|
2020-01-09 07:35:04 +02:00
|
|
|
before(launchServer(g => p = g));
|
2019-01-29 06:46:24 +02:00
|
|
|
|
|
|
|
after(() => {
|
2019-04-07 15:50:36 +03:00
|
|
|
p.kill();
|
2019-01-29 06:46:24 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
describe('Note visibility', async () => {
|
|
|
|
//#region vars
|
|
|
|
/** ヒロイン */
|
|
|
|
let alice: any;
|
|
|
|
/** フォロワー */
|
|
|
|
let follower: any;
|
|
|
|
/** 非フォロワー */
|
|
|
|
let other: any;
|
|
|
|
/** 非フォロワーでもリプライやメンションをされた人 */
|
|
|
|
let target: any;
|
2020-01-09 07:35:04 +02:00
|
|
|
/** specified mentionでmentionを飛ばされる人 */
|
|
|
|
let target2: any;
|
2019-01-29 06:46:24 +02:00
|
|
|
|
|
|
|
/** public-post */
|
|
|
|
let pub: any;
|
|
|
|
/** home-post */
|
|
|
|
let home: any;
|
|
|
|
/** followers-post */
|
|
|
|
let fol: any;
|
|
|
|
/** specified-post */
|
|
|
|
let spe: any;
|
|
|
|
|
|
|
|
/** public-reply to target's post */
|
|
|
|
let pubR: any;
|
|
|
|
/** home-reply to target's post */
|
|
|
|
let homeR: any;
|
|
|
|
/** followers-reply to target's post */
|
|
|
|
let folR: any;
|
|
|
|
/** specified-reply to target's post */
|
|
|
|
let speR: any;
|
|
|
|
|
|
|
|
/** public-mention to target */
|
|
|
|
let pubM: any;
|
|
|
|
/** home-mention to target */
|
|
|
|
let homeM: any;
|
|
|
|
/** followers-mention to target */
|
|
|
|
let folM: any;
|
|
|
|
/** specified-mention to target */
|
|
|
|
let speM: any;
|
|
|
|
|
|
|
|
/** reply target post */
|
|
|
|
let tgt: any;
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
const show = async (noteId: any, by: any) => {
|
|
|
|
return await request('/notes/show', {
|
|
|
|
noteId
|
|
|
|
}, by);
|
|
|
|
};
|
|
|
|
|
|
|
|
before(async () => {
|
|
|
|
//#region prepare
|
|
|
|
// signup
|
|
|
|
alice = await signup({ username: 'alice' });
|
|
|
|
follower = await signup({ username: 'follower' });
|
|
|
|
other = await signup({ username: 'other' });
|
|
|
|
target = await signup({ username: 'target' });
|
2020-01-09 07:35:04 +02:00
|
|
|
target2 = await signup({ username: 'target2' });
|
2019-01-29 06:46:24 +02:00
|
|
|
|
|
|
|
// follow alice <= follower
|
|
|
|
await request('/following/create', { userId: alice.id }, follower);
|
|
|
|
|
|
|
|
// normal posts
|
|
|
|
pub = await post(alice, { text: 'x', visibility: 'public' });
|
|
|
|
home = await post(alice, { text: 'x', visibility: 'home' });
|
|
|
|
fol = await post(alice, { text: 'x', visibility: 'followers' });
|
|
|
|
spe = await post(alice, { text: 'x', visibility: 'specified', visibleUserIds: [target.id] });
|
|
|
|
|
|
|
|
// replies
|
|
|
|
tgt = await post(target, { text: 'y', visibility: 'public' });
|
|
|
|
pubR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'public' });
|
|
|
|
homeR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'home' });
|
|
|
|
folR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'followers' });
|
|
|
|
speR = await post(alice, { text: 'x', replyId: tgt.id, visibility: 'specified' });
|
|
|
|
|
|
|
|
// mentions
|
|
|
|
pubM = await post(alice, { text: '@target x', replyId: tgt.id, visibility: 'public' });
|
|
|
|
homeM = await post(alice, { text: '@target x', replyId: tgt.id, visibility: 'home' });
|
|
|
|
folM = await post(alice, { text: '@target x', replyId: tgt.id, visibility: 'followers' });
|
2020-01-09 07:35:04 +02:00
|
|
|
speM = await post(alice, { text: '@target2 x', replyId: tgt.id, visibility: 'specified' });
|
2019-01-29 06:46:24 +02:00
|
|
|
//#endregion
|
|
|
|
});
|
|
|
|
|
|
|
|
//#region show post
|
|
|
|
// public
|
|
|
|
it('[show] public-postを自分が見れる', async(async () => {
|
|
|
|
const res = await show(pub.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-postをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(pub.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-postを非フォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(pub.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-postを未認証が見れる', async(async () => {
|
|
|
|
const res = await show(pub.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// home
|
|
|
|
it('[show] home-postを自分が見れる', async(async () => {
|
|
|
|
const res = await show(home.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-postをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(home.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-postを非フォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(home.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-postを未認証が見れる', async(async () => {
|
|
|
|
const res = await show(home.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// followers
|
|
|
|
it('[show] followers-postを自分が見れる', async(async () => {
|
|
|
|
const res = await show(fol.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-postをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(fol.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-postを非フォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(fol.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-postを未認証が見れない', async(async () => {
|
|
|
|
const res = await show(fol.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// specified
|
|
|
|
it('[show] specified-postを自分が見れる', async(async () => {
|
|
|
|
const res = await show(spe.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-postを指定ユーザーが見れる', async(async () => {
|
|
|
|
const res = await show(spe.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-postをフォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(spe.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-postを非フォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(spe.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-postを未認証が見れない', async(async () => {
|
|
|
|
const res = await show(spe.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region show reply
|
|
|
|
// public
|
|
|
|
it('[show] public-replyを自分が見れる', async(async () => {
|
|
|
|
const res = await show(pubR.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-replyをされた人が見れる', async(async () => {
|
|
|
|
const res = await show(pubR.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-replyをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(pubR.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-replyを非フォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(pubR.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-replyを未認証が見れる', async(async () => {
|
|
|
|
const res = await show(pubR.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// home
|
|
|
|
it('[show] home-replyを自分が見れる', async(async () => {
|
|
|
|
const res = await show(homeR.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-replyをされた人が見れる', async(async () => {
|
|
|
|
const res = await show(homeR.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-replyをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(homeR.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-replyを非フォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(homeR.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-replyを未認証が見れる', async(async () => {
|
|
|
|
const res = await show(homeR.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// followers
|
|
|
|
it('[show] followers-replyを自分が見れる', async(async () => {
|
|
|
|
const res = await show(folR.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
2019-01-29 10:34:43 +02:00
|
|
|
it('[show] followers-replyを非フォロワーでもリプライされていれば見れる', async(async () => {
|
2019-01-29 06:46:24 +02:00
|
|
|
const res = await show(folR.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-replyをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(folR.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-replyを非フォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(folR.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-replyを未認証が見れない', async(async () => {
|
|
|
|
const res = await show(folR.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// specified
|
|
|
|
it('[show] specified-replyを自分が見れる', async(async () => {
|
|
|
|
const res = await show(speR.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-replyを指定ユーザーが見れる', async(async () => {
|
|
|
|
const res = await show(speR.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-replyをされた人が指定されてなくても見れる', async(async () => {
|
|
|
|
const res = await show(speR.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-replyをフォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(speR.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-replyを非フォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(speR.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-replyを未認証が見れない', async(async () => {
|
|
|
|
const res = await show(speR.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region show mention
|
|
|
|
// public
|
|
|
|
it('[show] public-mentionを自分が見れる', async(async () => {
|
|
|
|
const res = await show(pubM.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-mentionをされた人が見れる', async(async () => {
|
|
|
|
const res = await show(pubM.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-mentionをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(pubM.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-mentionを非フォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(pubM.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] public-mentionを未認証が見れる', async(async () => {
|
|
|
|
const res = await show(pubM.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// home
|
|
|
|
it('[show] home-mentionを自分が見れる', async(async () => {
|
|
|
|
const res = await show(homeM.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-mentionをされた人が見れる', async(async () => {
|
|
|
|
const res = await show(homeM.id, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-mentionをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(homeM.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-mentionを非フォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(homeM.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] home-mentionを未認証が見れる', async(async () => {
|
|
|
|
const res = await show(homeM.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// followers
|
|
|
|
it('[show] followers-mentionを自分が見れる', async(async () => {
|
|
|
|
const res = await show(folM.id, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
2020-01-09 07:35:04 +02:00
|
|
|
it('[show] followers-mentionをメンションされていれば非フォロワーでも見れる', async(async () => {
|
2019-01-29 06:46:24 +02:00
|
|
|
const res = await show(folM.id, target);
|
2020-01-09 07:35:04 +02:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-mentionをフォロワーが見れる', async(async () => {
|
|
|
|
const res = await show(folM.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-mentionを非フォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(folM.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] followers-mentionを未認証が見れない', async(async () => {
|
|
|
|
const res = await show(folM.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
// specified
|
|
|
|
it('[show] specified-mentionを自分が見れる', async(async () => {
|
|
|
|
const res = await show(speM.id, alice);
|
2020-01-09 07:35:04 +02:00
|
|
|
assert.strictEqual(res.body.text, '@target2 x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-mentionを指定ユーザーが見れる', async(async () => {
|
|
|
|
const res = await show(speM.id, target);
|
2020-01-09 07:35:04 +02:00
|
|
|
assert.strictEqual(res.body.text, '@target2 x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
2019-04-07 15:50:36 +03:00
|
|
|
it('[show] specified-mentionをされた人が指定されてなかったら見れない', async(async () => {
|
2020-01-09 07:35:04 +02:00
|
|
|
const res = await show(speM.id, target2);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-mentionをフォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(speM.id, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-mentionを非フォロワーが見れない', async(async () => {
|
|
|
|
const res = await show(speM.id, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[show] specified-mentionを未認証が見れない', async(async () => {
|
|
|
|
const res = await show(speM.id, null);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.body.isHidden, true);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region HTL
|
|
|
|
it('[HTL] public-post が 自分が見れる', async(async () => {
|
|
|
|
const res = await request('/notes/timeline', { limit: 100 }, alice);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == pub.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[HTL] public-post が 非フォロワーから見れない', async(async () => {
|
|
|
|
const res = await request('/notes/timeline', { limit: 100 }, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == pub.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes.length, 0);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
|
|
|
it('[HTL] followers-post が フォロワーから見れる', async(async () => {
|
|
|
|
const res = await request('/notes/timeline', { limit: 100 }, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == fol.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region RTL
|
2019-01-29 10:34:43 +02:00
|
|
|
it('[replies] followers-reply が フォロワーから見れる', async(async () => {
|
|
|
|
const res = await request('/notes/replies', { noteId: tgt.id, limit: 100 }, follower);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == folR.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
2019-01-29 10:34:43 +02:00
|
|
|
it('[replies] followers-reply が 非フォロワー (リプライ先ではない) から見れない', async(async () => {
|
|
|
|
const res = await request('/notes/replies', { noteId: tgt.id, limit: 100 }, other);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == folR.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes.length, 0);
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
2019-01-29 10:34:43 +02:00
|
|
|
it('[replies] followers-reply が 非フォロワー (リプライ先である) から見れる', async(async () => {
|
|
|
|
const res = await request('/notes/replies', { noteId: tgt.id, limit: 100 }, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == folR.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
2019-01-29 10:34:43 +02:00
|
|
|
//#endregion
|
2019-01-29 06:46:24 +02:00
|
|
|
|
2019-01-29 10:34:43 +02:00
|
|
|
//#region MTL
|
|
|
|
it('[mentions] followers-reply が 非フォロワー (リプライ先である) から見れる', async(async () => {
|
|
|
|
const res = await request('/notes/mentions', { limit: 100 }, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == folR.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes[0].text, 'x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
|
2019-01-29 10:34:43 +02:00
|
|
|
it('[mentions] followers-mention が 非フォロワー (メンション先である) から見れる', async(async () => {
|
|
|
|
const res = await request('/notes/mentions', { limit: 100 }, target);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(res.status, 200);
|
2019-01-29 06:46:24 +02:00
|
|
|
const notes = res.body.filter((n: any) => n.id == folM.id);
|
2019-04-07 15:50:36 +03:00
|
|
|
assert.strictEqual(notes[0].text, '@target x');
|
2019-01-29 06:46:24 +02:00
|
|
|
}));
|
|
|
|
//#endregion
|
|
|
|
});
|
|
|
|
});
|