Interactive interface for browsing global, full-resolution satellite imagery
Skeleton for updated approach to classification test
Tom Carielloa402f2b9f646
diff --git a/e2e/features/classification/classification-test.spec.js b/e2e/features/classification/classification-test.spec.jsindex 4d787d235..599da8175 100644--- a/e2e/features/classification/classification-test.spec.js+++ b/e2e/features/classification/classification-test.spec.js@@ -6,13 +6,14 @@ Mac to generate the required reference images for all platforms.*/const { test, expect } = require('@playwright/test')+const UPNG = require('upng-js')let pageconst floodOnlyGrayUrl = 'http://localhost:3000/?v=-141,-32,21,66&df=true&l=MODIS_Combined_Flood_2-Day(disabled=3-0)&lg=true&t=2023-12-07-T18%3A49%3A23Z'const floodGrayAndBlueUrl = 'http://localhost:3000/?v=-139,-44,23,54&df=true&l=MODIS_Combined_Flood_2-Day(disabled=3-1)&lg=true&t=2023-12-07-T18%3A49%3A23Z'const floodAllColorsUrl = 'http://localhost:3000/?v=40,22,53,33&df=true&l=MODIS_Combined_Flood_2-Day&lg=true&t=2023-01-07-T18%3A49%3A23Z'-test.describe.configure({ mode: 'serial' })+test.describe.configure({ mode: 'serial', timeout: 60000 })test.beforeEach(async ({ browser }) => {page = await browser.newPage()@@ -22,35 +23,70 @@ test.afterEach(async () => {await page.close()})-test('Flood 2 Day only Gray', async () => {+test('Check colors in screenshot', async ({ page }) => {await page.goto(floodOnlyGrayUrl)await page.waitForLoadState('load')await page.waitForTimeout(5000)+ const screenshot = await page.screenshot()+ const colorsFound = analyzePixels(screenshot)- await expect(page).toHaveScreenshot('only-gray.png', {- fullPage: true,- threshold: 0.6- })+ // Define expected colors+ const expectedColors = ['#cccccc', '#ddeedd']++ // Check if all expected colors are found+ expect(colorsFound).toEqual(expectedColors)})-test('Flood 2 Day Gray & Blue', async () => {- await page.goto(floodGrayAndBlueUrl)- await page.waitForLoadState('load')- await page.waitForTimeout(5000)+// test('Flood 2 Day only Gray', async () => {+// await page.goto(floodOnlyGrayUrl)+// await page.waitForLoadState('load')+// await page.waitForTimeout(5000)- await expect(page).toHaveScreenshot('gray-and-blue.png', {- fullPage: true,- threshold: 0.6- })-})+// await expect(page).toHaveScreenshot('only-gray.png', {+// fullPage: true,+// threshold: 0.6+// })+// })-test('Flood 2 Day All Colors', async () => {- await page.goto(floodAllColorsUrl)- await page.waitForLoadState('load')- await page.waitForTimeout(5000)+// test('Flood 2 Day Gray & Blue', async () => {+// await page.goto(floodGrayAndBlueUrl)+// await page.waitForLoadState('load')+// await page.waitForTimeout(5000)- await expect(page).toHaveScreenshot('all-colors.png', {- fullPage: true,- threshold: 0.2- })-})+// await expect(page).toHaveScreenshot('gray-and-blue.png', {+// fullPage: true,+// threshold: 0.6+// })+// })++// test('Flood 2 Day All Colors', async () => {+// await page.goto(floodAllColorsUrl)+// await page.waitForLoadState('load')+// await page.waitForTimeout(5000)++// await expect(page).toHaveScreenshot('all-colors.png', {+// fullPage: true,+// threshold: 0.2+// })+// })++function analyzePixels (screenshot) {+ const imageData = decodeImageData(screenshot)+ const expectedColors = ['#cccccc', '#ddeedd']++ const colorsFound = new Set()+ for (let i = 0; i < imageData.length; i += 4) {+ const color = `#${('000000' + ((imageData[i] << 16) | (imageData[i + 1] << 8) | imageData[i + 2]).toString(16)).slice(-6)}`+ if (expectedColors.includes(color)) {+ colorsFound.add(color)+ }+ }++ return Array.from(colorsFound)+}++function decodeImageData (screenshot) {+ const decodedImage = UPNG.decode(screenshot)+ const rgbaData = UPNG.toRGBA8(decodedImage)[0]+ return rgbaData+}