Skip to content

Commit

Permalink
[Editor] Avoid to have the ML disclaimer when the ML engine isn't rea…
Browse files Browse the repository at this point in the history
…dy (bug 1917543)
  • Loading branch information
calixteman committed Sep 9, 2024
1 parent a1b45d6 commit f8b3a85
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
23 changes: 23 additions & 0 deletions test/integration/stamp_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,5 +1096,28 @@ describe("Stamp Editor", () => {
await page.waitForSelector("#newAltTextDialog", { visible: false });
}
});

it("must check the new alt text flow (part 3)", async () => {
// Run sequentially to avoid clipboard issues.
for (const [, page] of pages) {
await page.evaluate(() => {
window.PDFViewerApplication.mlManager.isReadyFlag = false;
});

await switchToStamp(page);

// Add an image.
await copyImage(page, "../images/firefox_logo.png", 0);
const editorSelector = getEditorSelector(0);
await page.waitForSelector(editorSelector);
await waitForSerialized(page, 1);

// Wait for the dialog to be visible.
await page.waitForSelector("#newAltTextDialog", { visible: true });

// Check we haven't the disclaimer.
await page.waitForSelector("#newAltTextDisclaimer[hidden]");
}
});
});
});
5 changes: 3 additions & 2 deletions web/genericcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class FakeMLManager {

constructor({ enableGuessAltText, enableAltTextModelDownload }) {
this.enableGuessAltText = enableGuessAltText;
this.enableAltTextModelDownload = enableAltTextModelDownload;
this.enableAltTextModelDownload = this.isReadyFlag =
enableAltTextModelDownload;
}

setEventBus(eventBus, abortSignal) {
Expand Down Expand Up @@ -126,7 +127,7 @@ class FakeMLManager {
}

isReady(_name) {
return this.enableAltTextModelDownload;
return this.isReadyFlag;
}

guess({ request: { data } }) {
Expand Down
1 change: 1 addition & 0 deletions web/new_alt_text_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ class NewAltTextManager {
this.#firstTime = firstTime;
let { mlManager } = uiManager;
let hasAI = !!mlManager;
this.#toggleTitleAndDisclaimer();

if (mlManager && !mlManager.isReady("altText")) {
hasAI = false;
Expand Down

0 comments on commit f8b3a85

Please sign in to comment.