Skip to content

Commit 1b93d24

Browse files
committed
MPP-4282: (bugfix) removed hardcoded domains in prod
1 parent 2287d1a commit 1b93d24

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

frontend/src/apiMocks/mockData.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ export const mockIds = ["demo", "empty", "onboarding", "some", "full"] as const;
1010

1111
// This is the same for all mock users, at this time:
1212
export const mockedRuntimeData: RuntimeData = {
13-
FXA_ORIGIN: "https://fxa-mock.com",
14-
BASKET_ORIGIN: "https://basket-mock.com",
13+
// not sure if this is the mock url we want to use
14+
FXA_ORIGIN: "http://localhost/mock/fxa",
15+
BASKET_ORIGIN: "http://localhost/mock/basket",
1516
GOOGLE_ANALYTICS_ID: "UA-123456789-0",
1617
GA4_MEASUREMENT_ID: "G-YXT33S87LT",
1718
PERIODICAL_PREMIUM_PRODUCT_ID: "prod_123456789",

frontend/src/components/phones/onboarding/RelayNumberPicker.test.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { RelayNumberPicker } from "../onboarding/RelayNumberPicker";
33
import { OverlayProvider } from "react-aria";
44
import { useL10n } from "../../../hooks/l10n";
55
import * as relayNumberHooks from "../../../hooks/api/relayNumber";
6+
import { formatPhone } from "../../../functions/formatPhone";
67

78
jest.mock("../../../hooks/l10n", () => ({
89
useL10n: jest.fn(),
@@ -165,7 +166,8 @@ describe("RelayNumberPicker", () => {
165166
expect(relayNumberHooks.search).toHaveBeenCalledWith("999");
166167
});
167168

168-
const label = screen.getByLabelText("(999) 888 - 7777");
169+
const formatted = formatPhone("+19998887777");
170+
const label = await screen.findByLabelText(formatted);
169171
expect(label).toBeInTheDocument();
170172
});
171173

frontend/src/functions/getPlan.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ describe("Megabundle Tests", () => {
158158
);
159159

160160
const expectedLink =
161-
"https://fxa-mock.com/subscriptions/products/prod_123456789?plan=price_1RMAopKb9q6OnNsLSGe1vLtt";
161+
"http://localhost/mock/fxa/subscriptions/products/prod_123456789?plan=price_1RMAopKb9q6OnNsLSGe1vLtt";
162162

163163
expect(link).toBe(expectedLink);
164164
});

frontend/src/pages/_app.page.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import ReactGa from "react-ga";
99
import { getL10n } from "../functions/getL10n";
1010
import { AddonDataContext, useAddonElementWatcher } from "../hooks/addon";
1111
import { ReactAriaI18nProvider } from "../components/ReactAriaI18nProvider";
12-
import { initialiseApiMocks } from "../apiMocks/initialise";
13-
import { mockIds } from "../apiMocks/mockData";
1412
import { useIsLoggedIn } from "../hooks/session";
1513
import { useMetrics } from "../hooks/metrics";
1614
import {
@@ -60,6 +58,9 @@ function MyApp({ Component, pageProps }: AppProps) {
6058
return;
6159
}
6260
(async () => {
61+
const { initialiseApiMocks } = await import("../apiMocks/initialise");
62+
const { mockIds } = await import("../apiMocks/mockData");
63+
6364
await initialiseApiMocks();
6465

6566
if (

frontend/src/pages/mock/login.page.tsx

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import styles from "./mockSession.module.scss";
55
import { getRuntimeConfig } from "../../config";
66
import { apiFetch } from "../../hooks/api/api";
77
import { UsersData } from "../../hooks/api/user";
8-
import { mockIds } from "../../apiMocks/mockData";
98

109
type UsedToken = {
1110
token: string;
@@ -20,15 +19,18 @@ const MockLogin: NextPage = () => {
2019

2120
useEffect(() => {
2221
if (process.env.NEXT_PUBLIC_MOCK_API === "true") {
23-
// When the API is mocked out, the API tokens are fake as well:
24-
const mockIdsAsTokens: UsedToken[] = mockIds.map((id) => ({
25-
lastUsed: 0,
26-
token: id,
27-
user: `${id}@example.com`,
28-
}));
29-
setUsedTokens(mockIdsAsTokens);
22+
(async () => {
23+
const { mockIds } = await import("../../apiMocks/mockData");
24+
const mockIdsAsTokens: UsedToken[] = mockIds.map((id) => ({
25+
lastUsed: 0,
26+
token: id,
27+
user: `${id}@example.com`,
28+
}));
29+
setUsedTokens(mockIdsAsTokens);
30+
})();
3031
return;
3132
}
33+
3234
const usedTokensString = localStorage.getItem("usedTokens") ?? "[]";
3335
setUsedTokens(JSON.parse(usedTokensString).sort(byUseDate));
3436
}, []);

0 commit comments

Comments
 (0)