Skip to content

Commit 58d1f2e

Browse files
fix test
1 parent 264113d commit 58d1f2e

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

test/cdn.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { AppConfigurationClient } from "@azure/app-configuration";
1111
import { loadFromAzureFrontDoor } from "../src/index.js";
1212
import { createMockedKeyValue, createMockedFeatureFlag, HttpRequestHeadersPolicy, getCachedIterator, sinon, restoreMocks, createMockedAzureFrontDoorEndpoint, sleepInMs } from "./utils/testHelper.js";
1313
import { TIMESTAMP_HEADER } from "../src/cdn/constants.js";
14+
import { isBrowser } from "../src/requestTracing/utils.js";
1415

1516
function createTimestampHeaders(timestamp: string | Date) {
1617
const value = timestamp instanceof Date ? timestamp.toUTCString() : new Date(timestamp).toUTCString();
@@ -49,7 +50,15 @@ describe("loadFromAzureFrontDoor", function() {
4950
} catch { /* empty */ }
5051

5152
expect(headerPolicy.headers).not.undefined;
52-
expect(headerPolicy.headers.get("User-Agent")).satisfy((ua: string) => ua.startsWith("javascript-appconfiguration-provider"));
53+
let userAgent;
54+
// https://github.com/Azure/azure-sdk-for-js/pull/6528
55+
if (isBrowser()) {
56+
userAgent = headerPolicy.headers.get("x-ms-useragent");
57+
} else {
58+
userAgent = headerPolicy.headers.get("User-Agent");
59+
}
60+
61+
expect(userAgent).satisfy((ua: string) => ua.startsWith("javascript-appconfiguration-provider"));
5362
expect(headerPolicy.headers.get("authorization")).to.be.undefined;
5463
expect(headerPolicy.headers.get("Authorization")).to.be.undefined;
5564
});

test/requestTracing.test.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const expect = chai.expect;
99
import { HttpRequestHeadersPolicy, createMockedConnectionString, createMockedKeyValue, createMockedFeatureFlag, createMockedTokenCredential, mockAppConfigurationClientListConfigurationSettings, restoreMocks, sinon, sleepInMs } from "./utils/testHelper.js";
1010
import { ConfigurationClientManager } from "../src/configurationClientManager.js";
1111
import { load, loadFromAzureFrontDoor } from "../src/index.js";
12+
import { isBrowser } from "../src/requestTracing/utils.js";
1213

1314
const CORRELATION_CONTEXT_HEADER_NAME = "Correlation-Context";
1415

@@ -43,7 +44,15 @@ describe("request tracing", function () {
4344
});
4445
} catch { /* empty */ }
4546
expect(headerPolicy.headers).not.undefined;
46-
expect(headerPolicy.headers.get("User-Agent")).satisfy((ua: string) => ua.startsWith("javascript-appconfiguration-provider"));
47+
let userAgent;
48+
// https://github.com/Azure/azure-sdk-for-js/pull/6528
49+
if (isBrowser()) {
50+
userAgent = headerPolicy.headers.get("x-ms-useragent");
51+
} else {
52+
userAgent = headerPolicy.headers.get("User-Agent");
53+
}
54+
55+
expect(userAgent).satisfy((ua: string) => ua.startsWith("javascript-appconfiguration-provider"));
4756
});
4857

4958
it("should have request type in correlation-context header", async () => {

vitest.browser.config.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,19 @@ export default defineConfig({
1010
{ browser: "chromium" },
1111
],
1212
},
13-
include: ["out/esm/test/load.test.js", "out/esm/test/refresh.test.js", "out/esm/test/featureFlag.test.js", "out/esm/test/json.test.js", "out/esm/test/startup.test.js", "out/esm/test/cdn.test.js"],
13+
include: [
14+
"out/esm/test/load.test.js",
15+
"out/esm/test/refresh.test.js",
16+
"out/esm/test/featureFlag.test.js",
17+
"out/esm/test/json.test.js",
18+
"out/esm/test/startup.test.js",
19+
"out/esm/test/cdn.test.js"
20+
],
1421
testTimeout: 200_000,
1522
hookTimeout: 200_000,
1623
reporters: "default",
1724
globals: true,
1825
// Provide Mocha-style hooks as globals
1926
setupFiles: ["./vitest.setup.mjs"],
2027
},
21-
});
28+
});

0 commit comments

Comments
 (0)