Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import CompassKit
import Foundation

/// Launch arguments read by native UI for XCUITest only. Production launches omit these.
Expand Down Expand Up @@ -66,6 +67,11 @@ public enum UITestLaunchPolicy {

/// Full week column count so demo fixture events stay in the focus layout during XCUITest.
public static var pinnedWeekGridTrackWidth: CGFloat? {
if ProcessInfo.processInfo.environment["PARITY_CAPTURE"] == "1"
|| ProcessInfo.processInfo.arguments.contains("-COMPASS_UI_TEST_PARITY_CAPTURE")
{
return CGFloat(ParityCaptureGeometry.contentTrackWidth)
}
if initialGridFocusEventId != nil
|| openFocusedEventFormAfterInitialGridFocus
|| ProcessInfo.processInfo.arguments.contains("-COMPASS_UI_TEST_PIN_WEEK_GRID_TRACK")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation

/// Geometry for desktop ↔ web parity screenshots. Keep in sync with
/// `e2e/parity/seed-demo-fixture.util.ts` and `apps/calendar-web/src/index.html`
/// boot track math (1280×820, sidebar open @ 345px, content pl-8).
public enum ParityCaptureGeometry {
public static let viewportWidth: Double = 1280
public static let contentLeadingInset: Double = 32
public static let sidebarDividerWidth: Double = 32
public static let defaultSidebarWidth: Double = 345
public static let gridMarginLeft: Double = Double(GridMetrics.gridMarginLeft)

/// Width of the week grid track (excluding sidebar chrome).
public static var contentTrackWidth: Double {
viewportWidth - contentLeadingInset - (sidebarDividerWidth + defaultSidebarWidth)
}

public static var visibleDayCount: Int {
CalendarWindowMath.computeVisibleDayCount(
trackWidth: contentTrackWidth,
marginLeft: gridMarginLeft
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import CompassKit
import XCTest

final class ParityCaptureGeometryTests: XCTestCase {
func testContentTrackWidthMatchesWebBootShell() {
// index.html: track = innerWidth - 32 - (32 + sidebarWidth)
XCTAssertEqual(ParityCaptureGeometry.contentTrackWidth, 871, accuracy: 0.1)
XCTAssertEqual(ParityCaptureGeometry.visibleDayCount, 5)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import XCTest
/// `.github/workflows/desktop-web-parity-screenshots.yml`). Run with
/// `PARITY_CAPTURE=1` and `PARITY_OUTPUT_DIR` set; skips ReferenceImages diff.
final class NativeParityCaptureTests: XCTestCase {
private static let demoLaunchArgs = ["-COMPASS_FIXTURE", "demo", "-compass.theme", "light-beach"]
private static let demoLaunchArgs = [
"-COMPASS_FIXTURE", "demo",
"-compass.theme", "light-beach",
"-COMPASS_UI_TEST_PARITY_CAPTURE",
"-\(OnboardingStorageKeys.hasSeenWelcome)", "true",
]

@MainActor
func testExportParitySurfaces() throws {
Expand All @@ -24,12 +29,14 @@ final class NativeParityCaptureTests: XCTestCase {
@MainActor
private func captureWeekGrid() {
let window = launchDemoWindow()
prepareParityGrid(window)
NativeImageSnapshotSupport.captureWindow(window, named: "week-grid")
}

@MainActor
private func captureMiniCalendar() {
let window = launchDemoWindow()
prepareParityGrid(window)
XCTAssertTrue(
window.descendants(matching: .any)["compass-native-month-picker"].waitForExistence(timeout: 10))
window.typeKey("i", modifierFlags: [])
Expand All @@ -39,6 +46,7 @@ final class NativeParityCaptureTests: XCTestCase {
@MainActor
private func captureEventForm() {
let window = launchDemoWindow()
prepareParityGrid(window)
window.typeKey("c", modifierFlags: [])
XCTAssertTrue(
window.descendants(matching: .any)["compass-event-form"].waitForExistence(timeout: 8))
Expand All @@ -48,6 +56,7 @@ final class NativeParityCaptureTests: XCTestCase {
@MainActor
private func captureCommandPalette() {
let window = launchDemoWindow()
prepareParityGrid(window)
window.typeKey("k", modifierFlags: [.command])
XCTAssertTrue(
window.descendants(matching: .any)["compass-native-command-palette"].waitForExistence(timeout: 8))
Expand All @@ -57,6 +66,7 @@ final class NativeParityCaptureTests: XCTestCase {
@MainActor
private func captureSettings() {
let window = launchDemoWindow()
prepareParityGrid(window)
window.typeKey(",", modifierFlags: [.command])
XCTAssertTrue(
window.descendants(matching: .any)["compass-native-settings"].waitForExistence(timeout: 8))
Expand Down Expand Up @@ -84,4 +94,16 @@ final class NativeParityCaptureTests: XCTestCase {
XCTAssertTrue(window.waitForExistence(timeout: 15))
return window
}

/// Dismiss demo chrome and wait for the shared demo-seed grid event (web parity uses the same fixture).
@MainActor
private func prepareParityGrid(_ window: XCUIElement) {
let okay = window.buttons["Okay"]
if okay.waitForExistence(timeout: 4) {
okay.tap()
}
XCTAssertTrue(
window.buttons["Morning standup"].waitForExistence(timeout: 20),
"Expected demo-seed timed event on the week grid")
}
}
11 changes: 11 additions & 0 deletions e2e/parity/seed-demo-fixture.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import { join } from "node:path";
/** Matches `AppDelegate` default content size on macOS. */
export const PARITY_VIEWPORT = { width: 1280, height: 820 } as const;

/** Keep in sync with `ParityCaptureGeometry.swift` and index.html boot track math. */
export const PARITY_SIDEBAR_WIDTH = 345;
export const PARITY_CONTENT_LEADING_INSET = 32;
export const PARITY_SIDEBAR_DIVIDER_WIDTH = 32;
export const PARITY_CONTENT_TRACK_WIDTH =
PARITY_VIEWPORT.width -
PARITY_CONTENT_LEADING_INSET -
(PARITY_SIDEBAR_DIVIDER_WIDTH + PARITY_SIDEBAR_WIDTH);

const DEMO_SEED_PATH = join(
process.cwd(),
"apps/calendar-macos/CompassKit/Sources/CompassKit/Resources/Fixtures/demo-seed.json",
Expand Down Expand Up @@ -34,6 +43,8 @@ export async function installParityWebEnvironment(
"compass.theme": "light-beach",
"compass.migration.demo-data-seed-v2": "done",
"compass.localCalendarId": demoFixture.calendarId,
"compass.view.sidebar-open": "true",
"compass.sidebar.width": String(PARITY_SIDEBAR_WIDTH),
};
if (dismissOnboarding) {
localStorageSeed["compass.onboarding.has-seen-welcome"] = "true";
Expand Down
Loading