Skip to content

Commit

Permalink
Merge pull request #18779 from calixteman/bug1920515
Browse files Browse the repository at this point in the history
[Editor] Don't show the ml toggle button when the ml is disabled (bug 1920515)
  • Loading branch information
calixteman authored Sep 23, 2024
2 parents b65b774 + d35a20a commit c90ce5d
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 1 deletion.
68 changes: 68 additions & 0 deletions test/integration/stamp_editor_spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,74 @@ describe("Stamp Editor", () => {
});
});

describe("New alt-text flow (bug 1920515)", () => {
let pages;

beforeAll(async () => {
pages = await loadAndWait(
"empty.pdf",
".annotationEditorLayer",
null,
{
eventBusSetup: eventBus => {
eventBus.on("annotationeditoruimanager", ({ uiManager }) => {
window.uiManager = uiManager;
});
},
},
{
enableAltText: false,
enableFakeMLManager: false,
enableUpdatedAddImage: true,
enableGuessAltText: true,
}
);
});

afterEach(async () => {
for (const [, page] of pages) {
if (await isVisible(page, "#newAltTextDialog")) {
await page.keyboard.press("Escape");
await page.waitForSelector("#newAltTextDisclaimer", {
visible: false,
});
}
await page.evaluate(() => {
window.uiManager.reset();
});
// Disable editing mode.
await switchToStamp(page, /* disable */ true);
}
});

afterAll(async () => {
await closePages(pages);
});

it("must check that the toggle button isn't displayed when there is no AI", async () => {
// Run sequentially to avoid clipboard issues.
for (const [, page] of pages) {
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.noAi", { visible: true });

// enableFakeMLManager is false, so it means that we don't have ML but
// we're using the new flow, hence we don't want to have the toggle
// button.
await page.waitForSelector("#newAltTextCreateAutomatically", {
hidden: true,
});
}
});
});

describe("No auto-resize", () => {
let pages;

Expand Down
1 change: 1 addition & 0 deletions web/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ const PDFViewerApplication = {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("TESTING")) {
Object.assign(opts, {
enableAltText: x => x === "true",
enableFakeMLManager: x => x === "true",
enableGuessAltText: x => x === "true",
enableUpdatedAddImage: x => x === "true",
highlightEditorColors: x => x,
Expand Down
2 changes: 1 addition & 1 deletion web/new_alt_text_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class NewAltTextManager {

#guessedAltText;

#hasAI = false;
#hasAI = null;

#isEditing = null;

Expand Down

0 comments on commit c90ce5d

Please sign in to comment.