Files
ShadowsocksX-NG/ShadowsocksX-NG2/Tests/SettingsWorkflowInterfaceTests+CommitFailures.swift
T
Qiu Yuzhou a8cd6262c2 feat(proxy): remove PAC and accept ACL system proxy path
Remove the PAC product feature entirely: PAC HTTP service, port, health
probe, runtime extension, PAC URL system proxy projection, PAC rule
editing, and GFWList URL settings. The product now exposes rule / global /
direct modes only, all projected as a local SOCKS system-proxy target.

First-run defaults are rule + proxyWhenUnmatched, agent on, system proxy
off. Homepage and status menu share one ProxyControlSnapshot showing the
three modes and rule sub-options. Manual servers, subscriptions, Legacy
import, and independent SOCKS/HTTP inbounds are retained.

Fix: include verbose in SslocalListenFingerprint so a verbose-only
contract change restarts sslocal instead of leaving RUST_LOG stale.

Revise CONTEXT.md vocabulary, ADR-0007, and ADR-0009. Record GFWList
exception shadowing, IPv6 system-exception, DNS, and traffic-coverage
boundaries. Add host acceptance evidence document.

Closes #67
2026-09-26 21:58:12 +08:00

83 lines
2.7 KiB
Swift

import XCTest
@testable import ShadowsocksX_NG2
extension SettingsWorkflowInterfaceTests {
// MARK: - 提交中与失败点名文案
func testCommitFailureSurfacesNamedReasonAndKeepsDraft() async throws {
committing.updateError = FakeCommitError.io
let workflow = makeWorkflow()
workflow.draft.timeoutSeconds = 120
_ = await workflow.save()
await waitUntil(workflow.lastFailure != nil)
XCTAssertEqual(workflow.lastFailure, .unknown)
XCTAssertEqual(workflow.lastFailure?.presentableMessage, AppPresentation.unknownError)
XCTAssertFalse(workflow.isCommitting)
XCTAssertEqual(workflow.draft.timeoutSeconds, 120, "失败不吞掉草稿")
XCTAssertEqual(committing.committedSettings.timeoutSeconds, 60, "失败不半提交")
XCTAssertTrue(workflow.isDirty)
}
func testStorageAndCredentialFailuresNameTheReason() async throws {
let workflow = makeWorkflow()
workflow.draft.timeoutSeconds = 120
committing.updateError = ProxySettingsStoreError.ioFailure(detail: "disk full")
_ = await workflow.save()
await waitUntil(!workflow.isCommitting)
XCTAssertEqual(
workflow.lastFailure,
.store(.ioFailure(detail: "disk full")))
XCTAssertTrue(workflow.lastFailure?.presentableMessage.contains("偏好文件") == true)
let reference = CredentialReference(rawValue: "test-ref")
committing.updateError = ProxySettingsStoreError.missingCredential(reference)
_ = await workflow.save()
await waitUntil(
workflow.lastFailure
== .store(.missingCredential(reference)))
XCTAssertEqual(
workflow.lastFailure,
.store(.missingCredential(reference)))
}
func testCommittingStateBlocksRepeatedSave() async throws {
committing.updateGate = AsyncGate()
let workflow = makeWorkflow()
workflow.draft.timeoutSeconds = 120
let first = Task { await workflow.save() }
await Task.yield()
await waitUntil(workflow.isCommitting)
XCTAssertTrue(workflow.isCommitting)
XCTAssertFalse(workflow.canSave, "提交中保存门禁关闭")
let second = await workflow.save()
committing.updateGate?.release()
_ = await first.value
XCTAssertEqual(second, .rejected(.inProgress))
XCTAssertEqual(committing.updateCalls.count, 1, "提交中不得重复触发")
}
func testResetFailureSurfacesNamedReason() async throws {
committing.resetError = FakeCommitError.io
let workflow = makeWorkflow()
_ = await workflow.reset()
_ = await workflow.confirmReset()
await waitUntil(workflow.lastFailure != nil)
XCTAssertEqual(workflow.lastFailure, .unknown)
}
private enum FakeCommitError: Error, CustomStringConvertible {
// swiftlint:disable:next identifier_name
case io
var description: String { "fake-io-error" }
}
}