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

fix: profile-sync-controller mobile compilation issues #4721

Merged
merged 2 commits into from
Sep 20, 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
Original file line number Diff line number Diff line change
Expand Up @@ -33,43 +33,70 @@ export const getMockUserStorageEndpoint = (
)}`;
};

export const createMockGetStorageResponse = async (
/**
* Creates a mock GET user-storage response
* @param data - data to encrypt
* @returns a realistic GET Response Body
*/
export async function createMockGetStorageResponse(
data?: string,
): Promise<GetUserStorageResponse> => ({
HashedKey: 'HASHED_KEY',
Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),
});
): Promise<GetUserStorageResponse> {
return {
HashedKey: 'HASHED_KEY',
Data: await MOCK_ENCRYPTED_STORAGE_DATA(data),
};
}

export const createMockAllFeatureEntriesResponse = async (
/**
* Creates a mock GET ALL user-storage response
* @param dataArr - array of data to encrypt
* @returns a realistic GET ALL Response Body
*/
export async function createMockAllFeatureEntriesResponse(
dataArr: string[] = [MOCK_STORAGE_DATA],
): Promise<GetUserStorageAllFeatureEntriesResponse> =>
Promise.all(
dataArr.map(async (d) => ({
HashedKey: 'HASHED_KEY',
Data: await MOCK_ENCRYPTED_STORAGE_DATA(d),
})),
): Promise<GetUserStorageAllFeatureEntriesResponse> {
return await Promise.all(
dataArr.map(async function (d) {
const encryptedData = await MOCK_ENCRYPTED_STORAGE_DATA(d);
return {
HashedKey: 'HASHED_KEY',
Data: encryptedData,
};
}),
);
}

export const getMockUserStorageGetResponse = async (
/**
* Creates a mock user-storage api GET request
* @param path - path of the GET Url
* @returns mock GET API request. Can be used by e2e or unit mock servers
*/
export async function getMockUserStorageGetResponse(
path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',
) => {
) {
return {
url: getMockUserStorageEndpoint(path),
requestMethod: 'GET',
response: await createMockGetStorageResponse(),
} satisfies MockResponse;
};
}

export const getMockUserStorageAllFeatureEntriesResponse = async (
/**
* Creates a mock user-storage api GET ALL request
* @param path - path of the GET url
* @param dataArr - data to encrypt
* @returns mock GET ALL API request. Can be used by e2e or unit mock servers
*/
export async function getMockUserStorageAllFeatureEntriesResponse(
path: UserStoragePathWithFeatureOnly = 'notifications',
dataArr?: string[],
) => {
) {
return {
url: getMockUserStorageEndpoint(path),
requestMethod: 'GET',
response: await createMockAllFeatureEntriesResponse(dataArr),
} satisfies MockResponse;
};
}

export const getMockUserStoragePutResponse = (
path: UserStoragePathWithFeatureAndKey = 'notifications.notification_settings',
Expand Down
Loading