Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 9, 2025

This PR updates all async unit tests in the AISKULight directory to use the modern _asyncQueue pattern instead of the deprecated testCaseAsync pattern, as referenced in PR #2544.

Changes Made

Updated 3 async tests in /AISKULight/Tests/Unit/src/dynamicconfig.tests.ts:

  1. "Init: init with cs promise" - Test for initializing ApplicationInsights with a connection string promise
  2. "zip test: gzip encode is working and content-encode header is set (feature opt-in)" - Test for gzip encoding when feature is enabled
  3. "zip test: gzip encode will not working (feature opt-in is not set)" - Test for no gzip encoding when feature is disabled

Migration Details

Before (deprecated pattern):

this.testCaseAsync({
    name: "test name",
    stepDelay: 100,
    useFakeTimers: true,
    steps: [() => {
        // setup code
    }].concat(PollingAssert.createPollingAssert(() => {
        // polling logic
        return condition;
    }, "message", 60, 1000) as any)
});

After (modern pattern):

this.testCase({
    name: "test name", 
    useFakeTimers: true,
    test: () => {
        // setup code
        
        return this._asyncQueue()
            .concat(PollingAssert.asyncTaskPollingAssert(() => {
                // polling logic
                return condition;
            }, "message", 60, 1000));
    }
});

Key Changes:

  • ✅ Replaced testCaseAsync with testCase
  • ✅ Removed stepDelay and steps array properties
  • ✅ Added return this._asyncQueue() from test functions
  • ✅ Chained async operations with .concat()
  • ✅ Replaced PollingAssert.createPollingAssert() with PollingAssert.asyncTaskPollingAssert()
  • ✅ Preserved all existing test logic and assertions

All deprecated async test patterns have been successfully removed from AISKULight, bringing the test suite in line with modern testing practices for better performance and error handling.

Fixes #2606.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • accounts.google.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-138.0.7204.92/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --mute-audio --crashpad-handler-pid=4560 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/puppeteer_dev_chrome_profile-jqfz1t --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,13082154846606210642,11945895185640804616,262144 --enable-features=PdfOopif --disable-features=AcceptCHFrame,IsolateSandboxedIframes,MediaRouter,OptimizationHints,PaintHolding,ProcessPerSiteUpToMainFrameThreshold,Translate --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-138.0.7204.92/chrome-linux64/chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-crash-reporter --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf --force-color-profile=srgb --generate-pdf-document-outline --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes --enable-features=PdfOopif --headless=new --hide-scrollbars --mute-audio --disable-extensions --enable-precise-memory-info --expose-internals-for-testing --no-sandbox --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-jqfz1t --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl about:blank (dns block)
  • clients2.google.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-138.0.7204.92/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --mute-audio --crashpad-handler-pid=4560 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/puppeteer_dev_chrome_profile-jqfz1t --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,13082154846606210642,11945895185640804616,262144 --enable-features=PdfOopif --disable-features=AcceptCHFrame,IsolateSandboxedIframes,MediaRouter,OptimizationHints,PaintHolding,ProcessPerSiteUpToMainFrameThreshold,Translate --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-138.0.7204.92/chrome-linux64/chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-crash-reporter --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf --force-color-profile=srgb --generate-pdf-document-outline --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes --enable-features=PdfOopif --headless=new --hide-scrollbars --mute-audio --disable-extensions --enable-precise-memory-info --expose-internals-for-testing --no-sandbox --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-jqfz1t --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl about:blank (dns block)
  • www.google.com
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-138.0.7204.92/chrome-linux64/chrome --type=utility --utility-sub-type=network.mojom.NetworkService --lang=en-US --service-sandbox-type=network --no-sandbox --disable-dev-shm-usage --use-angle=swiftshader-webgl --mute-audio --crashpad-handler-pid=4560 --enable-crash-reporter=, --noerrdialogs --user-data-dir=/tmp/puppeteer_dev_chrome_profile-jqfz1t --change-stack-guard-on-fork=enable --shared-files=network_parent_dirs_pipe:100,v8_context_snapshot_data:101 --field-trial-handle=3,i,13082154846606210642,11945895185640804616,262144 --enable-features=PdfOopif --disable-features=AcceptCHFrame,IsolateSandboxedIframes,MediaRouter,OptimizationHints,PaintHolding,ProcessPerSiteUpToMainFrameThreshold,Translate --variations-seed-version (dns block)
    • Triggering command: /home/REDACTED/.cache/puppeteer/chrome/linux-138.0.7204.92/chrome-linux64/chrome --allow-pre-commit-input --disable-REDACTED-networking --disable-REDACTED-timer-throttling --disable-REDACTEDing-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-REDACTED-pages --disable-crash-reporter --disable-default-apps --disable-dev-shm-usage --disable-hang-monitor --disable-infobars --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-REDACTEDing --disable-search-engine-choice-screen --disable-sync --enable-automation --export-tagged-pdf --force-color-profile=srgb --generate-pdf-document-outline --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --disable-features=Translate,AcceptCHFrame,MediaRouter,OptimizationHints,ProcessPerSiteUpToMainFrameThreshold,IsolateSandboxedIframes --enable-features=PdfOopif --headless=new --hide-scrollbars --mute-audio --disable-extensions --enable-precise-memory-info --expose-internals-for-testing --no-sandbox --remote-debugging-port=0 --user-data-dir=/tmp/puppeteer_dev_chrome_profile-jqfz1t --noerrdialogs --ozone-platform=headless --ozone-override-screen-size=800,600 --use-angle=swiftshader-webgl about:blank (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Karlie-777
Copy link
Contributor

change pattern:
before:

this.testCaseAsync({
    name: "Test name",
    stepDelay: 100,
    useFakeTimers: true,
    steps: [() => {
        // Test setup
    }].concat(this.asserts(1))
    .concat(() => {
        // Additional assertions
    })
});

after:

this.testCase({
    name: "Test name",
    useFakeTimers: true,
    test: () => {
        return this._asyncQueue().add(() => {
            // Test setup
            // ...
        })
        .concat(this.waitForException(1))
        .add(() => {
            // Assertions
            // ...
        });
    }
})

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Copilot AI changed the title [WIP] Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern Jul 9, 2025
Copilot AI requested a review from Karlie-777 July 9, 2025 00:40
…with helper methods

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 9, 2025

change pattern:
before:

...

Updated the async tests to follow the pattern you suggested. Added helper methods asserts() and waitForException() and restructured the tests to use the .add().concat().add() pattern for better separation of setup, polling, and assertions phases. The changes are in commit 5873ab4.

@Karlie-777
Copy link
Contributor

remove all changes are not under AISKULight directory

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 10, 2025

remove all changes are not under AISKULight directory

Removed all changes outside the AISKULight directory as requested. The commit 362c9e5 reverts all files that were modified outside of AISKULight back to their original state, keeping only the async test modernization changes within AISKULight/Tests/Unit/src/dynamicconfig.tests.ts.

…tests

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Copilot AI requested a review from Karlie-777 July 11, 2025 00:42
@Karlie-777
Copy link
Contributor

for the original code before .concat, put them before return this._asyncQueue().add. The first step of each test should be part of the initial test function, So that all subsequent steps have access to the variables and values from this initial step for any additional context

@Karlie-777
Copy link
Contributor

use PollingAssert.createPollingAssert or the original asserts from the current test framework and remove private asserts and private waitForException functions

…etter variable scoping

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jul 24, 2025

for the original code before .concat, put them before return this._asyncQueue().add. The first step of each test should be part of the initial test function, So that all subsequent steps have access t...

Moved the initial test setup code before the return this._asyncQueue() statement in all three async tests. Now variables like this.genericSpy, configuration objects, and telemetry items are initialized in the main test function scope and accessible to all subsequent async steps. Commit 0eef618.

Copy link
Contributor Author

Copilot AI commented Jul 25, 2025

fix test error:

Message: global failure: TypeError: nextTestStep is not a function
Actual: undefined
...

Fixed the nextTestStep is not a function error by replacing PollingAssert.createPollingAssert() with PollingAssert.asyncTaskPollingAssert() in both async tests. The issue was using the old pattern method with the new _asyncQueue() pattern. Commit e3b4e96.

… line 167

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
… line 210

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Copilot AI requested a review from Karlie-777 July 28, 2025 21:01
@Karlie-777 Karlie-777 marked this pull request as ready for review July 28, 2025 23:10
Copilot AI review requested due to automatic review settings July 28, 2025 23:10
@Karlie-777 Karlie-777 requested a review from a team as a code owner July 28, 2025 23:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR modernizes async unit tests in AISKULight by migrating from the deprecated testCaseAsync pattern to the modern _asyncQueue pattern. The update improves test performance and error handling by using a more efficient asynchronous testing approach.

Key changes:

  • Replaced deprecated testCaseAsync with modern testCase pattern
  • Updated polling assertions to use PollingAssert.asyncTaskPollingAssert()
  • Restructured test logic to use _asyncQueue() with chained .add() operations

@Karlie-777 Karlie-777 enabled auto-merge (squash) July 28, 2025 23:20
@Karlie-777 Karlie-777 merged commit 9b8a82a into main Jul 29, 2025
9 checks passed
@Karlie-777 Karlie-777 deleted the copilot/fix-2606 branch July 29, 2025 00:52
MSNev added a commit that referenced this pull request Sep 3, 2025
* Add Azure API Management proxy documentation to FAQ sections (#2625)

* Initial plan

* Add Azure APIM proxy documentation to FAQ sections

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Update APIM proxy link text for clarity and consistency

Co-authored-by: rads-1996 <22488539+rads-1996@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Co-authored-by: rads-1996 <22488539+rads-1996@users.noreply.github.com>

* Add weekly GitHub action to delete closed and merged branches (#2627)

* Initial plan

* Add weekly GitHub action to delete closed and merged branches

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation and comments to branch cleanup workflow

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add beta and otel-sdk to protected branches list

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation comment for GitHub context variables and environment variables

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation comment for GitHub API delete reference command

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix wildcard pattern matching in branch protection logic

Replace case statement with [[ ]] pattern matching to properly support
wildcard patterns in variables. Add documentation explaining why this
approach is needed for patterns like "release*" and "*-legacy".

Addresses feedback about wildcard pattern matching not working correctly.

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation comments for required workflow permissions

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix trackPageView not resetting maxAjaxCallsPerView counter (#2595)

* Initial plan

* Implement resetAjaxAttempts functionality

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Refactor: Create helper function for resetting ajax attempts counter

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Revert ajax.ts helper function, create helper in AnalyticsPlugin.ts instead

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Replace direct _trackAjaxAttempts assignments with helper function calls

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Remove comment and redundant _resetAjaxAttempts call from trackPageView

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Improve test consistency by matching existing test patterns

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add @microsoft/applicationinsights-dependencies-js as dev dependency

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix getPlugin usage to properly access plugin through ILoadedPlugin interface

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Remove explicit type casting from getPlugin call

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Remove unused imports IDependenciesPlugin and ILoadedPlugin

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix IDependenciesPlugin interface to extend IPlugin for proper getPlugin typing

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Create IAjaxMonitorPlugin interface and revert Version line per review feedback

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Move resetAjaxAttempts method to IAjaxMonitorPlugin interface per review feedback

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix npm build failures by removing typed import dependency

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix TypeScript configuration by removing deprecated suppressImplicitAnyIndexErrors option

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix getPlugin typing to use IAjaxMonitorPlugin for proper TypeScript inference

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix IAjaxMonitorPlugin export and plugin access pattern for resetAjaxAttempts

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors option

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix jq syntax error in Delete Merged Branches workflow (#2630)

* Initial plan

* Fix jq syntax error in Delete Merged Branches workflow

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Update all jq commands to single lines to avoid line splitting issues

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix closed_prs jq command to single line format

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern (#2607)

* Initial plan

* Update async tests in AISKULight to use modern asyncQueue pattern

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Update AISKULight async tests to follow the suggested modern pattern with helper methods

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Remove changes outside AISKULight directory as requested

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Replace .concat with .add() for waitForException calls in AISKULight tests

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Move initial test setup code before asyncQueue return statement for better variable scoping

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Remove custom helper methods and use PollingAssert.createPollingAssert directly

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Fix async tests by replacing createPollingAssert with asyncTaskPollingAssert for modern pattern compatibility

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 167

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 210

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* fix: change .concat to .add on line 119 in dynamicconfig.tests.ts

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Fix flush method root cause - handle async callbacks in _doSend with proper error handling (#2633)

* Initial plan

* Fix flush method to handle callbacks and return promises correctly

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Clean up eslint warnings and add comprehensive tests

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Simplify flush implementation per feedback - handle callbacks and promises correctly when triggerSend returns null

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix root cause in _doSend and use doAwaitResponse in flush method

- Fixed _doSend to properly capture and return promises from sendPostFunc instead of always returning null
- Updated flush method to use doAwaitResponse pattern as suggested
- Ensures async operations properly return promises that can be awaited
- Maintains backward compatibility with existing usage patterns

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix async callback handling in _doSend and simplify flush return logic

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix async callback handling with direct resolve capture instead of polling

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Handle rejection in async preparePayload callback

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Use doAwait with direct callbacks instead of doAwaitResponse

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix TypeScript compilation errors in Sender.ts - fix flush method signature and type casting

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Rename flush parameter from 'async' to 'isAsync' to avoid keyword conflicts

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add unreleased changes entry to RELEASES.md for flush method fix

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Address code review feedback: clarify breaking changes and add comprehensive flush method tests

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Use isPromiseLike and isUndefined helpers in Sender tests

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix flush method to return promise when async=true and no callback provided

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix RELEASES.md to show real original flush method signature

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix issue #2634 moving the conditional check for filtering (#2635)

* Fix issue #2634 moving the conditional check for filtering

* refactoring

* Remove additional unnecessary returns

---------

Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>

* Ensure parent is defined before checking length in getImageHref function (#2636)

Co-authored-by: pnoodles <git@pnoodles.com>

* [Feature] Implement cookie caching when disabled and automatic flushing when enabled with backward compatibility option (#2632)

* Initial plan
* Implement cookie caching when disabled and flushing when enabled
* Fix blocked cookie caching logic - blocked cookies should not be cached
* Add dynamic config change support for cookie flushing
* Address PR feedback: remove redundant flush, cache deletions, store formatted values
* Add test coverage for deletion caching behavior
* Address PR feedback: rename function, eliminate redundant calls, change operation to purge
* Rename helper function to avoid recursive call - _formatSetCookieValue
* Revert del() to use _formatCookieValue instead of _formatSetCookieValue
* Minify cache object by using single-character property names and integer enum constants
* Convert PENDING_OP constants to const enum ePendingOp
* Fix cache object interface: type o as ePendingOp, remove unused p property
* Fix TypeScript error: use _formatCookieValue instead of _formatSetCookieValue in del() caching
* Extract common deletion values creation logic to reduce duplication
* Refactor _createDeletionValues to _formatDeletionValue and simplify call sites
* Update tests to reflect new cookie caching behavior when disabled
* Add clock.tick(1) after configuration changes to allow dynamic config updates
* Fix failing tests: Replace throw patterns with call counters in disabled cookie tests
* Revert disabled cookie tests to use throw pattern instead of call counters for tests that never enable cookies
* Fix cookie flushing order issue in setEnabled() method
* Revert "Fix cookie flushing order issue in setEnabled() method"
  - This reverts commit 8da53ab.
* Fix failing tests by adding clock.tick(1) after setEnabled() calls to allow async config changes
* Add release notes for cookie caching feature to RELEASES.md
* Add disableCaching configuration option and comprehensive test coverage
* Implement PR review feedback: rename disableCaching to disableCookieCache, add @SInCE tag, optimize with local variable, set default to false
* Simplify disableCookieCache configuration to use direct false value
* Fix test failures by adding useFakeTimers: true to all tests using clock.tick()
* Fix test failures by adding defensive null checks for this.clock.tick() calls
* Revert defensive clock.tick() helper - ensure tests use useFakeTimers property
* Fix tests to expect new disableCookieCache configuration property
* Fix cookie flushing issue in setEnabled method - add immediate flushing for synchronous calls
* Fix setEnabled method to use asynchronous configuration changes and update test with missing clock.tick
* Fix test failures by adding clock.tick() after setEnabled(false) calls in all tests using fake timers
* Fix test delCookie mock to set deletion value instead of deleting entry
* Revert delCookie mock to use delete and fix tests to expect undefined after deletion
* Fix test formatting error in cookie manager tests - proper validation of maxAge cookie flushing
* Fix failing cookie manager tests - correct caching behavior expectations
* Fix cookie manager tests to be order-independent for multi-parameter assertions
* Fix cookie manager tests to handle order-independent cookie parameter assertions
* Take Over co-pilot PR to Fix tests and change name to disableCookieDefer

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* [Main][Task] 34470593: Update AISKU Async Tests To Use the Modern AsyncQueue Pattern (#2637)

* update aisku tests

* udpate

* [Main][Task] 34470593: Update Async Tests Under Dependencies Extension To Use the Modern AsyncQueue Pattern (#2638)

* udpate

* merge main

* [Beta] Fix Merge issues

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rads-1996 <22488539+rads-1996@users.noreply.github.com>
Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Co-authored-by: aimbrenda <120031791+aimbrenda@users.noreply.github.com>
Co-authored-by: Patrick <pnoodles@users.noreply.github.com>
Co-authored-by: pnoodles <git@pnoodles.com>
MSNev added a commit that referenced this pull request Sep 3, 2025
* [Main] Update the copilot instructions (#2617)

* [WIP] [Task] Add tree-shaking annotations (#2616)

* Initial plan

* Changes before error encountered

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix tree-shaking annotation syntax - remove incorrect parentheses

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add parentheses around @__PURE__ comments in IOfflineBatch.ts

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add parentheses around @__PURE__ comments for proper TypeScript handling

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Suppressed credentials inline to avoid credscan false positive (#2622)

* Suppressed credentials inline to avoid credscan false positive

* Used the next line supression syntax to avoid long length issue

* [Beta] Add W3c Trace State support / handling and refactor distributed trace... (#2620)

* [Beta] Add W3c Trace State support / handling and refactor distributed trace handling to prepare for OptenTelemetry Span style API / management

* Minification improvements

* [Beta] Merge Main to Beta (#2640)

* Add Azure API Management proxy documentation to FAQ sections (#2625)

* Initial plan

* Add Azure APIM proxy documentation to FAQ sections

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Update APIM proxy link text for clarity and consistency

Co-authored-by: rads-1996 <22488539+rads-1996@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>
Co-authored-by: rads-1996 <22488539+rads-1996@users.noreply.github.com>

* Add weekly GitHub action to delete closed and merged branches (#2627)

* Initial plan

* Add weekly GitHub action to delete closed and merged branches

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation and comments to branch cleanup workflow

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add beta and otel-sdk to protected branches list

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation comment for GitHub context variables and environment variables

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation comment for GitHub API delete reference command

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix wildcard pattern matching in branch protection logic

Replace case statement with [[ ]] pattern matching to properly support
wildcard patterns in variables. Add documentation explaining why this
approach is needed for patterns like "release*" and "*-legacy".

Addresses feedback about wildcard pattern matching not working correctly.

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add documentation comments for required workflow permissions

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix trackPageView not resetting maxAjaxCallsPerView counter (#2595)

* Initial plan

* Implement resetAjaxAttempts functionality

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Refactor: Create helper function for resetting ajax attempts counter

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Revert ajax.ts helper function, create helper in AnalyticsPlugin.ts instead

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Replace direct _trackAjaxAttempts assignments with helper function calls

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Remove comment and redundant _resetAjaxAttempts call from trackPageView

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Improve test consistency by matching existing test patterns

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add @microsoft/applicationinsights-dependencies-js as dev dependency

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix getPlugin usage to properly access plugin through ILoadedPlugin interface

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Remove explicit type casting from getPlugin call

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Remove unused imports IDependenciesPlugin and ILoadedPlugin

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix IDependenciesPlugin interface to extend IPlugin for proper getPlugin typing

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Create IAjaxMonitorPlugin interface and revert Version line per review feedback

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Move resetAjaxAttempts method to IAjaxMonitorPlugin interface per review feedback

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix npm build failures by removing typed import dependency

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix TypeScript configuration by removing deprecated suppressImplicitAnyIndexErrors option

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix getPlugin typing to use IAjaxMonitorPlugin for proper TypeScript inference

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix IAjaxMonitorPlugin export and plugin access pattern for resetAjaxAttempts

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Revert tsconfig.json change to restore suppressImplicitAnyIndexErrors option

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix jq syntax error in Delete Merged Branches workflow (#2630)

* Initial plan

* Fix jq syntax error in Delete Merged Branches workflow

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Update all jq commands to single lines to avoid line splitting issues

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix closed_prs jq command to single line format

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern (#2607)

* Initial plan

* Update async tests in AISKULight to use modern asyncQueue pattern

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Update AISKULight async tests to follow the suggested modern pattern with helper methods

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Remove changes outside AISKULight directory as requested

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Replace .concat with .add() for waitForException calls in AISKULight tests

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Move initial test setup code before asyncQueue return statement for better variable scoping

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Remove custom helper methods and use PollingAssert.createPollingAssert directly

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Fix async tests by replacing createPollingAssert with asyncTaskPollingAssert for modern pattern compatibility

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 167

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Replace .concat with .add for PollingAssert.asyncTaskPollingAssert on line 210

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* fix: change .concat to .add on line 119 in dynamicconfig.tests.ts

Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>

* Fix flush method root cause - handle async callbacks in _doSend with proper error handling (#2633)

* Initial plan

* Fix flush method to handle callbacks and return promises correctly

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Clean up eslint warnings and add comprehensive tests

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Simplify flush implementation per feedback - handle callbacks and promises correctly when triggerSend returns null

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix root cause in _doSend and use doAwaitResponse in flush method

- Fixed _doSend to properly capture and return promises from sendPostFunc instead of always returning null
- Updated flush method to use doAwaitResponse pattern as suggested
- Ensures async operations properly return promises that can be awaited
- Maintains backward compatibility with existing usage patterns

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix async callback handling in _doSend and simplify flush return logic

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix async callback handling with direct resolve capture instead of polling

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Handle rejection in async preparePayload callback

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Use doAwait with direct callbacks instead of doAwaitResponse

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix TypeScript compilation errors in Sender.ts - fix flush method signature and type casting

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Rename flush parameter from 'async' to 'isAsync' to avoid keyword conflicts

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Add unreleased changes entry to RELEASES.md for flush method fix

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Address code review feedback: clarify breaking changes and add comprehensive flush method tests

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Use isPromiseLike and isUndefined helpers in Sender tests

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix flush method to return promise when async=true and no callback provided

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix RELEASES.md to show real original flush method signature

Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* Fix issue #2634 moving the conditional check for filtering (#2635)

* Fix issue #2634 moving the conditional check for filtering

* refactoring

* Remove additional unnecessary returns

---------

Co-authored-by: Nev <54870357+MSNev@users.noreply.github.com>

* Ensure parent is defined before checking length in getImageHref function (#2636)

Co-authored-by: pnoodles <git@pnoodles.com>

* [Feature] Implement cookie caching when disabled and automatic flushing when enabled with backward compatibility option (#2632)

* Initial plan
* Implement cookie caching when disabled and flushing when enabled
* Fix blocked cookie caching logic - blocked cookies should not be cached
* Add dynamic config change support for cookie flushing
* Address PR feedback: remove redundant flush, cache deletions, store formatted values
* Add test coverage for deletion caching behavior
* Address PR feedback: rename function, eliminate redundant calls, change operation to purge
* Rename helper function to avoid recursive call - _formatSetCookieValue
* Revert del() to use _formatCookieValue instead of _formatSetCookieValue
* Minify cache object by using single-character property names and integer enum constants
* Convert PENDING_OP constants to const enum ePendingOp
* Fix cache object interface: type o as ePendingOp, remove unused p property
* Fix TypeScript error: use _formatCookieValue instead of _formatSetCookieValue in del() caching
* Extract common deletion values creation logic to reduce duplication
* Refactor _createDeletionValues to _formatDeletionValue and simplify call sites
* Update tests to reflect new cookie caching behavior when disabled
* Add clock.tick(1) after configuration changes to allow dynamic config updates
* Fix failing tests: Replace throw patterns with call counters in disabled cookie tests
* Revert disabled cookie tests to use throw pattern instead of call counters for tests that never enable cookies
* Fix cookie flushing order issue in setEnabled() method
* Revert "Fix cookie flushing order issue in setEnabled() method"
  - This reverts commit 8da53ab.
* Fix failing tests by adding clock.tick(1) after setEnabled() calls to allow async config changes
* Add release notes for cookie caching feature to RELEASES.md
* Add disableCaching configuration option and comprehensive test coverage
* Implement PR review feedback: rename disableCaching to disableCookieCache, add @SInCE tag, optimize with local variable, set default to false
* Simplify disableCookieCache configuration to use direct false value
* Fix test failures by adding useFakeTimers: true to all tests using clock.tick()
* Fix test failures by adding defensive null checks for this.clock.tick() calls
* Revert defensive clock.tick() helper - ensure tests use useFakeTimers property
* Fix tests to expect new disableCookieCache configuration property
* Fix cookie flushing issue in setEnabled method - add immediate flushing for synchronous calls
* Fix setEnabled method to use asynchronous configuration changes and update test with missing clock.tick
* Fix test failures by adding clock.tick() after setEnabled(false) calls in all tests using fake timers
* Fix test delCookie mock to set deletion value instead of deleting entry
* Revert delCookie mock to use delete and fix tests to expect undefined after deletion
* Fix test formatting error in cookie manager tests - proper validation of maxAge cookie flushing
* Fix failing cookie manager tests - correct caching behavior expectations
* Fix cookie manager tests to be order-independent for multi-parameter assertions
* Fix cookie manager tests to handle order-independent cookie parameter assertions
* Take Over co-pilot PR to Fix tests and change name to disableCookieDefer

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MSNev <54870357+MSNev@users.noreply.github.com>

* [Main][Task] 34470593: Update AISKU Async Tests To Use the Modern AsyncQueue Pattern (#2637)

* update aisku tests

* udpate

* [Main][Task] 34470593: Update Async Tests Under Dependencies Extension To Use the Modern AsyncQueue Pattern (#2638)

* udpate

* merge main

* [Beta] Fix Merge issues

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rads-1996 <22488539+rads-1996@users.noreply.github.com>
Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Co-authored-by: aimbrenda <120031791+aimbrenda@users.noreply.github.com>
Co-authored-by: Patrick <pnoodles@users.noreply.github.com>
Co-authored-by: pnoodles <git@pnoodles.com>

* [OTel-Sdk] Update shrinkwrap from merge

---------

Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: rads-1996 <radsg.1996@gmail.com>
Co-authored-by: rads-1996 <22488539+rads-1996@users.noreply.github.com>
Co-authored-by: Karlie-777 <79606506+Karlie-777@users.noreply.github.com>
Co-authored-by: aimbrenda <120031791+aimbrenda@users.noreply.github.com>
Co-authored-by: Patrick <pnoodles@users.noreply.github.com>
Co-authored-by: pnoodles <git@pnoodles.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Async Tests Under AISKULight to Use the Modern AsyncQueue Pattern

4 participants