From 89ac7b336f822b0db49fba6e630ea70c0a64f857 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Cutzach?= Date: Mon, 4 Nov 2024 15:56:12 +0100 Subject: [PATCH] fix: test after chrome driver updated to 130 --- app/common/UserAPI.ts | 3 +-- test/nbrowser/DocTypeConversion.ts | 21 +++++++++++++++------ test/nbrowser/elementUtils.ts | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/common/UserAPI.ts b/app/common/UserAPI.ts index d477f3a441..f58f05b8de 100644 --- a/app/common/UserAPI.ts +++ b/app/common/UserAPI.ts @@ -135,9 +135,8 @@ export const DOCTYPE_TUTORIAL = 'tutorial'; // null stands for normal document type, the one set by default at document creation. export type DocumentType = 'template'|'tutorial'|null; -export function persistType(doctype: DocumentType, docId: string|undefined){ +export function persistType(type: DocumentType, docId: string|undefined) { docId = docId?.split("~")[0]; - const type = doctype === null ? "" : doctype; return fetch(`/o/docs/api/docs/${docId}`, { method: 'PATCH', headers: {"Content-Type": "application/json"}, diff --git a/test/nbrowser/DocTypeConversion.ts b/test/nbrowser/DocTypeConversion.ts index 7522e088a6..4dce8a1750 100644 --- a/test/nbrowser/DocTypeConversion.ts +++ b/test/nbrowser/DocTypeConversion.ts @@ -28,11 +28,21 @@ describe("Document Type Conversion", function () { assert.isTrue(await button.visible()); } + async function checkDisplayedLabel(typeLabel: TypeLabels) { + // Wait in case of page reload + await displayedLabel.wait(); + + assert.equal(await displayedLabel.element().getText(), typeLabel); + } + async function convert(from: TypeLabels, to: TypeLabels) { await gu.openDocumentSettings(); // Ensure that initial document type is the expected one. - assert.equal(await displayedLabel.element().getText(), from); + const displayedLabelElement = displayedLabel.element(); + + // Check initially displayed label value + await checkDisplayedLabel(from); // Click to open the modal await editButton.click(); @@ -48,12 +58,11 @@ describe("Document Type Conversion", function () { // Confirm the choice await modalConfirm.click(); - // Wait for the page to be reloaded - await driver.wait(until.stalenessOf(displayedLabel.element())); - await displayedLabel.wait(); + // Wait for the page to be unloaded + await driver.wait(until.stalenessOf(displayedLabelElement), 3000); - // check that the displayedLabel is now equal to convert destination - assert.equal(await displayedLabel.element().getText(), to); + // checks that the displayedLabel is now equal to convert destination + await checkDisplayedLabel(to); } async function isRegular(){ diff --git a/test/nbrowser/elementUtils.ts b/test/nbrowser/elementUtils.ts index ec7e0b9189..11984ccff5 100644 --- a/test/nbrowser/elementUtils.ts +++ b/test/nbrowser/elementUtils.ts @@ -14,7 +14,7 @@ export const element = (testId: string) => ({ return driver.find(testId); }, async wait() { - await driver.findWait(testId, 2000); + await driver.findWait(testId, 10000); }, async visible() { return await this.element().isDisplayed();