-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Milestone
Description
Overview
Phase 3 of the test coverage improvement plan from plans/xcuitest.md. Targeted UI tests for critical user workflows.
Target: v3000.1.x or v3001.0.0 (can be written in Swift as part of port)
Depends on:
- Test Coverage Phase 2: Refactoring for Testability #198 (Phase 2 refactoring)
- Migrate from WebView to WKWebView #111 (WKWebView migration - for stable WebView testing)
XCUITest Target Setup
New Target: MacDownUITests
Configuration:
- Test target with host application
- Accessibility identifiers added to key UI elements
- Test data fixtures (sample markdown files)
Critical Path Tests (8-10 tests max)
Keep the UI test suite small and focused on high-value scenarios.
BasicWorkflowUITests.swift
class BasicWorkflowUITests: XCTestCase {
func testCreateEditExportWorkflow() {
// New doc → type markdown → preview updates → export
}
func testFileOpenSaveWorkflow() {
// Open file → modify → save → verify disk
}
func testPreviewUpdatesInRealTime() {
// Type in editor → preview renders
}
}ScrollSyncUITests.swift
class ScrollSyncUITests: XCTestCase {
func testScrollEditorUpdatesPreview() {
// Issue #39: Scroll editor → preview follows
}
func testScrollSyncWithImages() {
// Long doc with images → scroll stays synced
}
func testScrollPositionRestoration() {
// Scroll → close → reopen → position restored
}
}ExportUITests.swift
class ExportUITests: XCTestCase {
func testExportHTML() {
// Menu → Export → file created
}
func testCopyAsHTML() {
// Menu → Copy as HTML → clipboard has HTML
}
}PreferencesUITests.swift
class PreferencesUITests: XCTestCase {
func testThemeChange() {
// Prefs → change theme → preview updates
}
func testSyntaxHighlightingToggle() {
// Prefs → toggle highlighting → preview changes
}
}Page Object Pattern
class EditorPage {
let app: XCUIApplication
var textView: XCUIElement { app.textViews["markdown-editor"] }
func typeMarkdown(_ text: String) {
textView.click()
textView.typeText(text)
}
}
class PreviewPage {
let app: XCUIApplication
var webView: XCUIElement { app.webViews["preview-pane"] }
func waitForRender() {
webView.waitForExistence(timeout: 2)
}
func containsText(_ text: String) -> Bool {
return webView.staticTexts[text].exists
}
}Test Data Fixtures
MacDownUITests/
Fixtures/
simple.md
with-images.md
long-document.md
math-equations.md
Accessibility Identifiers Required
Add to codebase before XCUITests:
markdown-editoron MPEditorViewpreview-paneon WebView/WKWebViewdocument-windowon main window- Menu item identifiers as needed
Success Criteria
- XCUITest target created and builds
- 8-10 focused UI tests implemented
- Tests complete in < 10 minutes
- Test flakiness < 5%
- Page objects provide reusable abstractions
Risks and Mitigations
| Risk | Mitigation |
|---|---|
| XCUITest flakiness | Use waitForExistence(), generous timeouts, retry logic |
| WebView testing unreliable | Ensure WKWebView migration (#111) complete first |
| Slow test execution | Keep test count low, parallelize where possible |
Related
plans/xcuitest.md- Full technical design- Test Coverage Phase 1: Enhanced Unit Tests #197 - Phase 1 (prerequisite)
- Test Coverage Phase 2: Refactoring for Testability #198 - Phase 2 (prerequisite)
- Migrate from WebView to WKWebView #111 - WKWebView migration (prerequisite for stable testing)