mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
web: improve backups test reliability
This commit is contained in:
@@ -48,7 +48,9 @@ test("restore a backup", async ({ page }) => {
|
||||
expect(await tags.isEmpty()).toBeFalsy();
|
||||
});
|
||||
|
||||
test("create an encrypted backup", async ({ page }) => {
|
||||
test("create an encrypted backup", async ({ page }, info) => {
|
||||
info.setTimeout(60 * 1000);
|
||||
|
||||
const app = new AppModel(page);
|
||||
await app.auth.goto();
|
||||
await app.auth.login(USER.CURRENT);
|
||||
|
||||
@@ -40,7 +40,8 @@ export class BaseItemModel {
|
||||
}
|
||||
|
||||
async click() {
|
||||
await this.locator.scrollIntoViewIfNeeded();
|
||||
if (!(await this.locator.isVisible()))
|
||||
await this.locator.scrollIntoViewIfNeeded();
|
||||
await this.locator.click();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import { Page } from "@playwright/test";
|
||||
import { downloadAndReadFile, getTestId, uploadFile } from "../utils";
|
||||
import { confirmDialog, fillPasswordDialog, waitToHaveText } from "./utils";
|
||||
import {
|
||||
confirmDialog,
|
||||
fillPasswordDialog,
|
||||
waitForDialog,
|
||||
waitToHaveText
|
||||
} from "./utils";
|
||||
import { NavigationMenuModel } from "./navigation-menu.model";
|
||||
|
||||
export class SettingsViewModel {
|
||||
@@ -112,5 +117,7 @@ export class SettingsViewModel {
|
||||
|
||||
await uploadFile(this.page, restoreBackup, filename);
|
||||
if (password) await fillPasswordDialog(this.page, password);
|
||||
|
||||
await waitForDialog(this.page, "Restoring backup");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,6 +140,14 @@ export async function denyDialog(page: Page) {
|
||||
// await dialogConfirm.waitFor({ state: "detached" });
|
||||
}
|
||||
|
||||
export async function waitForDialog(page: Page, title: string) {
|
||||
const dialogTitle = page
|
||||
.locator(getTestId("dialog-title"))
|
||||
.filter({ hasText: title });
|
||||
await dialogTitle.waitFor({ state: "attached" });
|
||||
await dialogTitle.waitFor({ state: "detached" });
|
||||
}
|
||||
|
||||
export async function waitToHaveText(page: Page, id: string) {
|
||||
await page.waitForFunction(
|
||||
({ id }) => {
|
||||
|
||||
@@ -130,6 +130,7 @@ function BaseDialog(props: React.PropsWithChildren<DialogProps>) {
|
||||
{props.title && (
|
||||
<Text
|
||||
variant="heading"
|
||||
data-test-id="dialog-title"
|
||||
sx={{
|
||||
fontSize: "subheading",
|
||||
textAlign: props.textAlignment || "left",
|
||||
|
||||
Reference in New Issue
Block a user