mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2026-10-20 08:12:31 +00:00
Harden real-runtime workflow validation
This commit is contained in:
@@ -115,7 +115,6 @@ export async function openLiveSyncSettings(page: Page, timeoutMs = 10_000): Prom
|
||||
const setting = host.app?.setting;
|
||||
if (setting === undefined) throw new Error("Obsidian settings are unavailable");
|
||||
setting.open();
|
||||
setting.openTabById("obsidian-livesync");
|
||||
});
|
||||
|
||||
const deadline = Date.now() + timeoutMs;
|
||||
@@ -137,6 +136,16 @@ export async function openLiveSyncSettings(page: Page, timeoutMs = 10_000): Prom
|
||||
}
|
||||
if (settingsPage === undefined) throw new Error("Obsidian did not open its settings interface");
|
||||
|
||||
// Obsidian may discard a tab selection made before the settings modal has
|
||||
// finished opening. Select the plug-in only after a settings renderer is
|
||||
// visible so slower real-runtime sessions cannot remain on the About tab.
|
||||
await hostPage.evaluate(() => {
|
||||
const host = globalThis as ObsidianSettingsHost;
|
||||
const setting = host.app?.setting;
|
||||
if (setting === undefined) throw new Error("Obsidian settings are unavailable");
|
||||
setting.openTabById("obsidian-livesync");
|
||||
});
|
||||
|
||||
const dialogue = settingsPage.locator(".modal.mod-settings:visible").last();
|
||||
const imperativeRoot = dialogue.locator(".sls-setting:visible").last();
|
||||
const firstDeclarativeEntry = declarativePageEntry(dialogue, "Change Log");
|
||||
@@ -270,7 +279,8 @@ export async function allowPendingObsidianTestVaultOpenAction(
|
||||
export async function captureObsidianElement(
|
||||
port: number,
|
||||
filename: string,
|
||||
resolveElement: (page: Page) => Locator | Promise<Locator>
|
||||
resolveElement: (page: Page) => Locator | Promise<Locator>,
|
||||
timeoutMs = 10_000
|
||||
): Promise<string> {
|
||||
const outputDirectory = process.env.E2E_OBSIDIAN_DIAGNOSTICS_DIR ?? "/tmp/obsidian-livesync-e2e";
|
||||
const screenshotPath = join(outputDirectory, filename);
|
||||
@@ -279,7 +289,7 @@ export async function captureObsidianElement(
|
||||
await withObsidianPage(port, async (page) => {
|
||||
try {
|
||||
const element = await resolveElement(page);
|
||||
await element.waitFor({ state: "visible", timeout: 10000 });
|
||||
await element.waitFor({ state: "visible", timeout: timeoutMs });
|
||||
await element.screenshot({
|
||||
path: screenshotPath,
|
||||
animations: "disabled",
|
||||
|
||||
Reference in New Issue
Block a user