mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-30 19:39:22 +00:00
fix tests after moving to pnpm
This commit is contained in:
@@ -17,7 +17,7 @@ exports[`InCallView > rendering > renders 1`] = `
|
|||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
aria-label=""
|
aria-label=""
|
||||||
class="_avatar_7h2br_8 roomAvatar _avatar-imageless_7h2br_55"
|
class="_avatar_va14e_8 roomAvatar _avatar-imageless_va14e_55"
|
||||||
data-color="1"
|
data-color="1"
|
||||||
data-type="round"
|
data-type="round"
|
||||||
role="img"
|
role="img"
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ exports[`DeveloperSettingsTab > renders and matches snapshot 1`] = `
|
|||||||
>
|
>
|
||||||
<input
|
<input
|
||||||
aria-describedby="radix-_r_7_"
|
aria-describedby="radix-_r_7_"
|
||||||
class="_control_sqdq4_10"
|
class="_control_d83jn_10"
|
||||||
id="radix-_r_6_"
|
id="radix-_r_6_"
|
||||||
name="input"
|
name="input"
|
||||||
title=""
|
title=""
|
||||||
|
|||||||
@@ -794,7 +794,6 @@ export function enterRTCSession(
|
|||||||
makeKeyDelay: matrixRtcSessionConfig?.wait_for_key_rotation_ms,
|
makeKeyDelay: matrixRtcSessionConfig?.wait_for_key_rotation_ms,
|
||||||
membershipEventExpiryMs:
|
membershipEventExpiryMs:
|
||||||
matrixRtcSessionConfig?.membership_event_expiry_ms,
|
matrixRtcSessionConfig?.membership_event_expiry_ms,
|
||||||
useExperimentalToDeviceTransport: true,
|
|
||||||
unstableSendStickyEvents: matrixRTCMode === MatrixRTCMode.Matrix_2_0,
|
unstableSendStickyEvents: matrixRTCMode === MatrixRTCMode.Matrix_2_0,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -74,7 +74,26 @@ const panNode = vi.mocked(
|
|||||||
* It can also be used to mock the `AudioContext` constructor in tests:
|
* It can also be used to mock the `AudioContext` constructor in tests:
|
||||||
* `vi.stubGlobal("AudioContext", () => testAudioContext);`
|
* `vi.stubGlobal("AudioContext", () => testAudioContext);`
|
||||||
*/
|
*/
|
||||||
export const testAudioContext = {
|
export const testAudioContext: Partial<AudioContext> & {
|
||||||
|
gain: ReturnType<
|
||||||
|
typeof vi.mocked<{
|
||||||
|
connect: (node: AudioNode) => AudioNode;
|
||||||
|
gain: { setValueAtTime: ReturnType<typeof vi.fn>; value: number };
|
||||||
|
}>
|
||||||
|
>;
|
||||||
|
pan: ReturnType<
|
||||||
|
typeof vi.mocked<{
|
||||||
|
connect: (node: AudioNode) => AudioNode;
|
||||||
|
pan: { setValueAtTime: ReturnType<typeof vi.fn>; value: number };
|
||||||
|
}>
|
||||||
|
>;
|
||||||
|
setSinkId: ReturnType<typeof vi.fn>;
|
||||||
|
decodeAudioData: ReturnType<typeof vi.fn>;
|
||||||
|
createBufferSource: ReturnType<typeof vi.fn>;
|
||||||
|
createGain: ReturnType<typeof vi.fn>;
|
||||||
|
createStereoPanner: ReturnType<typeof vi.fn>;
|
||||||
|
close: ReturnType<typeof vi.fn>;
|
||||||
|
} = {
|
||||||
gain: gainNode,
|
gain: gainNode,
|
||||||
pan: panNode,
|
pan: panNode,
|
||||||
setSinkId: vi.fn().mockResolvedValue(undefined),
|
setSinkId: vi.fn().mockResolvedValue(undefined),
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
vitest,
|
vitest,
|
||||||
} from "vitest";
|
} from "vitest";
|
||||||
import {
|
import {
|
||||||
|
EventType,
|
||||||
MatrixEvent,
|
MatrixEvent,
|
||||||
type Room as MatrixRoom,
|
type Room as MatrixRoom,
|
||||||
type Room,
|
type Room,
|
||||||
@@ -255,6 +256,7 @@ export function mockRtcMembership(
|
|||||||
const event = new MatrixEvent({
|
const event = new MatrixEvent({
|
||||||
sender: userId,
|
sender: userId,
|
||||||
event_id: `$-ev-${randomUUID()}:example.org`,
|
event_id: `$-ev-${randomUUID()}:example.org`,
|
||||||
|
type: EventType.GroupCallMemberPrefix,
|
||||||
content: data,
|
content: data,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -466,7 +468,9 @@ export class MockRTCSession extends TypedEventEmitter<
|
|||||||
counters: {},
|
counters: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
public leaveRoomSession = vitest.fn().mockResolvedValue(undefined);
|
public leaveRoomSession: ReturnType<typeof vitest.fn> = vitest
|
||||||
|
.fn()
|
||||||
|
.mockResolvedValue(undefined);
|
||||||
|
|
||||||
public constructor(
|
public constructor(
|
||||||
public readonly room: Room,
|
public readonly room: Room,
|
||||||
@@ -496,7 +500,7 @@ export class MockRTCSession extends TypedEventEmitter<
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateCallIntent = vitest
|
public updateCallIntent: ReturnType<typeof vitest.fn> = vitest
|
||||||
.fn()
|
.fn()
|
||||||
.mockImplementation(async () => Promise.resolve());
|
.mockImplementation(async () => Promise.resolve());
|
||||||
|
|
||||||
|
|||||||
@@ -13,12 +13,13 @@ export default defineConfig((configEnv) =>
|
|||||||
classNameStrategy: "non-scoped",
|
classNameStrategy: "non-scoped",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
setupFiles: ["src/vitest.setup.ts"],
|
setupFiles: ["vitest.setup.ts"],
|
||||||
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],
|
include: ["src/**/*.test.ts", "src/**/*.test.tsx"],
|
||||||
coverage: {
|
coverage: {
|
||||||
reporter: ["html", "json"],
|
reporter: ["html", "json"],
|
||||||
include: ["src/"],
|
include: ["src/**/*.{ts,tsx,js,jsx}"],
|
||||||
exclude: [
|
exclude: [
|
||||||
|
"src/**/*.md",
|
||||||
"src/**/*.{d,test,stories}.{ts,tsx}",
|
"src/**/*.{d,test,stories}.{ts,tsx}",
|
||||||
"src/utils/test.ts",
|
"src/utils/test.ts",
|
||||||
"src/utils/test-viewmodel.ts",
|
"src/utils/test-viewmodel.ts",
|
||||||
|
|||||||
51
vitest.setup.ts
Normal file
51
vitest.setup.ts
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
const storage: Record<string, string> = {};
|
||||||
|
const localStoragePolyfill = {
|
||||||
|
getItem(key: string) {
|
||||||
|
return Object.prototype.hasOwnProperty.call(storage, key)
|
||||||
|
? storage[key]
|
||||||
|
: null;
|
||||||
|
},
|
||||||
|
setItem(key: string, value: string) {
|
||||||
|
storage[key] = String(value);
|
||||||
|
},
|
||||||
|
removeItem(key: string) {
|
||||||
|
delete storage[key];
|
||||||
|
},
|
||||||
|
clear() {
|
||||||
|
for (const key in storage) {
|
||||||
|
delete storage[key];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
key(index: number) {
|
||||||
|
const keys = Object.keys(storage);
|
||||||
|
return keys[index] ?? null;
|
||||||
|
},
|
||||||
|
get length() {
|
||||||
|
return Object.keys(storage).length;
|
||||||
|
},
|
||||||
|
} as unknown as Storage;
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof globalThis.localStorage === "undefined" ||
|
||||||
|
typeof globalThis.localStorage.clear !== "function"
|
||||||
|
) {
|
||||||
|
Object.defineProperty(globalThis, "localStorage", {
|
||||||
|
value: localStoragePolyfill,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
typeof window !== "undefined" &&
|
||||||
|
(typeof window.localStorage === "undefined" ||
|
||||||
|
typeof window.localStorage.clear !== "function")
|
||||||
|
) {
|
||||||
|
Object.defineProperty(window, "localStorage", {
|
||||||
|
value: localStoragePolyfill,
|
||||||
|
writable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
import "./src/vitest.setup.ts";
|
||||||
Reference in New Issue
Block a user