mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-16 19:57:52 +01:00
web: fix backup tests
This commit is contained in:
@@ -16,7 +16,7 @@ GNU General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
import { test, Browser, expect } from "@playwright/test";
|
import { test, expect } from "@playwright/test";
|
||||||
import { AppModel } from "./models/app.model";
|
import { AppModel } from "./models/app.model";
|
||||||
import { NOTE, USER } from "./utils";
|
import { NOTE, USER } from "./utils";
|
||||||
|
|
||||||
@@ -26,25 +26,25 @@ test("create a backup", async ({ page }) => {
|
|||||||
const notes = await app.goToNotes();
|
const notes = await app.goToNotes();
|
||||||
await notes.createNote(NOTE);
|
await notes.createNote(NOTE);
|
||||||
const settings = await app.goToSettings();
|
const settings = await app.goToSettings();
|
||||||
|
|
||||||
const backup = await settings.createBackup();
|
const backup = await settings.createBackup();
|
||||||
|
|
||||||
expect(backup.length > 0).toBeTruthy();
|
expect(backup.length > 0).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test.setTimeout(45 * 1000);
|
|
||||||
test("restore a backup", async ({ page }) => {
|
test("restore a backup", async ({ page }) => {
|
||||||
const app = new AppModel(page);
|
const app = new AppModel(page);
|
||||||
await app.goto();
|
await app.goto();
|
||||||
|
|
||||||
const settings = await app.goToSettings();
|
const settings = await app.goToSettings();
|
||||||
await settings.restoreData("backup.nnbackup", USER.CURRENT.password);
|
|
||||||
|
await settings.restoreData("backup.nnbackup");
|
||||||
|
|
||||||
const notes = await app.goToNotes();
|
const notes = await app.goToNotes();
|
||||||
expect(await notes.isEmpty()).toBeTruthy();
|
expect(await notes.isEmpty()).toBeFalsy();
|
||||||
const notebooks = await app.goToNotebooks();
|
const notebooks = await app.goToNotebooks();
|
||||||
expect(await notebooks.isEmpty()).toBeTruthy();
|
expect(await notebooks.isEmpty()).toBeFalsy();
|
||||||
const favotites = await app.goToFavorites();
|
|
||||||
expect(await favotites.isEmpty()).toBeTruthy();
|
|
||||||
const tags = await app.goToTags();
|
const tags = await app.goToTags();
|
||||||
expect(await tags.isEmpty()).toBeTruthy();
|
expect(await tags.isEmpty()).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test("create an encrypted backup", async ({ page }) => {
|
test("create an encrypted backup", async ({ page }) => {
|
||||||
@@ -52,6 +52,7 @@ test("create an encrypted backup", async ({ page }) => {
|
|||||||
await app.auth.goto();
|
await app.auth.goto();
|
||||||
await app.auth.login(USER.CURRENT);
|
await app.auth.login(USER.CURRENT);
|
||||||
const settings = await app.goToSettings();
|
const settings = await app.goToSettings();
|
||||||
|
|
||||||
const backup = await settings.createBackup(USER.CURRENT.password);
|
const backup = await settings.createBackup(USER.CURRENT.password);
|
||||||
|
|
||||||
expect(backup.length > 0).toBeTruthy();
|
expect(backup.length > 0).toBeTruthy();
|
||||||
@@ -60,15 +61,12 @@ test("create an encrypted backup", async ({ page }) => {
|
|||||||
test("restore an encrypted backup", async ({ page }) => {
|
test("restore an encrypted backup", async ({ page }) => {
|
||||||
const app = new AppModel(page);
|
const app = new AppModel(page);
|
||||||
await app.goto();
|
await app.goto();
|
||||||
|
|
||||||
const settings = await app.goToSettings();
|
const settings = await app.goToSettings();
|
||||||
|
|
||||||
await settings.restoreData("encrypted.nnbackup", USER.CURRENT.password);
|
await settings.restoreData("encrypted.nnbackup", USER.CURRENT.password);
|
||||||
|
|
||||||
const notes = await app.goToNotes();
|
const notes = await app.goToNotes();
|
||||||
expect(await notes.isEmpty()).toBeTruthy();
|
expect(await notes.isEmpty()).toBeFalsy();
|
||||||
const notebooks = await app.goToNotebooks();
|
const notebooks = await app.goToNotebooks();
|
||||||
expect(await notebooks.isEmpty()).toBeTruthy();
|
expect(await notebooks.isEmpty()).toBeFalsy();
|
||||||
const favotites = await app.goToFavorites();
|
|
||||||
expect(await favotites.isEmpty()).toBeTruthy();
|
|
||||||
const tags = await app.goToTags();
|
|
||||||
expect(await tags.isEmpty()).toBeTruthy();
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export class SettingsViewModel {
|
|||||||
return await downloadAndReadFile(this.page, this.backupData, "utf-8");
|
return await downloadAndReadFile(this.page, this.backupData, "utf-8");
|
||||||
}
|
}
|
||||||
|
|
||||||
async restoreData(filename: string, password: string | undefined) {
|
async restoreData(filename: string, password?: string) {
|
||||||
await this.backupRestoreContainer.click();
|
await this.backupRestoreContainer.click();
|
||||||
await this.restoreBackup.click();
|
await this.restoreBackup.click();
|
||||||
await uploadFile(this.page, this.restoreBackup, filename);
|
await uploadFile(this.page, this.restoreBackup, filename);
|
||||||
|
|||||||
Reference in New Issue
Block a user