Skip to content

Commit

Permalink
Update win32 images for pmtiles tests
Browse files Browse the repository at this point in the history
Prettier formatting of templatedPMTilesMVTLayer.test.js
  • Loading branch information
prushforth committed Aug 27, 2024
1 parent b94b09a commit e23dbba
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 21 deletions.
62 changes: 41 additions & 21 deletions test/e2e/layers/templatedPMTilesMVTLayer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ test.describe('Playwright templatedPMTilesLayer Tests', () => {
maxDiffPixels: 1500
});
});
test('pmtilesStyles.js module not found console errors', async ({
page
}) => {
test('pmtilesStyles.js module not found console errors', async ({ page }) => {
const messages = [];
page.on('console', async (msg) => {
for (const arg of msg.args()) messages.push(await arg.jsonValue());
Expand Down Expand Up @@ -98,43 +96,51 @@ test.describe('Playwright templatedPMTilesLayer Tests', () => {
await expect(flexProjectionLayer).not.toHaveAttribute('disabled');
await expect(fixedProjectionLayer).not.toHaveAttribute('disabled');
});
test('A protomaps map-link, parent map-extent and ancestor layer- are disabled when out of bounds', async ({ page }) => {
test('A protomaps map-link, parent map-extent and ancestor layer- are disabled when out of bounds', async ({
page
}) => {
await page.goto('templatedPMTilesMVTLayer.html');
await page.waitForTimeout(1000);
const viewer = page.getByTestId('viewer');
const lightLayer = page.getByTestId('light');
const darkLayer = page.getByTestId('dark');
await lightLayer.evaluate(l => l.removeAttribute('checked'));
await darkLayer.evaluate(l => {l.checked = 'checked';l.zoomTo();});
await lightLayer.evaluate((l) => l.removeAttribute('checked'));
await darkLayer.evaluate((l) => {
l.checked = 'checked';
l.zoomTo();
});
// at this point, the dark layer should be enabled
await expect(darkLayer).not.toHaveAttribute('disabled');
// move horizontally 2x the width of the extent, should make it not visible / disabled
await darkLayer.evaluate(l => {
let w = l.extent.bottomRight.gcrs.horizontal - l.extent.topLeft.gcrs.horizontal;
let h = l.extent.topLeft.gcrs.vertical - l.extent.bottomRight.gcrs.vertical;
let cLat = l.extent.bottomRight.gcrs.vertical + ( h / 2);
let cLon = l.extent.topLeft.gcrs.horizontal + (w / 2);
await darkLayer.evaluate((l) => {
let w =
l.extent.bottomRight.gcrs.horizontal - l.extent.topLeft.gcrs.horizontal;
let h =
l.extent.topLeft.gcrs.vertical - l.extent.bottomRight.gcrs.vertical;
let cLat = l.extent.bottomRight.gcrs.vertical + h / 2;
let cLon = l.extent.topLeft.gcrs.horizontal + w / 2;
let z = l.parentElement.zoom;
l.parentElement.zoomTo(cLat, (cLon + w * 2), z);
l.parentElement.zoomTo(cLat, cLon + w * 2, z);
});
await page.waitForTimeout(500);
// at this point, the dark layer should be disabled
await expect(darkLayer).toHaveAttribute('disabled');

});
test('A protomaps mvt map-link that has {z},{x},{y} variable names without associated map-inputs will not render', async ({ page }) => {
test('A protomaps mvt map-link that has {z},{x},{y} variable names without associated map-inputs will not render', async ({
page
}) => {
const messages = [];
page.on('console', async (msg) => {
for (const arg of msg.args()) messages.push(await arg.jsonValue());
});
await page.goto('templatedPMTilesMVTLayer.html');
const viewer = page.getByTestId('viewer');
const lightLayer = page.getByTestId('light');
await lightLayer.evaluate(l => l.removeAttribute('checked'));
await lightLayer.evaluate((l) => l.removeAttribute('checked'));
const darkLayer = page.getByTestId('dark');
await darkLayer.evaluate(l => l.removeAttribute('checked'));
await darkLayer.evaluate((l) => l.removeAttribute('checked'));
const hardCodedVariablesLayer = page.getByTestId('hard-coded-variables');
await hardCodedVariablesLayer.evaluate(l => l.checked = true);
await hardCodedVariablesLayer.evaluate((l) => (l.checked = true));
await page.waitForTimeout(1000);
await expect(viewer).toHaveScreenshot('mvt-blank.png', {
maxDiffPixels: 1500
Expand All @@ -153,10 +159,24 @@ test.describe('Playwright templatedPMTilesLayer Tests', () => {
)
)
errorFindingRules = true;
if (m.startsWith('input with name=z not found for template variable of same name')) errorNoZoomInput = true;
if (m.startsWith('input with name=x not found for template variable of same name')) errorNoXInput = true;
if (m.startsWith('input with name=y not found for template variable of same name')) errorNoYInput = true;

if (
m.startsWith(
'input with name=z not found for template variable of same name'
)
)
errorNoZoomInput = true;
if (
m.startsWith(
'input with name=x not found for template variable of same name'
)
)
errorNoXInput = true;
if (
m.startsWith(
'input with name=y not found for template variable of same name'
)
)
errorNoYInput = true;
}
// lack of rendering wasn't due to lack of styles
expect(errorLoadingModule).toBe(false);
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e23dbba

Please sign in to comment.