Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f934a31
Initial plan
Copilot Jul 7, 2025
47da5a0
Convert first batch of testCaseAsync to modern asyncQueue pattern
Copilot Jul 7, 2025
4a93f43
Complete migration for validate.e2e.tests.ts and CdnThrottle.tests.ts
Copilot Jul 7, 2025
cd14663
Complete migration for sanitizer.e2e.tests.ts
Copilot Jul 7, 2025
0c8b4df
Continue migration progress for SnippetInitialization.Tests.ts
Copilot Jul 7, 2025
17226c3
Demonstrate complete migration pattern with examples from all file types
Copilot Jul 7, 2025
ad44d74
Fix async test patterns to move setup code before _asyncQueue() calls
Copilot Jul 9, 2025
3f934f6
Apply async test pattern fix: move setup code before _asyncQueue() calls
Copilot Jul 9, 2025
69a7336
Fix formatting: remove extra space before testCase call
Copilot Jul 10, 2025
1be134d
Standardize async queue method to use .concat() consistently across a…
Copilot Jul 10, 2025
f0b6138
Update async tests to use .add() instead of .concat() for consistency
Copilot Jul 11, 2025
de36503
Update npm dependencies and confirm async test pattern is correctly a…
Copilot Jul 24, 2025
3d5693a
Fix TypeScript compilation errors in applicationinsights.e2e.tests.ts…
Copilot Jul 25, 2025
90dde69
Continue migration: fix 3 more testCaseAsync compilation errors
Copilot Jul 25, 2025
c4352b3
Continue migration: fix 3 more testCaseAsync compilation errors (down…
Copilot Jul 25, 2025
df20568
Continue migration: fix 2 more testCaseAsync compilation errors (down…
Copilot Jul 25, 2025
86e3210
Major migration progress: fixed 15 more testCaseAsync compilation err…
Copilot Jul 25, 2025
2742ae3
Fix 6 specific TypeScript compilation errors by converting testCaseAs…
Copilot Jul 28, 2025
961307b
Fix remaining TypeScript compilation errors by converting final two t…
Copilot Jul 31, 2025
7d6e8b9
Fix 6 remaining TypeScript compilation errors in SnippetInitializatio…
Copilot Jul 31, 2025
dfa8ed6
Fix all remaining TypeScript compilation errors in SnippetInitializat…
Copilot Jul 31, 2025
646044a
Fix runtime error: resolve TypeError: nextTestStep is not a function …
Copilot Jul 31, 2025
ee01062
Fix TypeScript compilation errors: add missing asserts_9499 declarations
Copilot Aug 5, 2025
b7ec71c
Remove changes to npm-shrinkwrap.json as requested
Copilot Aug 5, 2025
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
188 changes: 97 additions & 91 deletions AISKU/Tests/Unit/src/CdnThrottle.tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,10 @@ export class CdnThrottle extends AITestClass {
}

public registerTests() {
this.testCaseAsync({
this.testCase({
name: "CfgSyncPlugin: customer enable ikey messsage change, new config fetch from config url overwrite throttle setting and send message",
stepDelay: 10,
useFakeTimers: true,
steps: [ () => {
test: () => {
let doc = getGlobal();
hookFetch((resolve) => { // global instance cannot access test private instance
AITestClass.orgSetTimeout(function() {
Expand All @@ -194,31 +193,32 @@ export class CdnThrottle extends AITestClass {
});
this.init.loadAppInsights();
this._ai = this.init;
}].concat(PollingAssert.createPollingAssert(() => {
if (this.fetchStub.called){
let core = this._ai['core'];
let _logger = core.logger;
let loggingSpy = this.sandbox.stub(_logger, 'throwInternal');
Assert.equal(loggingSpy.called, 0);

// now enable feature
this.init.config.featureOptIn = {["iKeyUsage"]: {mode: FeatureOptInMode.enable}};
this.clock.tick(1);
Assert.equal(loggingSpy.called, 1);
Assert.equal(_eInternalMessageId.InstrumentationKeyDeprecation, loggingSpy.args[0][1]);
let message= loggingSpy.args[0][2];
Assert.ok(message.includes("Instrumentation key"));
return true;
}
return false;

}, "response received", 60, 1000) as any)
return this._asyncQueue().add(PollingAssert.createPollingAssert(() => {
if (this.fetchStub.called){
let core = this._ai['core'];
let _logger = core.logger;
let loggingSpy = this.sandbox.stub(_logger, 'throwInternal');
Assert.equal(loggingSpy.called, 0);

// now enable feature
this.init.config.featureOptIn = {["iKeyUsage"]: {mode: FeatureOptInMode.enable}};
this.clock.tick(1);
Assert.equal(loggingSpy.called, 1);
Assert.equal(_eInternalMessageId.InstrumentationKeyDeprecation, loggingSpy.args[0][1]);
let message= loggingSpy.args[0][2];
Assert.ok(message.includes("Instrumentation key"));
return true;
}
return false;

}, "response received", 60, 1000) as any);
}
});
this.testCaseAsync({
this.testCase({
name: "CfgSyncPlugin: customer didn't set throttle config, successfully fetch from config url",
stepDelay: 10,
useFakeTimers: true,
steps: [ () => {
test: () => {
let doc = getGlobal();
hookFetch((resolve) => { // global instance cannot access test private instance
AITestClass.orgSetTimeout(function() {
Expand All @@ -232,27 +232,28 @@ export class CdnThrottle extends AITestClass {
});
this.init.loadAppInsights();
this._ai = this.init;
}].concat(PollingAssert.createPollingAssert(() => {

if (this.fetchStub.called){
let plugin = this._ai.appInsights['core'].getPlugin<CfgSyncPlugin>(this.identifier).plugin;
let newCfg = plugin.getCfg();
Assert.equal(JSON.stringify(newCfg.throttleMgrCfg), JSON.stringify(sampleConfig.throttleMgrCfg));
// cdn should not be changed
let cdnCfg = this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation];
Assert.equal(JSON.stringify(cdnCfg), JSON.stringify(default_throttle_config));
return true;
}
return false;

}, "response received", 60, 1000) as any)
return this._asyncQueue().add(PollingAssert.createPollingAssert(() => {

if (this.fetchStub.called){
let plugin = this._ai.appInsights['core'].getPlugin<CfgSyncPlugin>(this.identifier).plugin;
let newCfg = plugin.getCfg();
Assert.equal(JSON.stringify(newCfg.throttleMgrCfg), JSON.stringify(sampleConfig.throttleMgrCfg));
// cdn should not be changed
let cdnCfg = this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation];
Assert.equal(JSON.stringify(cdnCfg), JSON.stringify(default_throttle_config));
return true;
}
return false;

}, "response received", 60, 1000) as any);
}
});

this.testCaseAsync({
this.testCase({
name: "CfgSyncPlugin: customer didn't set feature opt in, successfully get aisku default and fetch from config url, get disable zip config to be true",
stepDelay: 10,
useFakeTimers: true,
steps: [ () => {
test: () => {
let doc = getGlobal();
hookFetch((resolve) => { // global instance cannot access test private instance
AITestClass.orgSetTimeout(function() {
Expand All @@ -274,21 +275,22 @@ export class CdnThrottle extends AITestClass {
});
this.init.loadAppInsights();
this._ai = this.init;
}].concat(PollingAssert.createPollingAssert(() => {
if (this.fetchStub.called){
let newCfg = this._ai.config;
Assert.equal(newCfg.featureOptIn["zipPayload"]["mode"], FeatureOptInMode.enable); // aisku default is none, overwrite to true by cdn config
return true;
}
return false;
}, "response received", 60, 1000) as any)

return this._asyncQueue().add(PollingAssert.createPollingAssert(() => {
if (this.fetchStub.called){
let newCfg = this._ai.config;
Assert.equal(newCfg.featureOptIn["zipPayload"]["mode"], FeatureOptInMode.enable); // aisku default is none, overwrite to true by cdn config
return true;
}
return false;
}, "response received", 60, 1000) as any);
}
});

this.testCaseAsync({
this.testCase({
name: "CfgSyncPlugin: customer set throttle config, new config fetch from config url could overwrite original one",
stepDelay: 10,
useFakeTimers: true,
steps: [ () => {
test: () => {
let doc = getGlobal();
hookFetch((resolve) => { // global instance cannot access test private instance
AITestClass.orgSetTimeout(function() {
Expand Down Expand Up @@ -324,28 +326,29 @@ export class CdnThrottle extends AITestClass {
});
this.init.loadAppInsights();
this._ai = this.init;
}].concat(PollingAssert.createPollingAssert(() => {

if (this.fetchStub.called){
let plugin = this._ai.appInsights['core'].getPlugin<CfgSyncPlugin>(this.identifier).plugin;
let newCfg = plugin.getCfg();
Assert.equal(JSON.stringify(newCfg.throttleMgrCfg), JSON.stringify(sampleConfig.throttleMgrCfg));
// cdn should not be overwritten
let cdnCfg = this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation];
Assert.equal(JSON.stringify(cdnCfg), JSON.stringify(default_throttle_config));
let ikeyCfg = this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation];
Assert.equal(JSON.stringify(ikeyCfg), JSON.stringify(sampleConfig.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation]));
return true;
}
return false;
}, "response received", 60, 1000) as any)

return this._asyncQueue().add(PollingAssert.createPollingAssert(() => {

if (this.fetchStub.called){
let plugin = this._ai.appInsights['core'].getPlugin<CfgSyncPlugin>(this.identifier).plugin;
let newCfg = plugin.getCfg();
Assert.equal(JSON.stringify(newCfg.throttleMgrCfg), JSON.stringify(sampleConfig.throttleMgrCfg));
// cdn should not be overwritten
let cdnCfg = this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation];
Assert.equal(JSON.stringify(cdnCfg), JSON.stringify(default_throttle_config));
let ikeyCfg = this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation];
Assert.equal(JSON.stringify(ikeyCfg), JSON.stringify(sampleConfig.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation]));
return true;
}
return false;
}, "response received", 60, 1000) as any);
}
});

this.testCaseAsync({
this.testCase({
name: "CfgSyncPlugin: customer enable feature opt in, then the config in cdn feature opt in is applied",
stepDelay: 10,
useFakeTimers: true,
steps: [ () => {
test: () => {
let doc = getGlobal();
hookFetch((resolve) => { // global instance cannot access test private instance
AITestClass.orgSetTimeout(function() {
Expand All @@ -366,23 +369,24 @@ export class CdnThrottle extends AITestClass {
});
this.init.loadAppInsights();
this._ai = this.init;
}].concat(PollingAssert.createPollingAssert(() => {

if (this.fetchStub.called){
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].disabled, false);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation].disabled, true);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber, throttleCfgDisable[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber);
return true;
}
return false;
}, "response received", 60, 1000) as any)

return this._asyncQueue().add(PollingAssert.createPollingAssert(() => {

if (this.fetchStub.called){
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].disabled, false);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation].disabled, true);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber, throttleCfgDisable[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber);
return true;
}
return false;
}, "response received", 60, 1000) as any);
}
});

this.testCaseAsync({
this.testCase({
name: "CfgSyncPlugin: customer disable feature opt in, the origin config on cdn will apply",
stepDelay: 10,
useFakeTimers: true,
steps: [ () => {
test: () => {
let doc = getGlobal();
hookFetch((resolve) => { // global instance cannot access test private instance
AITestClass.orgSetTimeout(function() {
Expand All @@ -403,15 +407,17 @@ export class CdnThrottle extends AITestClass {
});
this.init.loadAppInsights();
this._ai = this.init;
}].concat(PollingAssert.createPollingAssert(() => {
if (this.fetchStub.called){
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].disabled, true);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation].disabled, true);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber, throttleCfgDisable[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber);
return true;
}
return false;
}, "response received", 60, 1000) as any)

return this._asyncQueue().add(PollingAssert.createPollingAssert(() => {
if (this.fetchStub.called){
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].disabled, true);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.CdnDeprecation].disabled, true);
Assert.equal(this.init.config.throttleMgrCfg[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber, throttleCfgDisable[_eInternalMessageId.InstrumentationKeyDeprecation].limit?.maxSendNumber);
return true;
}
return false;
}, "response received", 60, 1000) as any);
}
});


Expand Down
Loading
Loading