调整:叫号内容连续播报三次

需求:公屏每次播放叫号声音时重复三遍。
实现:单项目页和多项目公屏均为每个新批次排队三条相同语音,并更新回归测试。
This commit is contained in:
2026-07-31 17:31:03 +08:00
parent 9d56c181fb
commit af2c18a546
4 changed files with 29 additions and 21 deletions

View File

@@ -89,7 +89,7 @@ describe("DisplayPage", () => {
]);
});
it("新批次出现时播报次叫号内容", () => {
it("新批次出现时连续播报次叫号内容", () => {
const speak = vi.fn();
const cancel = vi.fn();
class SpeechSynthesisUtteranceMock {
@@ -118,11 +118,13 @@ describe("DisplayPage", () => {
rerender(<DisplayPage />);
expect(cancel).toHaveBeenCalledOnce();
expect(speak).toHaveBeenCalledOnce();
expect(speak.mock.calls[0][0]).toMatchObject({
text: "请零零零零五号至零零零零六号,前往入口。",
lang: "zh-CN",
rate: 0.9,
});
expect(speak).toHaveBeenCalledTimes(3);
for (const [utterance] of speak.mock.calls) {
expect(utterance).toMatchObject({
text: "请零零零零五号至零零零零六号,前往入口。",
lang: "zh-CN",
rate: 0.9,
});
}
});
});

View File

@@ -68,11 +68,13 @@ export function DisplayPage() {
|| typeof SpeechSynthesisUtterance === "undefined"
) return;
const utterance = new SpeechSynthesisUtterance(currentAnnouncement);
utterance.lang = "zh-CN";
utterance.rate = 0.9;
window.speechSynthesis.cancel();
window.speechSynthesis.speak(utterance);
for (let repeat = 0; repeat < 3; repeat += 1) {
const utterance = new SpeechSynthesisUtterance(currentAnnouncement);
utterance.lang = "zh-CN";
utterance.rate = 0.9;
window.speechSynthesis.speak(utterance);
}
}, [currentAnnouncement, currentCallKey, hasSnapshot, token]);
const waitingTicketCount = data?.waiting_ticket_count ?? data?.waiting_count ?? 0;
const waitingPeopleCount = data?.waiting_people_count ?? 0;

View File

@@ -62,7 +62,7 @@ describe("PublicDisplayCenterPage", () => {
expect(screen.queryByRole("navigation", { name: "管理任务" })).not.toBeInTheDocument();
});
it("新叫号批次出现时播报项目和号码", () => {
it("新叫号批次出现时连续三次播报项目和号码", () => {
const speak = vi.fn();
class SpeechSynthesisUtteranceMock {
text: string;
@@ -95,10 +95,12 @@ describe("PublicDisplayCenterPage", () => {
};
rerender(<PublicDisplayCenterPage />);
expect(speak).toHaveBeenCalledOnce();
expect(speak.mock.calls[0][0]).toMatchObject({
text: "东门观光车,请零零零一六号,前往入口。",
lang: "zh-CN",
});
expect(speak).toHaveBeenCalledTimes(3);
for (const [utterance] of speak.mock.calls) {
expect(utterance).toMatchObject({
text: "东门观光车,请零零零一六号,前往入口。",
lang: "zh-CN",
});
}
});
});

View File

@@ -37,10 +37,12 @@ export function PublicDisplayCenterPage() {
window.speechSynthesis.cancel();
for (const announcement of announcements) {
const utterance = new SpeechSynthesisUtterance(announcement);
utterance.lang = "zh-CN";
utterance.rate = 0.9;
window.speechSynthesis.speak(utterance);
for (let repeat = 0; repeat < 3; repeat += 1) {
const utterance = new SpeechSynthesisUtterance(announcement);
utterance.lang = "zh-CN";
utterance.rate = 0.9;
window.speechSynthesis.speak(utterance);
}
}
}, [data]);