web: fix backup tests for good

This commit is contained in:
Abdullah Atta
2024-07-27 09:26:18 +05:00
committed by Abdullah Atta
parent f95442a828
commit b6021dc76b
3 changed files with 14 additions and 13 deletions

View File

@@ -258,7 +258,7 @@ export class NoteContextMenuModel extends BaseProperties {
const zip = await downloadAndReadFile(
this.noteLocator.page(),
this.menu.getItem(format),
() => this.menu.getItem(format).click(),
null
);

View File

@@ -113,16 +113,17 @@ export class SettingsViewModel {
const item = await this.navigation.findItem("Backup & export");
await item?.click();
const backupData = this.page
.locator(getTestId("setting-create-backup"))
.locator("select");
if (password) {
await backupData.selectOption({ value: "partial", label: "Backup" });
await fillPasswordDialog(this.page, password);
}
return await downloadAndReadFile(this.page, backupData, "utf-8");
return await downloadAndReadFile(
this.page,
async () => {
const backupData = this.page
.locator(getTestId("setting-create-backup"))
.locator("select");
await backupData.selectOption({ value: "partial", label: "Backup" });
if (password) await fillPasswordDialog(this.page, password);
},
"utf-8"
);
}
async restoreData(filename: string, password?: string) {

View File

@@ -103,12 +103,12 @@ async function editNote(page: Page, note: Partial<Note>, noDelay = false) {
async function downloadAndReadFile(
page: Page,
action: Locator,
action: () => Promise<void>,
encoding: BufferEncoding | null | undefined = "utf-8"
) {
const [download] = await Promise.all([
page.waitForEvent("download"),
await action.click()
action()
]);
const dir = fs.mkdtempSync(join(tmpdir(), "nntests_"));