Skip to content

Commit

Permalink
Merge branch 'FD-4929-sutton-garden-sacks-image' into commercial-staging
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismytton committed Dec 20, 2024
2 parents 5fc7b6e + 0c56061 commit 28af28c
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 74 deletions.
150 changes: 79 additions & 71 deletions .cypress/cypress/integration/bromley.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,87 +9,95 @@ describe('Bromley cobrand', function() {
cy.route('**mapserver/bromley*Parks_Open_Spaces*', 'fixture:bromley-parks.xml').as('parks');
cy.route('/report/new/ajax*').as('report-ajax');
cy.viewport(480, 800);
cy.visit('http://bromley.localhost:3001/report/new?latitude=51.4021&longitude=0.01578');
cy.contains('Bromley');
cy.wait('@prow');
cy.wait('@crystal');
cy.wait('@sport_centre');
cy.wait('@report-ajax');
cy.get('#mob_ok').click();
});

it('fills the right of way field', function() {
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.get('#form_prow_reference').should('have.value', 'FP111');
});
describe('category asset tests', function() {
beforeEach(function() {
cy.visit('http://bromley.localhost:3001/report/new?latitude=51.4021&longitude=0.01578');
cy.contains('Bromley');
cy.wait('@report-ajax');
cy.get('#mob_ok').click();
});

it('does not display asset based upon extra question', function() {
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Sign Light Not Working');
// https://stackoverflow.com/questions/47295287/cypress-io-assert-no-xhr-requests-to-url
cy.on('fail', function(err) {
expect(err.message).to.include('No request ever occurred.');
return false;
it('fills the right of way field', function() {
cy.wait('@prow');
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.get('#form_prow_reference').should('have.value', 'FP111');
});
cy.wait('@lights', { timeout: 0 }).then(function(xhr) { throw new Error('Unexpected API call.'); });
});

it('displays assets based upon extra question', function() {
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.wait('@lights');
cy.nextPageReporting();
cy.get('.mobile-map-banner').should('be.visible');
});
it('does not display asset based upon extra question', function() {
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Sign Light Not Working');
// https://stackoverflow.com/questions/47295287/cypress-io-assert-no-xhr-requests-to-url
cy.on('fail', function(err) {
expect(err.message).to.include('No request ever occurred.');
return false;
});
cy.wait('@lights', { timeout: 0 }).then(function(xhr) { throw new Error('Unexpected API call.'); });
});

it('sets extra cobrand owner field when streetlight asset selected', function() {
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.wait('@lights');
cy.nextPageReporting();
cy.get('.mobile-map-banner').should('be.visible');
cy.get('#form_fms_layer_owner').should('have.value', '');
cy.visit('http://bromley.localhost:3001/report/new?longitude=0.022775&latitude=51.398387');
cy.wait('@report-ajax');
cy.get('#mob_ok').click();
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.wait('@lights');
cy.get('#form_fms_layer_owner').should('have.value', 'bromley');
});
it('displays assets based upon extra question', function() {
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.wait('@lights');
cy.nextPageReporting();
cy.get('.mobile-map-banner').should('be.visible');
});

it('adds stopper for Crystal Palace Park', function() {
cy.visit('http://bromley.localhost:3001/report/new?longitude=-0.064555&latitude=51.422382');
cy.contains('transferred to the Crystal Palace Park Trust');
cy.get('#mob_ok').should('not.be.visible');
it('sets extra cobrand owner field when streetlight asset selected', function() {
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.wait('@lights');
cy.nextPageReporting();
cy.get('.mobile-map-banner').should('be.visible');
cy.get('#form_fms_layer_owner').should('have.value', '');
cy.visit('http://bromley.localhost:3001/report/new?longitude=0.022775&latitude=51.398387');
cy.wait('@report-ajax');
cy.get('#mob_ok').click();
cy.pickCategory('Street Lighting and Road Signs');
cy.nextPageReporting();
cy.pickSubcategory('Street Lighting and Road Signs', 'Lamp Column Damaged');
cy.wait('@lights');
cy.get('#form_fms_layer_owner').should('have.value', 'bromley');
});
});

it('adds stopper for National Sports Centre', function() {
cy.visit('http://bromley.localhost:3001/report/new?longitude=-0.071410&latitude=51.419275');
cy.contains('responsibility of the National Sports Centre');
cy.get('#mob_ok').should('not.be.visible');
});
describe('location asset tests', function() {
it('adds stopper for Crystal Palace Park', function() {
cy.visit('http://bromley.localhost:3001/report/new?longitude=-0.064555&latitude=51.422382');
cy.wait('@crystal');
cy.contains('transferred to the Crystal Palace Park Trust');
cy.get('#mob_ok').should('not.be.visible');
});

it('adds post category message for Street categories within a park', function() {
cy.visit('http://bromley.localhost:3001/report/new?longitude=0.007803&latitude=51.403986');
cy.get('#mob_ok').click();
cy.pickCategory('Street Cleansing');
cy.wait('@parks');
cy.contains('We’ve noticed that you’ve selected a Streets category but that your map pin is located within a park').should('be.visible');
});
it('adds stopper for National Sports Centre', function() {
cy.visit('http://bromley.localhost:3001/report/new?longitude=-0.071410&latitude=51.419275');
cy.wait('@sport_centre');
cy.contains('responsibility of the National Sports Centre');
cy.get('#mob_ok').should('not.be.visible');
});

it('adds post category message for Park and Greenspace categories not in a park', function() {
cy.visit('http://bromley.localhost:3001/report/new?latitude=51.4021&longitude=0.01578');
cy.get('#mob_ok').click();
cy.pickCategory('Parks and Greenspace');
cy.wait('@parks');
cy.contains('We’ve noticed that you’ve selected a Parks and Greenspace category but that your map pin isn’t located within a park').should('be.visible');
});
it('adds post category message for Street categories within a park', function() {
cy.visit('http://bromley.localhost:3001/report/new?longitude=0.007803&latitude=51.403986');
cy.wait('@report-ajax');
cy.get('#mob_ok').click();
cy.pickCategory('Street Cleansing');
cy.wait('@parks');
cy.contains('We’ve noticed that you’ve selected a Streets category but that your map pin is located within a park').should('be.visible');
});

it('adds post category message for Park and Greenspace categories not in a park', function() {
cy.visit('http://bromley.localhost:3001/report/new?latitude=51.4021&longitude=0.01578');
cy.wait('@report-ajax');
cy.get('#mob_ok').click();
cy.pickCategory('Parks and Greenspace');
cy.wait('@parks');
cy.contains('We’ve noticed that you’ve selected a Parks and Greenspace category but that your map pin isn’t located within a park').should('be.visible');
});
});
});
1 change: 1 addition & 0 deletions perllib/FixMyStreet/Cobrand/Sutton.pm
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ sub image_for_unit {
my $base = '/i/waste-containers';
if (my $container = $unit->{garden_container}) {
return svg_container_bin("wheelie", '#41B28A', '#8B5E3D') if $container == 26 || $container == 27;
return svg_container_sack('normal', '#F5F5DC') if $container == 28; # Garden waste sack
return "";
}
if (my $container = $unit->{request_containers}[0]) {
Expand Down
28 changes: 28 additions & 0 deletions t/app/controller/waste_sutton_garden.t
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,34 @@ subtest "check signature generation" => sub {
is $sha, "06BB8BCD34670AE7BDBC054D23B84B30DFDEBABA", "correct signature generated";
};

subtest "check garden waste container images" => sub {
my $cobrand = FixMyStreet::Cobrand::Sutton->new;

# Test garden waste bin image
my $bin_unit = {
garden_container => 26, # Garden waste bin
};
my $bin_image = $cobrand->image_for_unit($bin_unit);
is_deeply $bin_image, {
type => 'svg',
data => $bin_image->{data}, # SVG data will vary
colour => '#41B28A',
lid_colour => '#8B5E3D',
recycling_logo => undef,
}, "garden waste bin shows as green bin with brown lid";

# Test garden waste sack image
my $sack_unit = {
garden_container => 28, # Garden waste sack
};
my $sack_image = $cobrand->image_for_unit($sack_unit);
is_deeply $sack_image, {
type => 'svg',
data => $sack_image->{data}, # SVG data will vary
colour => '#F5F5DC',
}, "garden waste sack shows as cream colored sack";
};

FixMyStreet::override_config {
ALLOWED_COBRANDS => 'sutton',
MAPIT_URL => 'http://mapit.uk/',
Expand Down
6 changes: 3 additions & 3 deletions web/cobrands/fixmystreet-uk-councils/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,17 +636,17 @@ var centralbeds_types = [

function cb_should_not_require_road() {
// Ensure the user can select anywhere on the map if they want to
// make a report in the "Trees", "Fly Tipping" or "Rights of way" categories.
// make a report in the "Trees", "Fly Tipping" or "Public Rights of way" categories.
// This means we don't show the "not found" message if no category/group has yet been selected
// or if one of the groups containing either the "Trees", "Fly Tipping" or "Rights of way"
// or if one of the groups containing either the "Trees", "Fly Tipping" or "Public Rights of way"
// categories has been selected.
var selected = fixmystreet.reporting.selectedCategory();
return selected.category === "Trees" ||
(selected.group === "Grass, Trees, Verges and Weeds" && !selected.category) ||
selected.category === "Fly Tipping" ||
(selected.group === "Flytipping, Bins and Graffiti" && !selected.category) ||
selected.category === 'Housing Fly-tipping' ||
selected.category === 'Rights of way' ||
selected.category === 'Public Rights of way' ||
(!selected.group && !selected.category);
}

Expand Down

0 comments on commit 28af28c

Please sign in to comment.