Add regression tests for duplicate sidebar git publishes
This commit is contained in:
parent
2d2d8da1c7
commit
642aead088
1 changed files with 80 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ import WebKit
|
||||||
import ObjectiveC.runtime
|
import ObjectiveC.runtime
|
||||||
import Bonsplit
|
import Bonsplit
|
||||||
import UserNotifications
|
import UserNotifications
|
||||||
|
import Combine
|
||||||
|
|
||||||
#if canImport(cmux_DEV)
|
#if canImport(cmux_DEV)
|
||||||
@testable import cmux_DEV
|
@testable import cmux_DEV
|
||||||
|
|
@ -2111,6 +2112,85 @@ final class WorkspacePanelGitBranchTests: XCTestCase {
|
||||||
XCTAssertEqual(ordered.map(\.isDirty), [false, true])
|
XCTAssertEqual(ordered.map(\.isDirty), [false, true])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testUpdatingFocusedPanelGitBranchWithSameStateDoesNotRepublishWorkspace() {
|
||||||
|
let workspace = Workspace()
|
||||||
|
guard let panelId = workspace.focusedPanelId else {
|
||||||
|
XCTFail("Expected initial focused panel")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var publishCount = 0
|
||||||
|
let cancellable = workspace.objectWillChange.sink { _ in
|
||||||
|
publishCount += 1
|
||||||
|
}
|
||||||
|
defer { cancellable.cancel() }
|
||||||
|
|
||||||
|
workspace.updatePanelGitBranch(panelId: panelId, branch: "main", isDirty: false)
|
||||||
|
let baselinePublishCount = publishCount
|
||||||
|
|
||||||
|
XCTAssertGreaterThan(
|
||||||
|
baselinePublishCount,
|
||||||
|
0,
|
||||||
|
"Expected the first focused branch update to publish workspace changes"
|
||||||
|
)
|
||||||
|
|
||||||
|
workspace.updatePanelGitBranch(panelId: panelId, branch: "main", isDirty: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(
|
||||||
|
publishCount,
|
||||||
|
baselinePublishCount,
|
||||||
|
"Expected identical focused branch refreshes to avoid extra workspace publishes"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testUpdatingFocusedPanelPullRequestWithSameStateDoesNotRepublishWorkspace() {
|
||||||
|
let workspace = Workspace()
|
||||||
|
guard let panelId = workspace.focusedPanelId else {
|
||||||
|
XCTFail("Expected initial focused panel")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
workspace.updatePanelGitBranch(panelId: panelId, branch: "feature/sidebar-pr", isDirty: false)
|
||||||
|
|
||||||
|
var publishCount = 0
|
||||||
|
let cancellable = workspace.objectWillChange.sink { _ in
|
||||||
|
publishCount += 1
|
||||||
|
}
|
||||||
|
defer { cancellable.cancel() }
|
||||||
|
|
||||||
|
let pullRequestURL = URL(string: "https://github.com/manaflow-ai/cmux/pull/2388")!
|
||||||
|
workspace.updatePanelPullRequest(
|
||||||
|
panelId: panelId,
|
||||||
|
number: 2388,
|
||||||
|
label: "PR",
|
||||||
|
url: pullRequestURL,
|
||||||
|
status: .open,
|
||||||
|
branch: "feature/sidebar-pr"
|
||||||
|
)
|
||||||
|
let baselinePublishCount = publishCount
|
||||||
|
|
||||||
|
XCTAssertGreaterThan(
|
||||||
|
baselinePublishCount,
|
||||||
|
0,
|
||||||
|
"Expected the first focused pull request update to publish workspace changes"
|
||||||
|
)
|
||||||
|
|
||||||
|
workspace.updatePanelPullRequest(
|
||||||
|
panelId: panelId,
|
||||||
|
number: 2388,
|
||||||
|
label: "PR",
|
||||||
|
url: pullRequestURL,
|
||||||
|
status: .open,
|
||||||
|
branch: "feature/sidebar-pr"
|
||||||
|
)
|
||||||
|
|
||||||
|
XCTAssertEqual(
|
||||||
|
publishCount,
|
||||||
|
baselinePublishCount,
|
||||||
|
"Expected identical focused pull request refreshes to avoid extra workspace publishes"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
@MainActor
|
@MainActor
|
||||||
func testSidebarPullRequestsTrackFocusedPanelOnly() {
|
func testSidebarPullRequestsTrackFocusedPanelOnly() {
|
||||||
let workspace = Workspace()
|
let workspace = Workspace()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue