Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
.th-wrapper {
width: 100%;
z-index: 1000;
height: 34px;
height: 32px;
flex-shrink: 0;
}

.root {
Expand Down Expand Up @@ -273,7 +274,7 @@
}
</script>
<% if (showTophat) { %>
<div id="earthdata-tophat2" class="th-wrapper" style="height: 34px; background: #000;"></div>
<div id="earthdata-tophat2" class="th-wrapper" style="background: #000;"></div>
<% } %>
<div id="root" class="root root--loading">
<div class="root__loading">
Expand Down
60 changes: 30 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@dotenvx/dotenvx": "^1.33.0",
"@edsc/eslint-config": "^0.0.9",
"@fastify/cors": "^10.0.2",
"@playwright/test": "^1.56.1",
"@playwright/test": "^1.62.1",
"@storybook/addon-essentials": "^8.6.7",
"@storybook/blocks": "^8.6.7",
"@storybook/react": "^8.6.7",
Expand Down
16 changes: 7 additions & 9 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@ export default defineConfig({
baseURL: 'http://localhost:8080',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

viewport: {
width: 1400,
height: 900
}
trace: 'on-first-retry'
},

// Set maxFailures to 5 on CI to avoid running the entire test suite if there are many failures.
Expand All @@ -52,7 +47,8 @@ export default defineConfig({
viewport: {
width: 1400,
height: 900
}
},
deviceScaleFactor: 2
}
},

Expand All @@ -63,7 +59,8 @@ export default defineConfig({
viewport: {
width: 1400,
height: 900
}
},
deviceScaleFactor: 2
}
},

Expand All @@ -74,7 +71,8 @@ export default defineConfig({
viewport: {
width: 1400,
height: 900
}
},
deviceScaleFactor: 2
}
}

Expand Down
8 changes: 7 additions & 1 deletion static/src/js/util/map/drawShapefile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ const drawShapefile = ({
onUpdateShapefile({ selectedFeatures: [edscId] })
}

let projectionChanged = false

// If the map should be moved and onChangeProjection is defined, determine of we need to
// change the map projection
if (shapefileAdded && onChangeProjection) {
Expand Down Expand Up @@ -263,6 +265,7 @@ const drawShapefile = ({
// If there is a new projection, update the map projection
if (newProjection) {
onChangeProjection(newProjection)
projectionChanged = true
}
}

Expand All @@ -271,12 +274,15 @@ const drawShapefile = ({
// Create the metrics event
metricsMap('Added Shapefile')

// When the projection changes we need to wait longer to ensure the map is ready to be moved to the shapefile.
const timeoutValue = projectionChanged ? 200 : 0

// SetTimeout is needed here because the map needs to be rendered before the map can be moved
setTimeout(() => {
eventEmitter.emit(mapEventTypes.MOVEMAP, {
source: vectorSource
})
}, 0)
}, timeoutValue)
}

// If the spatial polygon warning is enabled, add an MBR around the shape
Expand Down
90 changes: 90 additions & 0 deletions static/src/js/zustand/slices/__tests__/createGranulesSlice.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,5 +188,95 @@ describe('createGranulesSlice', () => {
title: 'Something went wrong fetching granule search results'
}))
})

describe('when the collectionId matches the granules collectionConceptId', () => {
describe('when the collection is not OpenSearch', () => {
test('does not fetch granules', async () => {
// This test will fail if a network request is attempted.

useEdscStore.setState((state) => {
state.collection.collectionId = 'collectionId'
state.granules.granules.collectionConceptId = 'collectionId'
state.errors.handleError = vi.fn()
})

const { granules } = useEdscStore.getState()
await granules.getGranules()

const { errors } = useEdscStore.getState()
expect(errors.handleError).toHaveBeenCalledTimes(0)
})
})

describe('when the collection is OpenSearch', () => {
test('fetches granules', async () => {
nock(/localhost/)
.post(/opensearch\/granules/)
.reply(200, `<feed>
<totalResults>1</totalResults>
<entry>
<mockGranuleData>goes here</mockGranuleData>
</entry>
</feed>`)

useEdscStore.setState((state) => {
state.collection.collectionId = 'collectionId'
state.collection.collectionMetadata = {
collectionId: {
links: [{
rel: '/search#',
href: 'https://example.com/opensearch'
}]
}
}

state.granules.granules.collectionConceptId = 'collectionId'
state.errors.handleError = vi.fn()
})

const { granules } = useEdscStore.getState()
await granules.getGranules()

const { errors } = useEdscStore.getState()
expect(errors.handleError).toHaveBeenCalledTimes(0)

const {
granules: updatedGranules
} = useEdscStore.getState()

expect(updatedGranules.granules).toEqual({
collectionConceptId: 'collectionId',
count: 1,
isLoaded: true,
isLoading: false,
items: [{
browseFlag: false,
collectionConceptId: 'collectionId',
isOpenSearch: true,
mockGranuleData: 'goes here',
spatial: null
}],
loadTime: expect.any(Number)
})
})
})
})

describe('when collectionId is not set', () => {
test('does not fetch granules', async () => {
// This test will fail if a network request is attempted.

useEdscStore.setState((state) => {
state.collection.collectionId = null
state.errors.handleError = vi.fn()
})

const { granules } = useEdscStore.getState()
await granules.getGranules()

const { errors } = useEdscStore.getState()
expect(errors.handleError).toHaveBeenCalledTimes(0)
})
})
})
})
5 changes: 3 additions & 2 deletions static/src/js/zustand/slices/createGranulesSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ const createGranulesSlice: ImmerStateCreator<GranulesSlice> = (set, get) => ({
// endpoints. This `if` ensures we don't double fetch CMR granules.
// TODO This is causing a double fetch for OpenSearch granules (both to the same OpenSearch endpoint)
// TODO when loaded from the search results. The first request gets cancelled, but it would be nice to avoid that
// When this double fetch is happening, it is possible the user has already moved to a new page and the `collectionId` no longer exists. When this happens we also need to return with no action.
if (
collectionId === zustandState.granules.granules.collectionConceptId
&& !isOpenSearch
!collectionId

@eudoroolivares2016 eudoroolivares2016 Aug 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put this catch further up if (!collectionId) return on something like line 49? if the coll is empty do we need to execute anything else on this slice instead bail?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had it further up but I was looking at what was triggering it, and the bug is because of the opensearch double trigger mentioned in the comments. So I moved it into this if statement. I meant to add details to that comment, I'll do that now

|| (collectionId === zustandState.granules.granules.collectionConceptId && !isOpenSearch)
) {
return
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/e2e/map/map_controls.spec.js-snapshots/webkit/geographic.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/e2e/map/map_controls.spec.js-snapshots/webkit/rotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/chromium/line.png
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/firefox/line.png
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/firefox/point.png
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/webkit/arctic.png
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/webkit/circle.png
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/webkit/line.png
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/webkit/point.png
Binary file modified tests/e2e/map/map_shapefile.spec.js-snapshots/webkit/polygon.png
Binary file modified tests/e2e/paths/search/search.spec.js-snapshots/firefox/box.png
Binary file modified tests/e2e/paths/search/search.spec.js-snapshots/webkit/box.png
Binary file modified tests/e2e/paths/search/search.spec.js-snapshots/webkit/circle.png
Binary file modified tests/e2e/paths/search/search.spec.js-snapshots/webkit/point.png
Binary file modified tests/e2e/paths/search/search.spec.js-snapshots/webkit/polygon.png
1 change: 1 addition & 0 deletions tests/support/setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const setupTests = async ({
await page.route('**googletagmanager**', (route) => route.abort())
await page.route('**google-analytics**', (route) => route.abort())
await page.route('**digitalgov**', (route) => route.abort())
await page.route('**tophat**', (route) => route.abort())

await page.route('**/arcgis/**', async (route) => {
await handleImage(route, page)
Expand Down
Loading