aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cypress/cypress/fixtures/trees.json35
-rw-r--r--.cypress/cypress/fixtures/trees_none.json11
-rw-r--r--.cypress/cypress/integration/northamptonshire.js85
-rw-r--r--t/Mock/MapIt.pm1
4 files changed, 132 insertions, 0 deletions
diff --git a/.cypress/cypress/fixtures/trees.json b/.cypress/cypress/fixtures/trees.json
new file mode 100644
index 000000000..c965614f7
--- /dev/null
+++ b/.cypress/cypress/fixtures/trees.json
@@ -0,0 +1,35 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "id": "307.9404949",
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ 99073,
+ 6843328
+ ]
+ },
+ "properties": {
+ "layerStyleId": 1387,
+ "itemId": 9656014,
+ "sourceTypeId": 1000651,
+ "title": "CAVAT-157380",
+ "color": "#911c43"
+ },
+ "crs": {
+ "properties": {
+ "name": "EPSG:900913"
+ },
+ "type": "name"
+ }
+ }
+ ],
+ "crs": {
+ "properties": {
+ "name": "EPSG:900913"
+ },
+ "type": "name"
+ }
+}
diff --git a/.cypress/cypress/fixtures/trees_none.json b/.cypress/cypress/fixtures/trees_none.json
new file mode 100644
index 000000000..3102a72dd
--- /dev/null
+++ b/.cypress/cypress/fixtures/trees_none.json
@@ -0,0 +1,11 @@
+{
+ "type": "FeatureCollection",
+ "features": [
+ ],
+ "crs": {
+ "properties": {
+ "name": "EPSG:900913"
+ },
+ "type": "name"
+ }
+}
diff --git a/.cypress/cypress/integration/northamptonshire.js b/.cypress/cypress/integration/northamptonshire.js
new file mode 100644
index 000000000..c4e6da85f
--- /dev/null
+++ b/.cypress/cypress/integration/northamptonshire.js
@@ -0,0 +1,85 @@
+/*
+ * These don't run by default, need to run the tests with
+ * ./bin/browser-tests run --cobrand northamptonshire --area_id 2234 --coords '52.236251,0.892052'
+ *
+ * NB: most of the non northamptonshire tests will then fail
+ */
+
+var cobrand = Cypress.env('cobrand');
+var only_or_skip = (cobrand == 'northamptonshire') ? describe.only : describe.skip;
+
+only_or_skip('Northamptonshire cobrand specific testing', function() {
+
+ it('loads the right front page', function() {
+ cy.visit('/');
+ cy.contains('Northamptonshire');
+ });
+
+ it('prevents clicking unless asset selected', function() {
+ cy.server();
+ cy.fixture('trees.json');
+ cy.fixture('trees_none.json');
+ cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer');
+ cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer');
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.visit('/');
+ cy.get('[name=pc]').type('NN1 1NS');
+ cy.get('[name=pc]').parents('form').submit();
+
+ cy.get('#map_box').click();
+
+ cy.get('[id=category_group]').select('Fallen Tree');
+
+ cy.wait('@report-ajax');
+ cy.wait('@trees-layer');
+ cy.wait('@empty-trees-layer');
+ cy.contains(/Please select a.*tree.*from the map/);
+ cy.get('#js-councils_text').should('be.hidden');
+ });
+
+ it('selecting an asset allows a report', function() {
+ cy.server();
+ cy.fixture('trees.json');
+ cy.fixture('trees_none.json');
+ cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer');
+ cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer');
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.visit('/');
+ cy.get('[name=pc]').type('NN1 2NS');
+ cy.get('[name=pc]').parents('form').submit();
+
+ cy.get('#map_box').click();
+
+ cy.get('[id=category_group]').select('Fallen Tree');
+
+ cy.wait('@trees-layer');
+ cy.wait('@empty-trees-layer');
+ cy.wait('@report-ajax');
+
+ cy.get('#js-councils_text').should('be.visible');
+ });
+
+ it('detects multiple assets at same location', function() {
+ cy.server();
+ cy.fixture('trees.json');
+ cy.fixture('trees_none.json');
+ cy.route('**/render-layer/**', 'fixture:trees_none.json').as('empty-trees-layer');
+ cy.route('**/16463/10787**', 'fixture:trees.json').as('trees-layer');
+ cy.route('**/16463/10788**', 'fixture:trees.json').as('trees-layer2');
+ cy.route('/report/new/ajax*').as('report-ajax');
+ cy.visit('/');
+ cy.get('[name=pc]').type('NN1 2NS');
+ cy.get('[name=pc]').parents('form').submit();
+
+ cy.get('#map_box').click();
+
+ cy.get('[id=category_group]').select('Fallen Tree');
+
+ cy.wait('@trees-layer');
+ cy.wait('@trees-layer2');
+ cy.wait('@empty-trees-layer');
+ cy.wait('@report-ajax');
+
+ cy.contains('more than one tree at this location');
+ });
+});
diff --git a/t/Mock/MapIt.pm b/t/Mock/MapIt.pm
index cc2a95ef6..7429d9731 100644
--- a/t/Mock/MapIt.pm
+++ b/t/Mock/MapIt.pm
@@ -38,6 +38,7 @@ my @PLACES = (
[ 'BR1 3UH', 51.4021, 0.01578, 2482, 'Bromley Council', 'LBO' ],
[ 'BR1 3UH', 51.402096, 0.015784, 2482, 'Bromley Council', 'LBO' ],
[ 'NN1 1NS', 52.236251, 0.892052, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
+ [ 'NN1 2NS', 52.238301, 0.889992, 2234, 'Northamptonshire County Council', 'CTY', 2397, 'Northampton Borough Council', 'DIS' ],
[ '?', 50.78301, -0.646929 ],
[ 'TA1 1QP', 51.023569, -3.099055, 2239, 'Somerset County Council', 'CTY', 2429, 'Taunton Deane Borough Council', 'DIS' ],
[ 'GU51 4AE', 51.279456, -0.846216, 2333, 'Hart District Council', 'DIS', 2227, 'Hampshire County Council', 'CTY' ],