Merge branch 'renovate/all-minor-patch' into 'main'
[ProtonMail-WebClient.git] / packages / testing / lib / handlers.ts
blob8211e9cab069313fdcaa1102b5261ec13686e4f7
1 import { HttpResponse, http } from 'msw';
3 import { DEFAULT_MAILSETTINGS } from '@proton/shared/lib/mail/mailSettings';
5 import { addressBuilder, calendarBuilder, calendarEventBuilder, userBuilder } from './builders';
7 export const getHandlers = () => [
8     http.get('/addresses', () => {
9         return HttpResponse.json({
10             Addresses: [addressBuilder()],
11             Total: 1,
12         });
13     }),
14     http.get(`/calendar/v1/:calendarId/events/:eventId`, () => {
15         return HttpResponse.json({
16             Event: calendarEventBuilder(),
17         });
18     }),
19     http.get(`/calendar/v1`, () => {
20         return HttpResponse.json({
21             Calendars: [calendarBuilder()],
22         });
23     }),
24     http.get(`/calendar/v1/events`, () => {
25         return HttpResponse.json({
26             Events: [],
27         });
28     }),
29     http.get(`/users`, () => {
30         return HttpResponse.json({
31             User: userBuilder(),
32         });
33     }),
34     http.get(`/settings/calendar`, () => {
35         return HttpResponse.json({
36             CalendarUserSettings: {
37                 WeekStart: 1,
38                 WeekLength: 0,
39                 DisplayWeekNumber: 1,
40                 DateFormat: 0,
41                 TimeFormat: 0,
42                 AutoDetectPrimaryTimezone: 1,
43                 PrimaryTimezone: 'Europe/Zurich',
44                 DisplaySecondaryTimezone: 0,
45                 SecondaryTimezone: null,
46                 ViewPreference: 1,
47                 DefaultCalendarID:
48                     '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
49                 ShowCancelled: 1,
50                 ShowDeclined: 1,
51                 AutoImportInvite: 0,
52             },
53         });
54     }),
55     http.get(`/contacts/v4/contacts/emails`, () => {
56         return HttpResponse.json({
57             ContactEmails: [],
58         });
59     }),
60     http.get(`/calendar/v1/:calendarId/bootstrap`, () => {
61         return HttpResponse.json({
62             Keys: [
63                 {
64                     ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
65                     PrivateKey:
66                         '-----BEGIN PGP PRIVATE KEY BLOCK-----\nVersion: ProtonMail\n\nxYYEYZYvsxYJKwYBBAHaRw8BAQdA5OCfLNgBD9N1o+rbYZ+T0cebDmXdqID9\nztWaA1Ks6g/+CQMIW87X8JxZQJZgbrTx1CiT3KHTzu6OPHyodLoBFTHsxuUk\nSH/QffB34h5ZcqBwjKXMXAxSUvSYoq3hA3SDpHWiYvpzVrXQGQPn6Z7nCvyu\njM0MQ2FsZW5kYXIga2V5wo8EEBYKACAFAmGWL7MGCwkHCAMCBBUICgIEFgIB\nAAIZAQIbAwIeAQAhCRA5ciVSKZC25RYhBKVX9ChVLEMtyLclAzlyJVIpkLbl\nVB0A/3EAxSlLsbwwcB1FdygYmNpUNcIA1F2a3jq0HFEY1M0dAP0eoUy/wI7G\n9dPWOdfIhsLpS8LZsnnlxXQCevonOi7xAceLBGGWL7MSCisGAQQBl1UBBQEB\nB0AYjNLjQgjzxU8rqfjXfiv/hIDBztnCHIHNC8bhHSMsWwMBCAf+CQMIccKl\n/DITNo5gvvFNaFhF6sKRd5KeOs7BPd/J1FZfmaEK5RF/o524eofdq7I3xp3F\nRTDmQ9XGKe237ixzBuX/Dlmb0BDAIXifTe9F23HQO8J4BBgWCAAJBQJhli+z\nAhsMACEJEDlyJVIpkLblFiEEpVf0KFUsQy3ItyUDOXIlUimQtuX8gQEA4xUQ\n4wbiOtsy+wimRQAzG3W5XWbpxcOdAhNWgen1EFIBANqbYe0rHPzfs6Jya6II\nXLLT5roLSphpuYwODd+GQ3kL\n=YRWm\n-----END PGP PRIVATE KEY BLOCK-----\n',
67                     PassphraseID:
68                         '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
69                     Flags: 3,
70                     CalendarID:
71                         '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
72                 },
73             ],
74             Passphrase: {
75                 Flags: 1,
76                 ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
77                 MemberPassphrases: [
78                     {
79                         MemberID:
80                             '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
81                         Passphrase:
82                             '-----BEGIN PGP MESSAGE-----\nVersion: ProtonMail\n\nwV4DclxUAN87lmsSAQdAo9FgKmAgiR5vwuLn1O5Ms1RFNPR9Z3H5UMtk0A7q\nrFUwIIX6blb/51oAAi2T7Arp++gx/S+EUr0T1keB2wYMansZsYclQbXfix6s\nnWrxoejL0mQBV6qx9TtuDAvOFIEy0EXEsY2QKg8QjAsz01siPoYLXOV3xJm6\nwD8U72xxxxvoMtIsx5OmmQYDzqpFTasZCgGJxsCo/y/tI+089KPjjC1YRHKG\ng6uJr+BnQrv7vsi65+AjRgmW\n=znTY\n-----END PGP MESSAGE-----\n',
83                         Signature:
84                             '-----BEGIN PGP SIGNATURE-----\nVersion: ProtonMail\n\nwnUEARYKAAYFAmGWL+8AIQkQ1oODHu7bPjIWIQTbrouLuU2xuMzp19LWg4Me\n7ts+MialAQCWwcs4GNahH4ZwGLxoQ5zpFCcieySg9sg1fYoSJXdYLAEApOc2\nxmZLBSMdpd4QrfWp2IhIyro6bO4s6NFRhElLmAw=\n=n64B\n-----END PGP SIGNATURE-----\n',
85                     },
86                 ],
87                 CalendarID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
88             },
89             Members: [
90                 {
91                     ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
92                     Permissions: 127,
93                     Email: 'stest1@proton.black',
94                     AddressID:
95                         'Lw5suur9q0eTrcp-ufF41Ar7WNj5FQQFz_iKVcCD8khv0eVLJ8MPyx9oiI1XfZJ3JVuTmpG2dgOIY2zCCrIVIw==',
96                     CalendarID:
97                         '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
98                     Color: '#5EC7B7',
99                     Display: 1,
100                 },
101             ],
102             CalendarSettings: {
103                 ID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
104                 CalendarID: '8DqHHGgVZgEb9KJ0En3mhktAcUBNlAEfGdp5-KnBy2WedZq2Th_gBhphVfcSITxDpz914-LvghzmLf5dhOB5HQ==',
105                 DefaultEventDuration: 30,
106                 DefaultPartDayNotifications: [
107                     {
108                         Type: 1,
109                         Trigger: '-PT15M',
110                     },
111                 ],
112                 DefaultFullDayNotifications: [
113                     {
114                         Type: 1,
115                         Trigger: '-PT15H',
116                     },
117                 ],
118             },
119         });
120     }),
121     http.get(`/mail/v4/settings`, () => {
122         return HttpResponse.json({
123             MailSettings: DEFAULT_MAILSETTINGS,
124         });
125     }),