mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: fix backup tests for good
This commit is contained in:
committed by
Abdullah Atta
parent
f95442a828
commit
b6021dc76b
@@ -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
|
||||
);
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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_"));
|
||||
|
||||
Reference in New Issue
Block a user