fix(social): complete shared listening request lifecycle
This commit is contained in:
1 parent
cb22f15912
commit
59983ed1b3
14 files changed
+302
-18
No files matched your search
@@ -1,4 +1,4 @@
|
||||
import { fakeApi, makeUser } from './fakeApi';
|
||||
import { albumTracks, fakeApi, makeUser } from './fakeApi';
|
||||
import { mobileFixtures } from './mobileFixtures';
|
||||
|
||||
/** Подменяет fetch на фейковый API. Включается только при сборке с VITE_E2E=1. */
|
||||
@@ -14,6 +14,21 @@ export function installE2EFetch() {
|
||||
const alice = [...api.users.values()].find(u => u.username === 'alice')!;
|
||||
const friend = [...api.users.values()].find(u => u.username === 'moderator')!;
|
||||
api.friendships.set([alice.id, friend.id].sort().join(':'), { sender: friend.id, accepted: true });
|
||||
const listeningScenario = localStorage.getItem('pipu.e2e.listening');
|
||||
if (listeningScenario) {
|
||||
const device = crypto.randomUUID();
|
||||
api.presence.set(friend.id, Date.now());
|
||||
api.activityVisibility.set(friend.id, 'friends');
|
||||
api.activity.set(friend.id, { device_id: device, track_id: albumTracks[0]!.id, track_title: albumTracks[0]!.title, artist: 'Кино', context: 'other', position_ms: 0 });
|
||||
api.listeningPreferences.set(friend.id, { requests: listeningScenario === 'restricted' ? 'nobody' : 'friends', auto_accept: listeningScenario === 'automatic' ? 'friends' : 'nobody', autoplay: true });
|
||||
if (listeningScenario === 'incoming') {
|
||||
const roomId = crypto.randomUUID();
|
||||
const requestId = crypto.randomUUID();
|
||||
api.listeningRooms.set(roomId, { id: roomId, owner_id: friend.id, owner_name: friend.username, device_id: device, track_id: albumTracks[0]!.id, position_ms: 0, playing: false, updated_at: new Date().toISOString(), participants: [] });
|
||||
api.listeningMembers.set(friend.id, roomId);
|
||||
api.listeningRequests.set(requestId, { id: requestId, owner_id: friend.id, guest_id: alice.id, sender_id: friend.id, sender_name: friend.username, recipient_id: alice.id, kind: 'invite', expires_at: new Date(Date.now() + 120_000).toISOString() });
|
||||
}
|
||||
}
|
||||
if (localStorage.getItem('pipu.e2e.notifications') === '1') {
|
||||
const kinds = ['message', 'friend_request', 'friend_accepted', 'music'] as const;
|
||||
for (let index = 0; index < 28; index++) api.notifications.push({
|
||||
|
||||
Reference in new issue
Block a user