mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
refactor(libs): consolidate messaging-internal into messaging library (#16386)
This change eliminates the circular dependency between messaging and messaging-internal libraries by merging them into a single messaging library. Previously, messaging-internal imported from @bitwarden/messaging while messaging tried to import from @bitwarden/messaging-internal, creating an unresolvable circular dependency. This also violated Nx best practices by using cross-library file includes in tsconfig.lib.json. Changes made: - Moved all messaging-internal code (SubjectMessageSender, helpers, tests) into libs/messaging/src/ - Updated all imports to use relative paths instead of @bitwarden/messaging imports - Removed the entire messaging-internal library and its configuration files - Updated external references in apps/browser to import from @bitwarden/messaging - Fixed libs/messaging/tsconfig.lib.json to use standard src/**/*.ts pattern - Updated libs/common internal.ts to re-export from messaging instead of messaging-internal The messaging library now exports both public APIs and internal implementations, which is a cleaner architecture than maintaining two separate libraries with circular dependencies. Fixes rootDir configuration issues identified in the Nx library systematic fix project.
This commit is contained in:
47
libs/messaging/src/helpers.spec.ts
Normal file
47
libs/messaging/src/helpers.spec.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { Subject, firstValueFrom } from "rxjs";
|
||||
|
||||
import { getCommand, tagAsExternal } from "./helpers";
|
||||
import { isExternalMessage } from "./is-external-message";
|
||||
import { CommandDefinition, Message } from "./types";
|
||||
|
||||
describe("helpers", () => {
|
||||
describe("getCommand", () => {
|
||||
it("can get the command from just a string", () => {
|
||||
const command = getCommand("myCommand");
|
||||
|
||||
expect(command).toEqual("myCommand");
|
||||
});
|
||||
|
||||
it("can get the command from a message definition", () => {
|
||||
const commandDefinition = new CommandDefinition<Record<string, unknown>>("myCommand");
|
||||
|
||||
const command = getCommand(commandDefinition);
|
||||
|
||||
expect(command).toEqual("myCommand");
|
||||
});
|
||||
});
|
||||
|
||||
describe("tag integration", () => {
|
||||
it("can tag and identify as tagged", async () => {
|
||||
const messagesSubject = new Subject<Message<Record<string, unknown>>>();
|
||||
|
||||
const taggedMessages = messagesSubject.asObservable().pipe(tagAsExternal());
|
||||
|
||||
const firstValuePromise = firstValueFrom(taggedMessages);
|
||||
|
||||
messagesSubject.next({ command: "test" });
|
||||
|
||||
const result = await firstValuePromise;
|
||||
|
||||
expect(isExternalMessage(result)).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isExternalMessage", () => {
|
||||
it.each([null, { command: "myCommand", test: "object" }, undefined] as Message<
|
||||
Record<string, unknown>
|
||||
>[])("returns false when value is %s", (value: Message<Record<string, unknown>>) => {
|
||||
expect(isExternalMessage(value)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user