40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import {
|
|
hideLongImageExportChrome,
|
|
isLongImageDownloadRequest,
|
|
LONG_IMAGE_EXPORT_SELECTORS,
|
|
LONG_IMAGE_EXPORT_STYLE,
|
|
} from './mindspace-long-image.mjs';
|
|
|
|
test('recognizes supported long-image download query values', () => {
|
|
assert.equal(isLongImageDownloadRequest({ download: 'long-image' }), true);
|
|
assert.equal(isLongImageDownloadRequest({ export: 'png' }), true);
|
|
assert.equal(isLongImageDownloadRequest({ download: 'document' }), false);
|
|
});
|
|
|
|
test('long-image capture style hides platform page actions', () => {
|
|
assert.match(LONG_IMAGE_EXPORT_STYLE, /\[data-mindspace-public-share\]/);
|
|
assert.match(LONG_IMAGE_EXPORT_STYLE, /\[data-mindspace-public-share-dialog\]/);
|
|
assert.match(LONG_IMAGE_EXPORT_STYLE, /\.publication-share-fab/);
|
|
assert.match(LONG_IMAGE_EXPORT_STYLE, /\.publication-share-sheet/);
|
|
assert.match(LONG_IMAGE_EXPORT_STYLE, /display:\s*none\s*!important/);
|
|
assert.ok(LONG_IMAGE_EXPORT_SELECTORS.includes('[data-mindspace-public-share]'));
|
|
});
|
|
|
|
test('long-image capture actively hides injected platform chrome before screenshot', async () => {
|
|
const calls = [];
|
|
const page = {
|
|
async addStyleTag(options) {
|
|
calls.push(['style', options.content]);
|
|
},
|
|
async evaluate(_fn, selectors) {
|
|
calls.push(['evaluate', selectors]);
|
|
},
|
|
};
|
|
await hideLongImageExportChrome(page);
|
|
assert.deepEqual(calls[0][0], 'style');
|
|
assert.match(calls[0][1], /\[data-mindspace-public-share\]/);
|
|
assert.deepEqual(calls[1], ['evaluate', LONG_IMAGE_EXPORT_SELECTORS]);
|
|
});
|