Skip to content

Commit

Permalink
Only serve one non-empty tile in Cypress tests
Browse files Browse the repository at this point in the history
  • Loading branch information
steinbro committed Nov 29, 2024
1 parent 4678bf4 commit 0833636
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
6 changes: 5 additions & 1 deletion cypress/e2e/1-basic/fixed.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ describe('Fixed-location view', () => {
cy.visit('http://localhost:8080/soundscape-web-client/#/fixed/38.897600/-77.006156')
cy.mockSpeechSynthesis();

// Return static tile data for all network calls
// Return empty data for all but one tile
cy.intercept('GET', /\/tiles\/.*/, {
body: {},
}).as('other-tiles');

cy.intercept('GET', '/tiles/16/18749/25070.json', {
fixture: 'tiles_16_18749_25070.json'
}).as('tile');
})
Expand Down
8 changes: 6 additions & 2 deletions cypress/e2e/1-basic/gpx.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ describe('GPX view', () => {
cy.visit('http://localhost:8080/soundscape-web-client/#/gpx')
cy.mockSpeechSynthesis();

// Return static tile data for all network calls
// Return empty data for all but one tile
cy.intercept('GET', /\/tiles\/.*/, {
body: {},
}).as('other-tiles');

cy.intercept('GET', '/tiles/16/18109/23965.json', {
fixture: 'tiles_16_18109_23965.json'
}).as('tile');
})
Expand Down Expand Up @@ -62,7 +66,7 @@ describe('GPX view', () => {
const expectedTileUrl = '/tiles/16/18108/23964.json';

cy.get('#playPauseButton').click()
cy.wait('@tile').its('request.url').should('include', expectedTileUrl);
cy.wait('@other-tiles').its('request.url').should('include', expectedTileUrl);
})

it('starts speaking', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/WelcomeScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { initializeBeaconAudio } from '../state/beacon_audio';
import { useDeviceOrientation } from "../composables/compass";
import { myLocation } from '../state/location';
import { initializeAudioQueue, playSpatialSpeech } from '../state/audio';
import { loadTilesOnLocationCHange } from '../composables/tile';
import { loadTilesOnLocationChange } from '../composables/tile';
import { ref } from 'vue';
import { useRoute } from 'vue-router';
Expand Down Expand Up @@ -43,7 +43,7 @@ const removewall = () => {
initializeBeaconAudio();
// Automatically fetch tiles when location changes
loadTilesOnLocationCHange();
loadTilesOnLocationChange();
// Report to parent that we're ready
isVisible.value = false;
Expand Down
2 changes: 1 addition & 1 deletion src/composables/feature.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('nearbyFeatures', () => {

before(async () => {
// Washington Union Station
let lat = 38.897600, lon = -77.006156
let lat = 38.897600, lon = -77.006156;
await new Tile({ x: 18749, y: 25070, z: 16 }).import(tileData.features);
myLocation.setLocation(lat, lon);
nearby = await nearbyFeatures(lat, lon, radiusMeters);
Expand Down
2 changes: 1 addition & 1 deletion src/composables/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function enumerateTilesAround(
.map(coords => new Tile(coords));
}

export function loadTilesOnLocationCHange() {
export function loadTilesOnLocationChange() {
// Fetch nearby tiles when location changes
watch(myLocation, (newValue, oldValue) => {
if (newValue.latitude && newValue.longitude) {
Expand Down

0 comments on commit 0833636

Please sign in to comment.