Skip to content

fix context api test #19412

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/16.0
Choose a base branch
from

Conversation

nielslyngsoe
Copy link
Member

Fixes the units tests as the context API does not call callback with undefined unless there was a instance send earlier.

the issue originates from this PR #19367

@Copilot Copilot AI review requested due to automatic review settings May 24, 2025 18:52
@nielslyngsoe nielslyngsoe requested a review from iOvergaard May 24, 2025 18:52
@nielslyngsoe nielslyngsoe enabled auto-merge (squash) May 24, 2025 18:52
Copy link
Contributor

@Copilot 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 updates the context-consumer tests to align with the new behavior of the Context API, which no longer invokes callbacks with undefined by default.

  • Swaps a type-only import for a concrete import of UmbContextRequestEventImplementation
  • Converts several tests from callback-based done() style to async/await with oneEvent
  • Ensures tests assert the absence of callback calls rather than expecting an initial undefined
Comments suppressed due to low confidence (1)

src/Umbraco.Web.UI.Client/src/libs/context-api/consume/context-consumer.test.ts:277

  • [nitpick] The callbackCount variable is initialized but never mutated in the new callback; consider removing it or using a spy to track invocations more directly.
let callbackCount = 0;

localConsumer.hostConnected();

await requestEvent;
await Promise.resolve();
Copy link
Preview

Copilot AI May 24, 2025

Choose a reason for hiding this comment

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

[nitpick] This extra await Promise.resolve() may be unnecessary now that you’re awaiting the event; you can remove it to simplify the test.

Suggested change
await Promise.resolve();

Copilot uses AI. Check for mistakes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant