diff --git a/web/src/components/oncall/OnCallCoverageStrip.spec.ts b/web/src/components/oncall/OnCallCoverageStrip.spec.ts
index 6477a00c06..9d227ffc6b 100644
--- a/web/src/components/oncall/OnCallCoverageStrip.spec.ts
+++ b/web/src/components/oncall/OnCallCoverageStrip.spec.ts
@@ -14,13 +14,28 @@
// along with this program. If not, see .
import { mount } from "@vue/test-utils";
-import { describe, expect, it } from "vitest";
+import { afterEach, describe, expect, it, vi } from "vitest";
import OnCallCoverageStrip from "@/components/oncall/OnCallCoverageStrip.vue";
import i18n from "@/locales";
import type { Rotation } from "@/ts/interfaces/oncall";
import { MICROS_PER_WEEK } from "@/ts/interfaces/oncall";
+// Mutable per case, so the phone tests can switch while every other test stays desktop.
+const mockViewport = vi.hoisted(() => ({ mdUp: true, lgUp: true }));
+vi.mock("@/composables/useBreakpoint", async () => {
+ const { computed } = await import("vue");
+ return {
+ default: () => ({
+ isMobile: computed(() => !mockViewport.mdUp),
+ isTablet: computed(() => mockViewport.mdUp && !mockViewport.lgUp),
+ isDesktop: computed(() => mockViewport.lgUp),
+ mdUp: computed(() => mockViewport.mdUp),
+ lgUp: computed(() => mockViewport.lgUp),
+ }),
+ };
+});
+
const stubs = {
OScheduleTimeline: {
name: "OScheduleTimeline",
@@ -65,6 +80,11 @@ function render(rotations: Rotation[]) {
}
describe("OnCallCoverageStrip", () => {
+ afterEach(() => {
+ mockViewport.mdUp = true;
+ mockViewport.lgUp = true;
+ });
+
/// A covered fortnight is ONE band, not 336 hourly slivers the browser has to
/// lay out.
it("merges an unbroken stretch of cover into a single band", () => {
@@ -153,6 +173,17 @@ describe("OnCallCoverageStrip", () => {
expect(first.offset).toBeGreaterThan(0);
expect(first.offset).toBeLessThan(dayShare);
});
+
+ /// A phone-width strip has room for about four date labels; the laptop's seven ran into each other.
+ it("thins the dates further on a phone", () => {
+ const laptop = axisOf(render([rotation(["ana@o2.ai"])]));
+ mockViewport.mdUp = false;
+ const phone = axisOf(render([rotation(["ana@o2.ai"])]));
+
+ expect(phone.length).toBeGreaterThan(1);
+ expect(phone.length).toBeLessThanOrEqual(4);
+ expect(phone.length).toBeLessThan(laptop.length);
+ });
});
/// E5: `Covered` is a binary that answers the wrong question. What somebody
diff --git a/web/src/components/oncall/OnCallCoverageStrip.vue b/web/src/components/oncall/OnCallCoverageStrip.vue
index 716affaa82..9caf23c1b1 100644
--- a/web/src/components/oncall/OnCallCoverageStrip.vue
+++ b/web/src/components/oncall/OnCallCoverageStrip.vue
@@ -114,6 +114,7 @@ along with this program. If not, see .