eugenegujing opened a new pull request, #6474: URL: https://github.com/apache/texera/pull/6474
### What changes were proposed in this PR? This PR adds unit test coverage for `frontend/src/app/common/util/context.ts`, which previously had no spec and was only exercised implicitly through `JointGraphWrapper`. The module exports the `ContextManager` and `ObservableContextManager` class factories that back the workflow editor's context-stack behavior, and this PR locks that behavior down with explicit assertions without changing any production code. The `ContextManager` tests cover the context-stack semantics: `getContext` returns the current context, `prevContext` returns the previous one and throws in the default context, `withContext` exposes the entered and previous contexts to its callable and restores the previous context afterwards, the callable's return value is forwarded, the context is still restored (and the error re-thrown) when the callable throws, nested calls restore each level, and separately created managers keep isolated stacks. The `ObservableContextManager` tests cover the enter, exit, and change-context streams: each emits the correct `[exiting, entering]` tuple, events fire after the stack has been updated, and ordering is correct across nested `withContext` calls, including the case where the callable throws. Edge cases are covered as well: object-reference contexts are preserved by identity through the stack and in the emitted tuples, both levels unwind via their `finally` blocks when a nested callable throws, a late subscriber receives no earlier events because the streams are plain `Subject`s with no replay, `prevContext` is valid inside the enter subscriber, re-entering the same context value still pushes a new stack frame, and `withContext` returns falsy callable results unchanged. ### Any related issues, documentation, discussions? Closes #6442 ### How was this PR tested? All 23 tests pass via `ng test --include='src/app/common/util/context.spec.ts'`, and no production code is modified. ### Was this PR authored or co-authored using generative AI tooling? Co-authored using Claude Code(Fable 5) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
