-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathlive-compat.spec.js
More file actions
282 lines (262 loc) · 9.49 KB
/
Copy pathlive-compat.spec.js
File metadata and controls
282 lines (262 loc) · 9.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
const { expect, test } = require("@playwright/test");
const targets = [
{
name: "Arts & Culture",
expectedDezoomer: "Arts & Culture",
url: "https://artsandculture.google.com/asset/liza-kottou-0113/3gGrYhjfhcwvbA",
},
{
name: "National Gallery",
expectedDezoomer: "IIIF",
url: "https://www.nationalgallery.org.uk/paintings/alexandre-calame-at-handeck",
},
{
name: "Memoire des hommes",
expectedDezoomer: "IIIF",
url: "https://www.memoiredeshommes.defense.gouv.fr/_recherche-images/show/112145/image/56545/0/info.json",
},
{
name: "London Museum collections",
expectedDezoomer: "IIIF",
url: "https://www.londonmuseum.org.uk/collections/v/object-95380/a-country-fair/",
},
{
name: "Philadelphia Museum of Art",
expectedDezoomer: "IIIF",
url: "https://philamuseum.org/collection/object/101731",
},
{
name: "Liechtenstein Collections",
expectedDezoomer: "IIIF",
url: "https://www.liechtensteincollections.at/en/collections-online/forest-landscape",
},
{
name: "National Gallery of Victoria",
expectedDezoomer: "Zoomify",
url: "https://www.ngv.vic.gov.au/explore/collection/work/3867/",
},
{
name: "Czech Digital Library",
expectedDezoomer: "Zoomify",
url: "https://api.ceskadigitalniknihovna.cz/search/api/client/v7.0/items/cuni/uuid:425e338e-9420-11ec-ac48-fa163e4ea95f/image/zoomify/ImageProperties.xml",
},
{
name: "CSNTM manuscripts",
expectedDezoomer: "IIIF",
url: "https://collections.csntm.org/image-service/iiif/MNTGRCGA01/default/M_NT_GRC_GA01_20250609_203r/M_NT_GRC_GA01_20250609_203r/info.json",
},
{
name: "Austrian National Library",
expectedDezoomer: "IIIF",
url: "https://api.onb.ac.at/iiif/presentation/v3/manifest/10048A37",
},
{
name: "Memorix TopViewer",
expectedDezoomer: "TopViewer",
url: "https://images.memorix.nl/wba/topviewjson/memorix/6eb5a89b-b76c-5039-3999-aabfd7a0c7c9",
},
{
name: "Oklahoma State Digital Collections",
expectedDezoomer: "IIIF",
url: "https://dc.library.okstate.edu/digital/collection/OKMaps/id/6483/rec/6",
},
{
name: "University of Washington Mirador",
expectedDezoomer: "IIIF",
url: "https://digitalcollections.lib.washington.edu/digital/custom/mirador3?manifest=https://digitalcollections.lib.washington.edu//iiif/info/social/1303/manifest.json",
},
{
name: "krpano",
expectedDezoomer: "krpano",
url: "https://krpano.com/panos/andreabiffi/galleria_04.xml",
},
{
name: "Bibliotheques specialisees de Paris",
expectedDezoomer: "Seadragon (Deep Zoom Image)",
url: "https://bibliotheques-specialisees.paris.fr/ark:/73873/pf0001115743/0017/v0001.simple.selectedTab=otherdocs",
},
{
name: "Art Institute of Chicago Sargent archive",
expectedDezoomer: "Seadragon (Deep Zoom Image)",
url: "https://archive.artic.edu/sargent/",
},
{
name: "Academia Sinica Bronze Rubbings",
expectedDezoomer: "Seadragon (Deep Zoom Image)",
url: "https://bronze.asdc.sinica.edu.tw/filePool/R/05395-1.html",
},
{
name: "FSI Viewer",
expectedDezoomer: "FSI",
url: "https://www.neptunelabs.com/fsi-viewer/",
},
{
name: "Alabama Maps LizardTech",
expectedDezoomer: "LizardTech ImageServer",
url: "http://cartweb.geography.ua.edu/lizardtech/iserv/calcrgn?cat=North%20America%20and%20United%20States&item=NorthAmerica/US1566a.sid&wid=500&hei=400&props=item(Name,Description),cat(Name,Description)&style=default/view.xsl&plugin=true",
},
{
name: "Geographicus",
expectedDezoomer: "Zoomify",
url: "https://www.geographicus.com/P/AntiqueMap/nantucket-sheminroyster-1973",
},
{
name: "OpenSeadragon Zoomify",
expectedDezoomer: "Zoomify",
url: "https://openseadragon.github.io/examples/tilesource-zoomify/",
},
{
name: "National Library of Israel",
expectedDezoomer: "IIIF",
url: "https://iiif.nli.org.il/IIIFv21/FL58252370/info.json",
},
{
name: "National Library of Scotland",
expectedDezoomer: "IIIF",
url: "https://auchinleck.nls.uk/imageserver/iipsrv.fcgi?iiif=/auchinleck/105v.jp2/info.json",
},
{
name: "National Library of Scotland map-view",
expectedDezoomer: "IIIF",
url: "https://map-view.nls.uk/iiif/19619%2F196194600/info.json",
},
{
name: "Westchester County Archives",
expectedDezoomer: "IIIF",
url: "https://collections.westchestergov.com/digital/collection/ccmaps/id/69/",
},
{
name: "pnav catalog.shm.ru",
expectedDezoomer: "pnav",
url: "https://catalog.shm.ru/entity/OBJECT/2117418",
},
{
name: "pnav collection.pushkinmuseum.art",
expectedDezoomer: "pnav",
url: "https://collection.pushkinmuseum.art/entity/OBJECT/77606",
},
{
name: "pnav collection.ethnomuseum.ru",
expectedDezoomer: "pnav",
url: "https://collection.ethnomuseum.ru/entity/OBJECT/32945",
},
];
async function openApp(page) {
await page.goto("/index.html");
await page.waitForFunction(() => {
return (
window.ZoomManager &&
window.ZoomManager.dezoomersList &&
window.ZoomManager.dezoomersList.pnav
);
});
}
async function runLiveTarget(page, target) {
const proxyUrl = `${new URL(page.url()).origin}/proxy`;
return page.evaluate(
({ proxyUrl, target }) => {
return new Promise((resolve, reject) => {
const ZoomManager = window.ZoomManager;
const timeout = setTimeout(() => {
reject(new Error(
`Timed out while running ${target.name}: ` +
JSON.stringify({
data: ZoomManager.data,
dezoomerName: ZoomManager.dezoomer && ZoomManager.dezoomer.name,
status: ZoomManager.status,
})
));
}, target.timeout || 25000);
function finish(result) {
clearTimeout(timeout);
resolve(result);
}
function fail(error) {
clearTimeout(timeout);
reject(error instanceof Error ? error : new Error(String(error)));
}
window.onerror = function (message, source, line) {
fail(new Error(`${message} (${source}:${line})`));
return true;
};
ZoomManager.setDezoomer(ZoomManager.dezoomersList["Select automatically"]);
ZoomManager.data = null;
ZoomManager.proxy_url = proxyUrl;
ZoomManager.proxy_tiles = "";
ZoomManager.cookies = "";
ZoomManager.nextTick = (fn) => setTimeout(fn, 0);
ZoomManager.error = (message) => fail(new Error(message));
ZoomManager.updateProgress = () => {};
ZoomManager.readyToRender = (data) => {
data.nbrTilesX = data.nbrTilesX || Math.ceil(data.width / data.tileSize);
data.nbrTilesY = data.nbrTilesY || Math.ceil(data.height / data.tileSize);
data.totalTiles = data.totalTiles || data.nbrTilesX * data.nbrTilesY;
data.zoomFactor = data.zoomFactor || 2;
data.baseZoomLevel = data.baseZoomLevel || 0;
data.overlap = data.overlap || 0;
ZoomManager.status.totalTiles = data.totalTiles;
ZoomManager.data = data;
const zoom = data.maxZoomLevel || ZoomManager.findMaxZoom(data);
Promise.resolve(ZoomManager.dezoomer.getTileURL(0, 0, zoom, data))
.then((tileUrl) => {
if (data.origin) tileUrl = ZoomManager.resolveRelative(tileUrl, data.origin);
const img = new Image();
img.onload = () => finish({
dezoomerName: ZoomManager.dezoomer.name,
height: data.height,
tileHeight: img.naturalHeight || img.height,
tileUrl,
tileWidth: img.naturalWidth || img.width,
totalTiles: data.totalTiles,
width: data.width,
});
img.onerror = () => fail(new Error(`Unable to load tile: ${tileUrl}`));
img.referrerPolicy = "no-referrer";
img.src = tileUrl;
})
.catch(fail);
};
ZoomManager.open(target.url);
});
},
{ proxyUrl, target }
);
}
function escapeGitHubActionsAnnotation(value) {
return String(value)
.replaceAll("%", "%25")
.replaceAll("\r", "%0D")
.replaceAll("\n", "%0A");
}
function emitLiveFailureWarning(target, error) {
if (process.env.GITHUB_ACTIONS !== "true") return;
const title = escapeGitHubActionsAnnotation(`Live compatibility failed: ${target.name}`);
const message = escapeGitHubActionsAnnotation(
"A live website changed, blocked the runner, or returned an unexpected response. " +
`URL: ${target.url}. Error: ${error.message}`
);
console.log(`::warning title=${title}::${message}`);
}
for (const target of targets) {
test(target.name, async ({ page }, testInfo) => {
test.setTimeout(target.timeout || 30000);
try {
await openApp(page);
const result = await runLiveTarget(page, target);
expect(result.dezoomerName).toBe(target.expectedDezoomer);
expect(result.width).toBeGreaterThan(0);
expect(result.height).toBeGreaterThan(0);
expect(result.totalTiles).toBeGreaterThan(0);
expect(result.tileUrl).toContain("http");
expect(result.tileWidth).toBeGreaterThan(0);
expect(result.tileHeight).toBeGreaterThan(0);
} catch (error) {
const failure = error instanceof Error ? error : new Error(String(error));
failure.message = `${failure.message}\nLive target URL: ${target.url}`;
if (testInfo.retry >= (testInfo.project.retries || 0)) {
emitLiveFailureWarning(target, failure);
}
throw failure;
}
});
}