























@@ -74,6 +74,39 @@ function captureStdout() {
7474};
7575}
767677+async function runCreateMeetBrowserScript(params: { buttonText: string }) {
78+const location = {
79+href: "https://meet.google.com/new",
80+hostname: "meet.google.com",
81+};
82+const button = {
83+disabled: false,
84+innerText: params.buttonText,
85+textContent: params.buttonText,
86+getAttribute: (name: string) => (name === "aria-label" ? params.buttonText : null),
87+click: vi.fn(() => {
88+location.href = "https://meet.google.com/abc-defg-hij";
89+}),
90+};
91+const document = {
92+title: "Meet",
93+body: {
94+innerText: "Do you want people to hear you in the meeting?",
95+textContent: "Do you want people to hear you in the meeting?",
96+},
97+querySelectorAll: (selector: string) => (selector === "button" ? [button] : []),
98+};
99+vi.stubGlobal("document", document);
100+vi.stubGlobal("location", location);
101+const fn = (0, eval)(`(${CREATE_MEET_FROM_BROWSER_SCRIPT})`) as () => Promise<{
102+meetingUri?: string;
103+manualActionReason?: string;
104+notes?: string[];
105+retryAfterMs?: number;
106+}>;
107+return { button, result: await fn() };
108+}
109+77110type TestBridgeProcess = {
78111stdin?: { write(chunk: unknown): unknown } | null;
79112stdout?: { on(event: "data", listener: (chunk: unknown) => void): unknown } | null;
@@ -853,50 +886,15 @@ describe("google-meet plugin", () => {
853886])(
854887"uses browser automation for Meet's %s choice during browser creation",
855888async (buttonText, note) => {
856-const location = {
857-href: "https://meet.google.com/new",
858-hostname: "meet.google.com",
859-};
860-const button = {
861-disabled: false,
862-innerText: buttonText,
863-textContent: buttonText,
864-getAttribute: (name: string) => (name === "aria-label" ? buttonText : null),
865-click: vi.fn(() => {
866-location.href = "https://meet.google.com/abc-defg-hij";
867-}),
868-};
869-const document = {
870-title: "Meet",
871-body: {
872-innerText: "Do you want people to hear you in the meeting?",
873-textContent: "Do you want people to hear you in the meeting?",
874-},
875-querySelectorAll: (selector: string) => (selector === "button" ? [button] : []),
876-};
877-vi.stubGlobal("document", document);
878-vi.stubGlobal("location", location);
879-vi.useFakeTimers();
880-881-try {
882-const fn = (0, eval)(`(${CREATE_MEET_FROM_BROWSER_SCRIPT})`) as () => Promise<{
883-meetingUri?: string;
884-manualActionReason?: string;
885-notes?: string[];
886-retryAfterMs?: number;
887-}>;
888-const result = await fn();
889-890-expect(result).toMatchObject({
891-retryAfterMs: 1000,
892-notes: [note],
893-});
894-expect(button.click).toHaveBeenCalledTimes(1);
895-expect(result.meetingUri).toBeUndefined();
896-expect(result.manualActionReason).toBeUndefined();
897-} finally {
898-vi.useRealTimers();
899-}
889+const { button, result } = await runCreateMeetBrowserScript({ buttonText });
890+891+expect(result).toMatchObject({
892+retryAfterMs: 1000,
893+notes: [note],
894+});
895+expect(button.click).toHaveBeenCalledTimes(1);
896+expect(result.meetingUri).toBeUndefined();
897+expect(result.manualActionReason).toBeUndefined();
900898},
901899);
902900此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。