"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const react_1 = __importDefault(require("react"));
const experimental_ct_react_1 = require("@playwright/experimental-ct-react");
const MultiLineAnswer_story_1 = require("../stories/results/MultiLineAnswer.story");
const textAnnotationScore = {
    questionId: 1,
    answerId: 1,
    pregrading: {
        score: 1,
        annotations: [{ type: 'text', startIndex: 6, length: 5, message: 'Text annotation' }]
    }
};
experimental_ct_react_1.test.describe('<MultiLineAnswer /> image opening', () => {
    (0, experimental_ct_react_1.test)('adds a full size image link for downscaled images', async ({ mount }) => {
        const component = await mount(react_1.default.createElement(MultiLineAnswer_story_1.MultiLineAnswerStory, { imageWidth: 1600 }));
        const src = await component.locator('img').evaluate((img) => img.src);
        await (0, experimental_ct_react_1.expect)(component.locator('.full-size-image a')).toHaveAttribute('target', '_blank');
        await (0, experimental_ct_react_1.expect)(component.locator('.full-size-image a')).toHaveAttribute('href', src);
    });
    (0, experimental_ct_react_1.test)('does not add a full size image link for images rendered at natural size', async ({ mount }) => {
        const component = await mount(react_1.default.createElement(MultiLineAnswer_story_1.MultiLineAnswerStory, { imageWidth: 400 }));
        // we need to wait for the image to load, otherwise the assertion would be immediately true
        await waitForImageLoad(component.locator('img'));
        await (0, experimental_ct_react_1.expect)(component.locator('.full-size-image')).toHaveCount(0);
    });
    (0, experimental_ct_react_1.test)('keeps annotation marks out of the full size image wrapper', async ({ mount }) => {
        const component = await mount(react_1.default.createElement(MultiLineAnswer_story_1.MultiLineAnswerStory, { imageWidth: 1600, score: textAnnotationScore }));
        await (0, experimental_ct_react_1.expect)(component.locator('.full-size-image a')).toHaveCount(1);
        await (0, experimental_ct_react_1.expect)(component.locator('.full-size-image mark')).toHaveCount(0);
        await (0, experimental_ct_react_1.expect)(component.locator('mark')).toContainText('World');
    });
});
async function waitForImageLoad(image) {
    await image.evaluate((img) => {
        if (img.complete) {
            return;
        }
        return new Promise(resolve => img.addEventListener('load', () => resolve(), { once: true }));
    });
}
//# sourceMappingURL=MultiLineAnswer.test.js.map