diff options
Diffstat (limited to 'server/tests/api/users/user-subscriptions.ts')
-rw-r--r-- | server/tests/api/users/user-subscriptions.ts | 156 |
1 files changed, 156 insertions, 0 deletions
diff --git a/server/tests/api/users/user-subscriptions.ts b/server/tests/api/users/user-subscriptions.ts index 441f70d07..b49367be6 100644 --- a/server/tests/api/users/user-subscriptions.ts +++ b/server/tests/api/users/user-subscriptions.ts | |||
@@ -368,6 +368,162 @@ describe('Test users subscriptions', function () { | |||
368 | } | 368 | } |
369 | }) | 369 | }) |
370 | 370 | ||
371 | it('Should follow user channels of server 3 by root of server 3', async function () { | ||
372 | this.timeout(60000) | ||
373 | |||
374 | await servers[2].channels.create({ token: users[2].accessToken, attributes: { name: 'user3_channel2' } }) | ||
375 | |||
376 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel@localhost:' + servers[2].port }) | ||
377 | await servers[2].subscriptions.add({ token: servers[2].accessToken, targetUri: 'user3_channel2@localhost:' + servers[2].port }) | ||
378 | |||
379 | await waitJobs(servers) | ||
380 | }) | ||
381 | |||
382 | it('Should list user 3 followers', async function () { | ||
383 | { | ||
384 | const { total, data } = await servers[2].accounts.listFollowers({ | ||
385 | token: users[2].accessToken, | ||
386 | accountName: 'user3', | ||
387 | start: 0, | ||
388 | count: 5, | ||
389 | sort: 'createdAt' | ||
390 | }) | ||
391 | |||
392 | expect(total).to.equal(3) | ||
393 | expect(data[0].following.host).to.equal(servers[2].host) | ||
394 | expect(data[0].following.name).to.equal('user3_channel') | ||
395 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
396 | expect(data[0].follower.name).to.equal('user1') | ||
397 | |||
398 | expect(data[1].following.host).to.equal(servers[2].host) | ||
399 | expect(data[1].following.name).to.equal('user3_channel') | ||
400 | expect(data[1].follower.host).to.equal(servers[2].host) | ||
401 | expect(data[1].follower.name).to.equal('root') | ||
402 | |||
403 | expect(data[2].following.host).to.equal(servers[2].host) | ||
404 | expect(data[2].following.name).to.equal('user3_channel2') | ||
405 | expect(data[2].follower.host).to.equal(servers[2].host) | ||
406 | expect(data[2].follower.name).to.equal('root') | ||
407 | } | ||
408 | |||
409 | { | ||
410 | const { total, data } = await servers[2].accounts.listFollowers({ | ||
411 | token: users[2].accessToken, | ||
412 | accountName: 'user3', | ||
413 | start: 0, | ||
414 | count: 1, | ||
415 | sort: '-createdAt' | ||
416 | }) | ||
417 | |||
418 | expect(total).to.equal(3) | ||
419 | expect(data[0].following.host).to.equal(servers[2].host) | ||
420 | expect(data[0].following.name).to.equal('user3_channel2') | ||
421 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
422 | expect(data[0].follower.name).to.equal('root') | ||
423 | } | ||
424 | |||
425 | { | ||
426 | const { total, data } = await servers[2].accounts.listFollowers({ | ||
427 | token: users[2].accessToken, | ||
428 | accountName: 'user3', | ||
429 | start: 1, | ||
430 | count: 1, | ||
431 | sort: '-createdAt' | ||
432 | }) | ||
433 | |||
434 | expect(total).to.equal(3) | ||
435 | expect(data[0].following.host).to.equal(servers[2].host) | ||
436 | expect(data[0].following.name).to.equal('user3_channel') | ||
437 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
438 | expect(data[0].follower.name).to.equal('root') | ||
439 | } | ||
440 | |||
441 | { | ||
442 | const { total, data } = await servers[2].accounts.listFollowers({ | ||
443 | token: users[2].accessToken, | ||
444 | accountName: 'user3', | ||
445 | search: 'user1', | ||
446 | sort: '-createdAt' | ||
447 | }) | ||
448 | |||
449 | expect(total).to.equal(1) | ||
450 | expect(data[0].following.host).to.equal(servers[2].host) | ||
451 | expect(data[0].following.name).to.equal('user3_channel') | ||
452 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
453 | expect(data[0].follower.name).to.equal('user1') | ||
454 | } | ||
455 | }) | ||
456 | |||
457 | it('Should list user3_channel followers', async function () { | ||
458 | { | ||
459 | const { total, data } = await servers[2].channels.listFollowers({ | ||
460 | token: users[2].accessToken, | ||
461 | channelName: 'user3_channel', | ||
462 | start: 0, | ||
463 | count: 5, | ||
464 | sort: 'createdAt' | ||
465 | }) | ||
466 | |||
467 | expect(total).to.equal(2) | ||
468 | expect(data[0].following.host).to.equal(servers[2].host) | ||
469 | expect(data[0].following.name).to.equal('user3_channel') | ||
470 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
471 | expect(data[0].follower.name).to.equal('user1') | ||
472 | |||
473 | expect(data[1].following.host).to.equal(servers[2].host) | ||
474 | expect(data[1].following.name).to.equal('user3_channel') | ||
475 | expect(data[1].follower.host).to.equal(servers[2].host) | ||
476 | expect(data[1].follower.name).to.equal('root') | ||
477 | } | ||
478 | |||
479 | { | ||
480 | const { total, data } = await servers[2].channels.listFollowers({ | ||
481 | token: users[2].accessToken, | ||
482 | channelName: 'user3_channel', | ||
483 | start: 0, | ||
484 | count: 1, | ||
485 | sort: '-createdAt' | ||
486 | }) | ||
487 | |||
488 | expect(total).to.equal(2) | ||
489 | expect(data[0].following.host).to.equal(servers[2].host) | ||
490 | expect(data[0].following.name).to.equal('user3_channel') | ||
491 | expect(data[0].follower.host).to.equal(servers[2].host) | ||
492 | expect(data[0].follower.name).to.equal('root') | ||
493 | } | ||
494 | |||
495 | { | ||
496 | const { total, data } = await servers[2].channels.listFollowers({ | ||
497 | token: users[2].accessToken, | ||
498 | channelName: 'user3_channel', | ||
499 | start: 1, | ||
500 | count: 1, | ||
501 | sort: '-createdAt' | ||
502 | }) | ||
503 | |||
504 | expect(total).to.equal(2) | ||
505 | expect(data[0].following.host).to.equal(servers[2].host) | ||
506 | expect(data[0].following.name).to.equal('user3_channel') | ||
507 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
508 | expect(data[0].follower.name).to.equal('root') | ||
509 | } | ||
510 | |||
511 | { | ||
512 | const { total, data } = await servers[2].channels.listFollowers({ | ||
513 | token: users[2].accessToken, | ||
514 | channelName: 'user3_channel', | ||
515 | search: 'user1', | ||
516 | sort: '-createdAt' | ||
517 | }) | ||
518 | |||
519 | expect(total).to.equal(1) | ||
520 | expect(data[0].following.host).to.equal(servers[2].host) | ||
521 | expect(data[0].following.name).to.equal('user3_channel') | ||
522 | expect(data[0].follower.host).to.equal(servers[0].host) | ||
523 | expect(data[0].follower.name).to.equal('user1') | ||
524 | } | ||
525 | }) | ||
526 | |||
371 | after(async function () { | 527 | after(async function () { |
372 | await cleanupTests(servers) | 528 | await cleanupTests(servers) |
373 | }) | 529 | }) |