-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into Feature/AccessibilityTable
- Loading branch information
Showing
16 changed files
with
3,572 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module.exports = { | ||
tabWidth: 4, | ||
bracketSpacing: true, | ||
singleQuote: true, | ||
trailingComma: 'all', | ||
arrowParens: 'avoid', | ||
printWidth: 100, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,81 @@ | ||
export const expectedPlaceZwierzyniecka = { | ||
title: "Zwierzyniecka", | ||
subtitle: "small bridge", | ||
categories: [ | ||
["type_of_place", "small bridge"], | ||
["accessible_by", "bikes, pedestrians"] | ||
] | ||
title: 'Zwierzyniecka', | ||
subtitle: 'small bridge', | ||
categories: [ | ||
['type_of_place', 'small bridge'], | ||
['accessible_by', 'bikes, pedestrians'], | ||
], | ||
}; | ||
|
||
// This is workaround for a problem with getting specific marker. | ||
// TODO Find a way of getting specific marker or marker in specific position | ||
export function getRightmostMarker(markers) { | ||
let rightmostMarker; | ||
let maxX = -Infinity; | ||
let rightmostMarker; | ||
let maxX = -Infinity; | ||
|
||
Cypress.$(markers).each((index, marker) => { | ||
const rect = marker.getBoundingClientRect(); | ||
if (rect.x > maxX) { | ||
maxX = rect.x; | ||
rightmostMarker = marker; | ||
} | ||
}); | ||
return rightmostMarker; | ||
Cypress.$(markers).each((index, marker) => { | ||
const rect = marker.getBoundingClientRect(); | ||
if (rect.x > maxX) { | ||
maxX = rect.x; | ||
rightmostMarker = marker; | ||
} | ||
}); | ||
return rightmostMarker; | ||
} | ||
|
||
export function verifyPopupContent(expectedContent) { | ||
cy.get('.point-title').should('have.text', expectedContent.title); | ||
cy.get('.point-title').should('have.text', expectedContent.title); | ||
|
||
cy.get('.point-subtitle').should('have.text', expectedContent.subtitle); | ||
cy.get('.point-subtitle').should('have.text', expectedContent.subtitle); | ||
|
||
expectedContent.categories.forEach(([category, value]) => { | ||
cy.contains(category).should('exist'); | ||
cy.contains(value).should('exist'); | ||
}); | ||
expectedContent.categories.forEach(([category, value]) => { | ||
cy.contains(category).should('exist'); | ||
cy.contains(value).should('exist'); | ||
}); | ||
|
||
if (expectedContent.CTA) { | ||
cy.contains(expectedContent.CTA.displayValue).should('exist'); | ||
cy.contains('button', expectedContent.CTA.displayValue).click(); | ||
cy.get('@openStub').should('have.been.calledOnceWith', | ||
expectedContent.CTA.value, '_blank'); | ||
} | ||
if (expectedContent.CTA) { | ||
cy.contains(expectedContent.CTA.displayValue).should('exist'); | ||
cy.contains('button', expectedContent.CTA.displayValue).click(); | ||
cy.get('@openStub').should('have.been.calledOnceWith', expectedContent.CTA.value, '_blank'); | ||
} | ||
} | ||
|
||
export function verifyProblemForm() { | ||
cy.contains('report a problem').should('exist').click(); | ||
cy.intercept('POST', '/api/report-location').as('reportLocation'); | ||
cy.contains('report a problem').should('exist').click(); | ||
cy.intercept('POST', '/api/report-location').as('reportLocation'); | ||
|
||
cy.get('form').should('exist').within(() => { | ||
cy.get('select').should('exist').within(() => { | ||
cy.get('option').then((options) => { | ||
const optionValues = [...options].map(option => option.textContent.trim()); | ||
expect(optionValues).to.include.members([ | ||
'--Please choose an option--', | ||
'this point is not here', | ||
"it's overloaded", | ||
"it's broken", | ||
'other', | ||
]); | ||
}); | ||
}); | ||
cy.get('form') | ||
.should('exist') | ||
.within(() => { | ||
cy.get('select') | ||
.should('exist') | ||
.within(() => { | ||
cy.get('option').then(options => { | ||
const optionValues = [...options].map(option => option.textContent.trim()); | ||
expect(optionValues).to.include.members([ | ||
'--Please choose an option--', | ||
'this point is not here', | ||
"it's overloaded", | ||
"it's broken", | ||
'other', | ||
]); | ||
}); | ||
}); | ||
|
||
cy.get('select').select('other'); | ||
cy.get('input[name="problem"]').should('exist'); | ||
cy.get('input[name="problem"]').type('Custom issue description'); | ||
cy.get('input[type="submit"]').should('exist').click(); | ||
}); | ||
cy.get('select').select('other'); | ||
cy.get('input[name="problem"]').should('exist'); | ||
cy.get('input[name="problem"]').type('Custom issue description'); | ||
cy.get('input[type="submit"]').should('exist').click(); | ||
}); | ||
|
||
cy.wait('@reportLocation').then((interception) => { | ||
expect(interception.request.body).to.have.property('id'); | ||
expect(interception.request.body).to.have.property('description'); | ||
expect(interception.request.body.description).to.equal('Custom issue description'); | ||
expect(interception.response.statusCode).to.equal(200); | ||
expect(interception.response.body.message).to.equal('Location reported'); | ||
}); | ||
cy.wait('@reportLocation').then(interception => { | ||
expect(interception.request.body).to.have.property('id'); | ||
expect(interception.request.body).to.have.property('description'); | ||
expect(interception.request.body.description).to.equal('Custom issue description'); | ||
expect(interception.response.statusCode).to.equal(200); | ||
expect(interception.response.body.message).to.equal('Location reported'); | ||
}); | ||
|
||
cy.contains('p', 'Location reported').should('exist'); | ||
cy.get('form').should('not.exist'); | ||
cy.contains('p', 'Location reported').should('exist'); | ||
cy.get('form').should('not.exist'); | ||
} |
64 changes: 64 additions & 0 deletions
64
tests/e2e_tests/cypress/e2e/basic-test/go-to-my-location-test.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Checks whether map has moved to the correct location by checking | ||
// if the specific OSM (Open Street Map) tile file was requested. | ||
// Filename (URL) format is /zoom/column/tile.png | ||
// Formulas that calculate tiles and columns can be found here: | ||
// https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Common_programming_languages | ||
function lon2column(lon, zoom) { | ||
return Math.floor(((lon + 180) / 360) * Math.pow(2, zoom)); | ||
} | ||
function lat2tile(lat, zoom) { | ||
return Math.floor( | ||
((1 - | ||
Math.log(Math.tan((lat * Math.PI) / 180) + 1 / Math.cos((lat * Math.PI) / 180)) / | ||
Math.PI) / | ||
2) * | ||
Math.pow(2, zoom), | ||
); | ||
} | ||
|
||
let mockedLon = 15.976627; | ||
let mockedLat = 51.919126; | ||
|
||
describe('Go To My Location Button', () => { | ||
beforeEach(() => { | ||
cy.visit('/', { | ||
onBeforeLoad(win) { | ||
cy.stub(win.navigator.geolocation, 'watchPosition').callsFake(success => { | ||
success({ | ||
coords: { | ||
longitude: mockedLon, | ||
latitude: mockedLat, | ||
accuracy: 100, | ||
}, | ||
}); | ||
}); | ||
}, | ||
}); | ||
}); | ||
|
||
it('should click the go-to-my-location button and move the map', () => { | ||
cy.window().then(win => { | ||
win.navigator.permissions.query = () => | ||
Promise.resolve({ | ||
state: 'granted', | ||
}); | ||
}); | ||
cy.get('.leaflet-marker-icon').click(); | ||
|
||
cy.get('.MuiButtonBase-root > [data-testid="MyLocationIcon"] > path').click(); | ||
cy.get('.MuiButtonBase-root > [data-testid="MyLocationIcon"] > path').click(); | ||
|
||
const zoomLevel = 16; | ||
const OSMColumn = lon2column(mockedLon, zoomLevel); | ||
const OSMTile = lat2tile(mockedLat, zoomLevel); | ||
|
||
const regExpURL = new RegExp( | ||
`^https://[abc]\\.tile\\.openstreetmap\\.org/${zoomLevel}/${OSMColumn}/${OSMTile}\\.png$`, | ||
); | ||
cy.intercept('GET', regExpURL).as('tileRequest'); | ||
cy.wait('@tileRequest', { timeout: 10000 }).then(interception => { | ||
expect(interception.response.statusCode).to.eq(200); | ||
expect(interception.request.url).to.include(`${OSMColumn}/${OSMTile}.png`); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
describe('Map Tests', () => { | ||
beforeEach(() => { | ||
cy.visit('/') | ||
}) | ||
beforeEach(() => { | ||
cy.visit('/'); | ||
}); | ||
|
||
it('displays filter list with two categories with 5 items', () => { | ||
cy.get('input[type="checkbox"]').should('have.length', 5) | ||
cy.get('form span').should('have.length', 2) | ||
}) | ||
it('displays filter list with two categories with 5 items', () => { | ||
cy.get('input[type="checkbox"]').should('have.length', 5); | ||
cy.get('form span').should('have.length', 2); | ||
}); | ||
|
||
it('Should not have scrollbars', () => { | ||
// Get the dimensions of the viewport and the entire page | ||
cy.window().then((win) => { | ||
const { innerWidth, innerHeight } = win; | ||
const { scrollWidth, scrollHeight } = win.document.documentElement; | ||
it('Should not have scrollbars', () => { | ||
// Get the dimensions of the viewport and the entire page | ||
cy.window().then(win => { | ||
const { innerWidth, innerHeight } = win; | ||
const { scrollWidth, scrollHeight } = win.document.documentElement; | ||
|
||
// Assert if the page width or height is less than or equal to the viewport dimensions, | ||
// indicating no scrollbars | ||
expect(scrollWidth <= innerWidth && scrollHeight <= innerHeight).to.be.true; | ||
// Assert if the page width or height is less than or equal to the viewport dimensions, | ||
// indicating no scrollbars | ||
expect(scrollWidth <= innerWidth && scrollHeight <= innerHeight).to.be.true; | ||
}); | ||
}); | ||
}); | ||
} | ||
) | ||
}); |
Oops, something went wrong.