forked from Maps4HTML/MapML.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetaDefault.test.js
More file actions
117 lines (111 loc) · 3.67 KB
/
metaDefault.test.js
File metadata and controls
117 lines (111 loc) · 3.67 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
import { test, expect, chromium } from '@playwright/test';
let expectedPCRSFirstLayer = {
topLeft: {
horizontal: -3263369.215138428,
vertical: 4046262.80585894
},
bottomRight: {
horizontal: 3823752.959105924,
vertical: -1554448.395563461
}
},
expectedGCRSFirstLayer = {
topLeft: {
horizontal: -125.78104358919225,
vertical: 56.11474703973131
},
bottomRight: {
horizontal: -5.116088318047697,
vertical: 28.87016583287855
}
};
let expectedPCRSSecondLayer = {
topLeft: {
horizontal: -7786477,
vertical: 7928344
},
bottomRight: {
horizontal: 7148753,
vertical: -927808
}
},
expectedGCRSSecondLayer = {
topLeft: {
horizontal: -155.3514099767017,
vertical: 22.2852694215843
},
bottomRight: {
horizontal: 32.23057852696884,
vertical: 10.170068283825733
}
};
test.describe('Playwright Missing Min Max Attribute, Meta Default Tests', () => {
let page;
let context;
test.beforeAll(async () => {
context = await chromium.launchPersistentContext('');
page =
context.pages().find((page) => page.url() === 'about:blank') ||
(await context.newPage());
await page.goto('metaDefault.html');
});
test.afterAll(async function () {
await context.close();
});
test('Inline layer extent test', async () => {
const extent = await page.$eval(
'body > mapml-viewer > layer-:nth-child(1)',
(layer) => layer.extent
);
expect(extent.hasOwnProperty('zoom')).toBeTruthy();
expect(extent.hasOwnProperty('topLeft')).toBeTruthy();
expect(extent.hasOwnProperty('bottomRight')).toBeTruthy();
expect(extent.hasOwnProperty('projection')).toBeTruthy();
expect(extent.topLeft.pcrs).toEqual(expectedPCRSFirstLayer.topLeft);
expect(extent.bottomRight.pcrs).toEqual(expectedPCRSFirstLayer.bottomRight);
expect(extent.topLeft.gcrs).toEqual(expectedGCRSFirstLayer.topLeft);
expect(extent.bottomRight.gcrs).toEqual(expectedGCRSFirstLayer.bottomRight);
});
test('Fetched layer extent test', async () => {
const extent = await page.$eval(
'body > mapml-viewer > layer-:nth-child(2)',
(layer) => layer.extent
);
expect(extent.hasOwnProperty('zoom')).toBeTruthy();
expect(extent.hasOwnProperty('topLeft')).toBeTruthy();
expect(extent.hasOwnProperty('bottomRight')).toBeTruthy();
expect(extent.hasOwnProperty('projection')).toBeTruthy();
expect(extent.topLeft.pcrs).toEqual(expectedPCRSSecondLayer.topLeft);
expect(extent.bottomRight.pcrs).toEqual(
expectedPCRSSecondLayer.bottomRight
);
expect(extent.topLeft.gcrs).toEqual(expectedGCRSSecondLayer.topLeft);
expect(extent.bottomRight.gcrs).toEqual(
expectedGCRSSecondLayer.bottomRight
);
});
test("Layer with no map-meta's is rendered on map", async () => {
let vector = await page.locator('.mapml-vector-container > svg');
await expect(vector).toHaveCount(1);
});
test('cs defaults / falls back to gcrs; priority is cs attribute, then map-meta, then fallback (gcrs)', async () => {
await page.click('body');
await page.keyboard.press('Tab');
await page.keyboard.press('Tab');
const f1 = await page.evaluate(
() =>
document.activeElement.shadowRoot.activeElement._feature.querySelector(
'map-coordinates'
).textContent
);
expect(f1).toBe('1515460 -157975');
await page.keyboard.press('ArrowRight');
const f2 = await page.evaluate(
() =>
document.activeElement.shadowRoot.activeElement._feature.querySelector(
'map-coordinates'
).textContent
);
expect(f2).toBe('-79.477626 43.764814');
});
});