1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Merge pull request #18779 from calixteman/bug1920515

[Editor] Don't show the ml toggle button when the ml is disabled (bug 1920515)
This commit is contained in:
calixteman 2024-09-23 22:12:25 +02:00 committed by GitHub
commit c90ce5da20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 70 additions and 1 deletions

View file

@ -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;

View file

@ -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,

View file

@ -40,7 +40,7 @@ class NewAltTextManager {
#guessedAltText;
#hasAI = false;
#hasAI = null;
#isEditing = null;