Skip to content

Commit 2d065c9

Browse files
update stuff
1 parent 81da104 commit 2d065c9

File tree

3 files changed

+25
-7
lines changed

3 files changed

+25
-7
lines changed

packages/e2e-remote-config/remote-config-test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
# STAGING
2+
API_KEY="52fbe5356dc7490756a9c26591f2bb37"
3+
AMPLITUDE_VERSION="2.22.2"
4+
SERVER_ZONE="STAGING"
5+
SERVER_ZONE=$SERVER_ZONE API_KEY=$API_KEY AMPLITUDE_VERSION=$AMPLITUDE_VERSION npx playwright test packages/e2e-remote-config/test/e2e/fetch-remote-config.spec.ts
6+
17
# API_KEY empty
28
API_KEY="657954c4c37e22e8dc2af0413ac01e2b"
9+
SERVER_ZONE="US"
310
API_KEY=$API_KEY AMPLITUDE_VERSION=$AMPLITUDE_VERSION npx playwright test packages/e2e-remote-config/test/e2e/fetch-remote-config.spec.ts
411

512
# 2.11.0 -- first mionor version to support remote config for autocapture

packages/e2e-remote-config/test/e2e/fetch-remote-config.spec.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,41 +5,52 @@ import { test, expect } from '@playwright/test';
55
const remoteConfigUrl = 'https://sr-client-cfg.amplitude.com/';
66
const amplitudeVersion = process.env.AMPLITUDE_VERSION;
77
const apiKey = process.env.API_KEY;
8-
let redirectedServerUrl = process.env.REMOTE_CONFIG_URL || '';
8+
const serverZone = process.env.SERVER_ZONE || 'US';
9+
10+
let redirectedServerUrl = null;
11+
if (serverZone === 'STAGING') {
12+
redirectedServerUrl = 'https://sr-client-cfg.stag2.amplitude.com/';
13+
} else if (serverZone === 'EU') {
14+
redirectedServerUrl = 'https://sr-client-cfg.eu.amplitude.com/';
15+
}
16+
console.log(`Redirecting to server URL: ${redirectedServerUrl}`);
917

1018
if (redirectedServerUrl && !redirectedServerUrl?.endsWith('/')) {
1119
redirectedServerUrl += '/';
1220
}
1321

1422
const LOCAL_SITE = 'http://localhost:5173';
1523

16-
test.describe(`Fetch remote config sdkVersion=${amplitudeVersion || 'latest'} apiKey=${apiKey || 'default'}`, () => {
24+
test.describe(`Fetch remote config: remoteConfigUrl=${redirectedServerUrl} sdkVersion=${amplitudeVersion || 'latest'} apiKey=${apiKey || 'default'}`, () => {
1725
test('should fetch remote config', async ({ page }) => {
1826
// intercept the fetch request to the remote config
27+
let fullRemoteConfigUrl = remoteConfigUrl;
1928
await page.route(`${remoteConfigUrl}**`, async (route) => {
2029
if (redirectedServerUrl) {
2130
// edit the request to redirect to the redirectedServerUrl
2231
const request = route.request();
2332
const newUrl = request.url().replace(remoteConfigUrl, redirectedServerUrl);
33+
fullRemoteConfigUrl = newUrl;
2434
await route.continue({ url: newUrl });
2535
} else {
36+
fullRemoteConfigUrl = route.request().url();
2637
await route.continue();
2738
}
2839
});
29-
30-
const fetchRemoteConfigPromise = page.waitForResponse(`${remoteConfigUrl}*`);
40+
const responsePattern = redirectedServerUrl ? `${redirectedServerUrl}**` : `${remoteConfigUrl}**`;
41+
const fetchRemoteConfigPromise = page.waitForResponse(responsePattern);
3142
let queryParams: Record<string, string> = {};
3243
if (amplitudeVersion) {
3344
queryParams.amplitudeVersion = amplitudeVersion;
3445
}
3546
if (apiKey) {
3647
queryParams.apiKey = apiKey;
3748
}
38-
// TODO: parameterize this
39-
queryParams.serverZone = 'STAGING';
49+
queryParams.serverZone = serverZone;
4050
await page.goto(`${LOCAL_SITE}/remote-config-test.html?${new URLSearchParams(queryParams).toString()}`);
4151
const response = await fetchRemoteConfigPromise;
4252
const body = await response.json();
53+
console.log('body', body);
4354
expect(body.configs.analyticsSDK).toBeDefined();
4455
});
4556
});

test-server/remote-config-test.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ <h3>Event Log</h3>
9494
const API_ENDPOINTS = {
9595
US: 'https://api2.amplitude.com/2/httpapi',
9696
EU: 'https://api.eu.amplitude.com/2/httpapi',
97-
STAG: 'https://api.stag2.amplitude.com/2/httpapi',
97+
STAGING: 'https://api.stag2.amplitude.com/2/httpapi',
9898
};
9999

100100
window.SERVER_URL = API_ENDPOINTS[window.SERVER_ZONE?.toUpperCase()];

0 commit comments

Comments
 (0)