mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-07-27 23:13:03 +00:00
Improve conflict inspection and recovery workflow
This commit is contained in:
@@ -765,18 +765,39 @@ async function verifyHatchSurfacesAndSafeActions(): Promise<string> {
|
||||
for (const label of [
|
||||
"Write logs into the file",
|
||||
"Recreate chunks for current Vault files",
|
||||
"Verify and repair all files",
|
||||
"Inspect conflicts and file/database differences",
|
||||
"Resolve All conflicted files by the newer one",
|
||||
]) {
|
||||
await liveSyncSettings.locator(".setting-item-name", { hasText: label }).waitFor({
|
||||
state: "visible",
|
||||
timeout: uiTimeoutMs,
|
||||
});
|
||||
}
|
||||
const settingNames = await liveSyncSettings.locator(".setting-item-name").allTextContents();
|
||||
const recreateIndex = settingNames.findIndex((name) =>
|
||||
name.includes("Recreate chunks for current Vault files")
|
||||
);
|
||||
const inspectIndex = settingNames.findIndex((name) =>
|
||||
name.includes("Inspect conflicts and file/database differences")
|
||||
);
|
||||
const resolveIndex = settingNames.findIndex((name) =>
|
||||
name.includes("Resolve All conflicted files by the newer one")
|
||||
);
|
||||
if (
|
||||
recreateIndex === -1 ||
|
||||
inspectIndex === -1 ||
|
||||
resolveIndex === -1 ||
|
||||
!(recreateIndex < inspectIndex && inspectIndex < resolveIndex)
|
||||
) {
|
||||
throw new Error(
|
||||
"Recovery actions are not ordered from chunk recreation through inspection to bulk conflict resolution"
|
||||
);
|
||||
}
|
||||
await liveSyncSettings.getByRole("button", { name: "Recreate current chunks", exact: true }).waitFor({
|
||||
state: "visible",
|
||||
timeout: uiTimeoutMs,
|
||||
});
|
||||
await liveSyncSettings.getByRole("button", { name: "Verify all", exact: true }).waitFor({
|
||||
await liveSyncSettings.getByRole("button", { name: "Scan all files", exact: true }).waitFor({
|
||||
state: "visible",
|
||||
timeout: uiTimeoutMs,
|
||||
});
|
||||
@@ -897,7 +918,7 @@ async function verifyHatchSurfacesAndSafeActions(): Promise<string> {
|
||||
await page
|
||||
.locator(".sls-setting:visible")
|
||||
.last()
|
||||
.getByRole("button", { name: "Verify all", exact: true })
|
||||
.getByRole("button", { name: "Scan all files", exact: true })
|
||||
.click({
|
||||
timeout: uiTimeoutMs,
|
||||
});
|
||||
|
||||
@@ -230,12 +230,15 @@ function revisionCard(settings: Locator, revision: string): Locator {
|
||||
}
|
||||
|
||||
async function openRevisionActionMenu(page: Page, settings: Locator, revision: string): Promise<Locator> {
|
||||
await revisionCard(settings, revision)
|
||||
.getByRole("button", {
|
||||
name: `More actions for revision ${revision}`,
|
||||
exact: true,
|
||||
})
|
||||
.click({ timeout: uiTimeoutMs });
|
||||
const actionButton = revisionCard(settings, revision).getByRole("button", {
|
||||
name: `More actions for revision ${revision}`,
|
||||
exact: true,
|
||||
});
|
||||
await actionButton.locator("svg.lucide-wrench").waitFor({
|
||||
state: "visible",
|
||||
timeout: uiTimeoutMs,
|
||||
});
|
||||
await actionButton.click({ timeout: uiTimeoutMs });
|
||||
const menu = page.locator(".menu:visible").last();
|
||||
await menu.waitFor({ state: "visible", timeout: uiTimeoutMs });
|
||||
const box = await menu.boundingBox();
|
||||
@@ -366,16 +369,18 @@ async function main(): Promise<void> {
|
||||
await settings.waitFor({ state: "visible", timeout: uiTimeoutMs });
|
||||
await settings.locator('.sls-setting-menu-btn[title="Hatch"]').click({ timeout: uiTimeoutMs });
|
||||
const verifySetting = settings.locator(".setting-item").filter({
|
||||
has: page.getByText("Verify and repair all files", { exact: true }),
|
||||
has: page.getByText("Inspect conflicts and file/database differences", {
|
||||
exact: true,
|
||||
}),
|
||||
});
|
||||
await verifySetting.getByRole("button", { name: "Verify all", exact: true }).click({
|
||||
await verifySetting.getByRole("button", { name: "Scan all files", exact: true }).click({
|
||||
timeout: uiTimeoutMs,
|
||||
});
|
||||
const card = repairCard(settings);
|
||||
await card.waitFor({ state: "visible", timeout: uiTimeoutMs });
|
||||
if ((await settings.locator(".sls-repair-result").filter({ hasText: healthyDeletedPath }).count()) !== 0) {
|
||||
throw new Error(
|
||||
`Verify and Repair reported the healthy logical deletion ${healthyDeletedPath} (${healthyDeletionRevision}).`
|
||||
`File/database inspection reported the healthy logical deletion ${healthyDeletedPath} (${healthyDeletionRevision}).`
|
||||
);
|
||||
}
|
||||
const winnerRevision = revisionCard(settings, fixture.winnerRevision);
|
||||
|
||||
Reference in New Issue
Block a user