web: fix backup tests

This commit is contained in:
Abdullah Atta
2023-01-04 12:42:52 +05:00
parent 2beccd6918
commit 5a540362c0
2 changed files with 15 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
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 { NOTE, USER } from "./utils";
@@ -26,25 +26,25 @@ test("create a backup", async ({ page }) => {
const notes = await app.goToNotes();
await notes.createNote(NOTE);
const settings = await app.goToSettings();
const backup = await settings.createBackup();
expect(backup.length > 0).toBeTruthy();
});
test.setTimeout(45 * 1000);
test("restore a backup", async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const settings = await app.goToSettings();
await settings.restoreData("backup.nnbackup", USER.CURRENT.password);
await settings.restoreData("backup.nnbackup");
const notes = await app.goToNotes();
expect(await notes.isEmpty()).toBeTruthy();
expect(await notes.isEmpty()).toBeFalsy();
const notebooks = await app.goToNotebooks();
expect(await notebooks.isEmpty()).toBeTruthy();
const favotites = await app.goToFavorites();
expect(await favotites.isEmpty()).toBeTruthy();
expect(await notebooks.isEmpty()).toBeFalsy();
const tags = await app.goToTags();
expect(await tags.isEmpty()).toBeTruthy();
expect(await tags.isEmpty()).toBeFalsy();
});
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.login(USER.CURRENT);
const settings = await app.goToSettings();
const backup = await settings.createBackup(USER.CURRENT.password);
expect(backup.length > 0).toBeTruthy();
@@ -60,15 +61,12 @@ test("create an encrypted backup", async ({ page }) => {
test("restore an encrypted backup", async ({ page }) => {
const app = new AppModel(page);
await app.goto();
const settings = await app.goToSettings();
await settings.restoreData("encrypted.nnbackup", USER.CURRENT.password);
const notes = await app.goToNotes();
expect(await notes.isEmpty()).toBeTruthy();
expect(await notes.isEmpty()).toBeFalsy();
const notebooks = await app.goToNotebooks();
expect(await notebooks.isEmpty()).toBeTruthy();
const favotites = await app.goToFavorites();
expect(await favotites.isEmpty()).toBeTruthy();
const tags = await app.goToTags();
expect(await tags.isEmpty()).toBeTruthy();
expect(await notebooks.isEmpty()).toBeFalsy();
});

View File

@@ -76,7 +76,7 @@ export class SettingsViewModel {
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.restoreBackup.click();
await uploadFile(this.page, this.restoreBackup, filename);