Skip to content

Commit

Permalink
test(experience): update unit tests (migration-6) (#6420)
Browse files Browse the repository at this point in the history
* test(experience): update unit tests

update unit tests

* chore(experience): remove legacy APIs

remove legacy APIs
  • Loading branch information
simeng-li authored Aug 13, 2024
1 parent 3e643f4 commit 7365a9a
Show file tree
Hide file tree
Showing 22 changed files with 298 additions and 474 deletions.
3 changes: 3 additions & 0 deletions packages/experience/src/apis/api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import i18next from 'i18next';
import ky from 'ky';

import { kyPrefixUrl } from './const';

export default ky.extend({
prefixUrl: kyPrefixUrl,
hooks: {
beforeRequest: [
(request) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/experience/src/apis/consent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const consent = async (organizationId?: string) => {
};

return api
.post('/api/interaction/consent', {
.post('api/interaction/consent', {
json: {
organizationIds: organizationId && [organizationId],
},
Expand All @@ -17,5 +17,5 @@ export const consent = async (organizationId?: string) => {
};

export const getConsentInfo = async () => {
return api.get('/api/interaction/consent').json<ConsentInfoResponse>();
return api.get('api/interaction/consent').json<ConsentInfoResponse>();
};
1 change: 1 addition & 0 deletions packages/experience/src/apis/const.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const kyPrefixUrl = '/';
2 changes: 1 addition & 1 deletion packages/experience/src/apis/experience/const.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const prefix = '/api/experience';
export const prefix = 'api/experience';

export const experienceRoutes = Object.freeze({
prefix,
Expand Down
262 changes: 0 additions & 262 deletions packages/experience/src/apis/interaction.ts

This file was deleted.

10 changes: 8 additions & 2 deletions packages/experience/src/apis/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import ky from 'ky';
import type { SignInExperienceResponse } from '@/types';
import { searchKeys } from '@/utils/search-parameters';

import { kyPrefixUrl } from './const';

const buildSearchParameters = (record: Record<string, Nullable<Optional<string>>>) => {
const entries = Object.entries(record).filter((entry): entry is [string, string] =>
Boolean(entry[0] && entry[1])
Expand All @@ -27,7 +29,10 @@ const camelCase = (string: string): string =>

export const getSignInExperience = async <T extends SignInExperienceResponse>(): Promise<T> => {
return ky
.get('/api/.well-known/sign-in-exp', {
.extend({
prefixUrl: kyPrefixUrl,
})
.get('api/.well-known/sign-in-exp', {
searchParams: buildSearchParameters(
Object.fromEntries(
Object.values(searchKeys).map((key) => [camelCase(key), sessionStorage.getItem(key)])
Expand All @@ -46,6 +51,7 @@ export const getPhrases = async ({
}) =>
ky
.extend({
prefixUrl: kyPrefixUrl,
hooks: {
beforeRequest: [
(request) => {
Expand All @@ -56,7 +62,7 @@ export const getPhrases = async ({
],
},
})
.get('/api/.well-known/phrases', {
.get('api/.well-known/phrases', {
searchParams: buildSearchParameters({
lng: language,
}),
Expand Down
53 changes: 0 additions & 53 deletions packages/experience/src/apis/single-sign-on.ts

This file was deleted.

Loading

0 comments on commit 7365a9a

Please sign in to comment.