ChannelUserEditListTest.php 982 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. use Illuminate\Foundation\Testing\RefreshDatabase;
  3. uses(RefreshDatabase::class);
  4. /**
  5. * Skill 用 view=user-edit 列出「我能编辑的 channel」供用户交互式选择,
  6. * 而不是要求用户手工贴 channel uid(设计决策 3)。
  7. */
  8. it('lists the channels the user can edit', function () {
  9. $me = makeStudio('me');
  10. $mine = makeChannel($me, 'my channel');
  11. makeChannel(makeStudio('someone-else'), 'not mine');
  12. $rows = $this->getJson('/api/v2/channel?view=user-edit', authHeader($me))
  13. ->assertOk()
  14. ->json('data.rows');
  15. $uids = array_column($rows, 'uid');
  16. expect($uids)->toContain($mine);
  17. expect($uids)->toHaveCount(1);
  18. // 交互式选择要展示的字段
  19. expect($rows[0])->toHaveKeys(['uid', 'name', 'lang']);
  20. expect($rows[0]['name'])->toBe('my channel');
  21. });
  22. it('requires authentication', function () {
  23. $this->getJson('/api/v2/channel?view=user-edit')
  24. ->assertJsonPath('ok', false);
  25. });