Public Access
feat(ui): add follow button, follows card, and inbox page
This commit is contained in:
1 parent
3aed243e35
commit
43c4862606
23 files changed
+603
-2
No files matched your search
@@ -25,6 +25,7 @@ function mockBackends({name = 'Lobo', profileStatus = 200, libraryStatus = 200,
|
||||
...(me && {
|
||||
'GET /api/users/me': json(200, me),
|
||||
'PUT /api/users/settings/profile-tiles': json(204, {}),
|
||||
'GET /api/follows': json(200, {following: [], followers: []}),
|
||||
}),
|
||||
});
|
||||
}
|
||||
@@ -238,6 +239,34 @@ describe('PublicProfilePage', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('offers "Follow" to a logged-in visitor, not to the owner and not to a guest', async () => {
|
||||
localStorage.setItem('tbp_session', '1');
|
||||
try {
|
||||
mockBackends({me: {displayName: 'Someone', role: 'USER'}});
|
||||
const visitor = renderPage();
|
||||
expect(await screen.findByRole('button', {name: 'FOLLOW.FOLLOW'})).toBeTruthy();
|
||||
visitor.unmount();
|
||||
|
||||
mockBackends({me: {displayName: 'Lobo', role: 'USER'}});
|
||||
renderPage();
|
||||
await screen.findByRole('button', {name: 'TILES.CUSTOMIZE'});
|
||||
expect(screen.queryByRole('button', {name: 'FOLLOW.FOLLOW'})).toBeNull();
|
||||
expect(fetch).not.toHaveBeenCalledWith(expect.stringContaining('/api/follows'), expect.anything());
|
||||
} finally {
|
||||
localStorage.clear();
|
||||
}
|
||||
});
|
||||
|
||||
it('offers no "Follow" to a guest', async () => {
|
||||
mockBackends();
|
||||
renderPage();
|
||||
|
||||
await screen.findByText('Portal 2');
|
||||
|
||||
expect(screen.queryByRole('button', {name: 'FOLLOW.FOLLOW'})).toBeNull();
|
||||
expect(fetch).not.toHaveBeenCalledWith(expect.stringContaining('/api/follows'), expect.anything());
|
||||
});
|
||||
|
||||
it('shows no "Customize" to a visitor', async () => {
|
||||
localStorage.setItem('tbp_session', '1');
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user