Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: share the same user storage mock instance in tests #28119

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions test/e2e/tests/notifications/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ type MockResponse = {
* E2E mock setup for notification APIs (Auth, UserStorage, Notifications, Push Notifications, Profile syncing)
*
* @param server - server obj used to mock our endpoints
* @param userStorageMockttpController - optional controller to mock user storage endpoints
* @param userStorageMockttpControllerInstance - optional instance of UserStorageMockttpController, useful if you need persisted user storage between tests
*/
export async function mockNotificationServices(
server: Mockttp,
userStorageMockttpController?: UserStorageMockttpController,
userStorageMockttpControllerInstance: UserStorageMockttpController = new UserStorageMockttpController(),
) {
// Auth
mockAPICall(server, AuthMocks.getMockAuthNonceResponse());
mockAPICall(server, AuthMocks.getMockAuthLoginResponse());
mockAPICall(server, AuthMocks.getMockAuthAccessTokenResponse());

// Storage
if (!userStorageMockttpController?.paths.get('accounts')) {
new UserStorageMockttpController().setupPath('accounts', server);
if (!userStorageMockttpControllerInstance?.paths.get('accounts')) {
userStorageMockttpControllerInstance.setupPath('accounts', server);
}
if (!userStorageMockttpController?.paths.get('networks')) {
new UserStorageMockttpController().setupPath('networks', server);
if (!userStorageMockttpControllerInstance?.paths.get('networks')) {
userStorageMockttpControllerInstance.setupPath('networks', server);
}
if (!userStorageMockttpController?.paths.get('notifications')) {
new UserStorageMockttpController().setupPath('notifications', server);
if (!userStorageMockttpControllerInstance?.paths.get('notifications')) {
userStorageMockttpControllerInstance.setupPath('notifications', server);
}

// Notifications
Expand Down