Skip to content

Commit

Permalink
extend test timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
shinyoshiaki committed Feb 19, 2024
1 parent 907aed6 commit dd5dd64
Show file tree
Hide file tree
Showing 15 changed files with 727 additions and 804 deletions.
4 changes: 2 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"dev": "npm run dev:chrome",
"dev:chrome": "vitest ./tests",
"dev:server": "DEBUG=werift* ts-node-dev --project tsconfig.server.json ./server/main.ts",
"format": "npx @biomejs/biome check --apply server tests",
"format": "biome check --apply server tests",
"prod:server": "DEBUG=werift* node lib/e2e/server/main.js",
"prod:test": "vitest run ./tests --browser.headless && node stop.js",
"prod:test": "vitest run ./tests --browser.headless --reporter=basic && node stop.js",
"server": "npm run dev:server",
"test": "npm run prod:test",
"type": "tsc --noEmit -p tsconfig.server.json && tsc --noEmit -p tsconfig.json"
Expand Down
110 changes: 53 additions & 57 deletions e2e/tests/bundle/max-compat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,67 +72,63 @@ describe("bundle_max_compat", () => {
6000 * 1000,
);

it(
"bundle_max_compat_offer",
async () =>
new Promise<void>(async (done) => {
const label = "bundle_max_compat_offer";
it("bundle_max_compat_offer", async () =>
new Promise<void>(async (done) => {
const label = "bundle_max_compat_offer";

const counter = new Counter(3, () => {
pc.close();
done();
});
const counter = new Counter(3, () => {
pc.close();
done();
});

if (!peer.connected) await new Promise<void>((r) => peer.on("open", r));
await sleep(100);
if (!peer.connected) await new Promise<void>((r) => peer.on("open", r));
await sleep(100);

const pc = new RTCPeerConnection({
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
bundlePolicy: "max-compat",
});
pc.ontrack = async ({ track }) => {
await waitVideoPlay(track);
counter.done();
};

const channel = pc.createDataChannel("dc");
channel.onopen = () => {
channel.send("ping");
};
channel.onmessage = (e) => {
if (e.data === "pong") {
counter.done();
}
};
const pc = new RTCPeerConnection({
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
bundlePolicy: "max-compat",
});
pc.ontrack = async ({ track }) => {
await waitVideoPlay(track);
counter.done();
};

{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
}
{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
const channel = pc.createDataChannel("dc");
channel.onopen = () => {
channel.send("ping");
};
channel.onmessage = (e) => {
if (e.data === "pong") {
counter.done();
}
pc.onicecandidate = ({ candidate }) => {
peer
.request(label, {
type: "candidate",
payload: candidate,
})
.catch(() => {});
};
};

await pc.setLocalDescription(await pc.createOffer());
const answer = await peer.request(label, {
type: "init",
payload: pc.localDescription,
});
await pc.setRemoteDescription(answer);
}),
10 * 1000,
);
{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
}
{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
}
pc.onicecandidate = ({ candidate }) => {
peer
.request(label, {
type: "candidate",
payload: candidate,
})
.catch(() => {});
};

await pc.setLocalDescription(await pc.createOffer());
const answer = await peer.request(label, {
type: "init",
payload: pc.localDescription,
});
await pc.setRemoteDescription(answer);
}));
});
202 changes: 97 additions & 105 deletions e2e/tests/combination/allmedia.test.ts
Original file line number Diff line number Diff line change
@@ -1,128 +1,120 @@
import { Counter, peer, sleep, waitVideoPlay } from "../fixture";

describe("combination_all_media", () => {
it(
"combination_all_media_answer",
async () =>
new Promise<void>(async (done) => {
const label = "combination_all_media_answer";
it("combination_all_media_answer", async () =>
new Promise<void>(async (done) => {
const label = "combination_all_media_answer";

const counter = new Counter(3, () => {
pc.close();
done();
});
const counter = new Counter(3, () => {
pc.close();
done();
});

if (!peer.connected) await new Promise<void>((r) => peer.on("open", r));
await sleep(100);
if (!peer.connected) await new Promise<void>((r) => peer.on("open", r));
await sleep(100);

const pc = new RTCPeerConnection({
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
});
pc.ontrack = async ({ track }) => {
await waitVideoPlay(track);
counter.done();
const pc = new RTCPeerConnection({
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
});
pc.ontrack = async ({ track }) => {
await waitVideoPlay(track);
counter.done();
};
pc.ondatachannel = ({ channel }) => {
channel.onopen = () => {
channel.send("ping");
};
pc.ondatachannel = ({ channel }) => {
channel.onopen = () => {
channel.send("ping");
};
channel.onmessage = (e) => {
if (e.data === "pong") {
counter.done();
}
};
channel.onmessage = (e) => {
if (e.data === "pong") {
counter.done();
}
};
};

{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
}
{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
}

const offer = await peer.request(label, {
type: "init",
});
await pc.setRemoteDescription(offer);
await pc.setLocalDescription(await pc.createAnswer());
{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
}
{
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
}

pc.onicecandidate = ({ candidate }) => {
peer
.request(label, {
type: "candidate",
payload: candidate,
})
.catch(() => {});
};
const offer = await peer.request(label, {
type: "init",
});
await pc.setRemoteDescription(offer);
await pc.setLocalDescription(await pc.createAnswer());

pc.onicecandidate = ({ candidate }) => {
peer
.request(label, {
type: "answer",
payload: pc.localDescription,
type: "candidate",
payload: candidate,
})
.catch(() => {});
}),
10 * 1000,
);
};

it(
"combination_all_media_offer",
async () =>
new Promise<void>(async (done) => {
const label = "combination_all_media_offer";
peer
.request(label, {
type: "answer",
payload: pc.localDescription,
})
.catch(() => {});
}));

const counter = new Counter(2, () => {
pc.close();
done();
});
it("combination_all_media_offer", async () =>
new Promise<void>(async (done) => {
const label = "combination_all_media_offer";

if (!peer.connected) await new Promise<void>((r) => peer.on("open", r));
await sleep(100);
const counter = new Counter(2, () => {
pc.close();
done();
});

const pc = new RTCPeerConnection({
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
});
pc.ontrack = async ({ track }) => {
await waitVideoPlay(track);
counter.done();
};
if (!peer.connected) await new Promise<void>((r) => peer.on("open", r));
await sleep(100);

const channel = pc.createDataChannel("dc");
channel.onopen = () => {
channel.send("ping");
};
channel.onmessage = (e) => {
if (e.data === "pong") {
counter.done();
}
};
const pc = new RTCPeerConnection({
iceServers: [{ urls: "stun:stun.l.google.com:19302" }],
});
pc.ontrack = async ({ track }) => {
await waitVideoPlay(track);
counter.done();
};

const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
pc.onicecandidate = ({ candidate }) => {
peer
.request(label, {
type: "candidate",
payload: candidate,
})
.catch(() => {});
};
const channel = pc.createDataChannel("dc");
channel.onopen = () => {
channel.send("ping");
};
channel.onmessage = (e) => {
if (e.data === "pong") {
counter.done();
}
};

await pc.setLocalDescription(await pc.createOffer());
const answer = await peer.request(label, {
type: "init",
payload: pc.localDescription,
});
await pc.setRemoteDescription(answer);
}),
10 * 1000,
);
const [track] = (
await navigator.mediaDevices.getUserMedia({ video: true })
).getTracks();
pc.addTrack(track);
pc.onicecandidate = ({ candidate }) => {
peer
.request(label, {
type: "candidate",
payload: candidate,
})
.catch(() => {});
};

await pc.setLocalDescription(await pc.createOffer());
const answer = await peer.request(label, {
type: "init",
payload: pc.localDescription,
});
await pc.setRemoteDescription(answer);
}));
});
Loading

0 comments on commit dd5dd64

Please sign in to comment.