Skip to content

Commit

Permalink
fix: test after chrome driver updated to 130
Browse files Browse the repository at this point in the history
  • Loading branch information
hexaltation committed Jan 14, 2025
1 parent be7fcb9 commit 89ac7b3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
3 changes: 1 addition & 2 deletions app/common/UserAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down
21 changes: 15 additions & 6 deletions test/nbrowser/DocTypeConversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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(){
Expand Down
2 changes: 1 addition & 1 deletion test/nbrowser/elementUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 89ac7b3

Please sign in to comment.