Skip to content

Commit

Permalink
Fixes for changes in test flow/speed.
Browse files Browse the repository at this point in the history
Have seen a situation (more likely with upgraded jQuery?) where the test
code runs before the map has initialised its layers, so make sure the
map is loaded.

And make sure a couple of other things load before clicks/submissions.
  • Loading branch information
dracos committed Nov 23, 2020
1 parent 9509d20 commit e802f8b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions .cypress/cypress/integration/bathnes.js
Expand Up @@ -16,6 +16,7 @@ it('loads the staff layer correctly', function() {
cy.get('[name=pc]').parents('form').submit();
cy.url().should('include', '/around');
cy.window().its('fixmystreet.maps').should('have.property', 'banes_defaults');
cy.get('.olMap'); // Make sure map is loaded before testing its layers
cy.window().then(function(win){
var llpg = 0;
win.fixmystreet.map.layers.forEach(function(lyr) {
Expand Down
6 changes: 6 additions & 0 deletions .cypress/cypress/integration/borsetshire.js
Expand Up @@ -4,15 +4,21 @@ it('loads the right front page', function() {
});

it('logs in without fuss', function() {
cy.server();
cy.route('/mapit/area/*').as('get-geometry');

cy.contains('Sign in').click();
cy.contains('Customer service').click();
cy.url().should('include', '/reports');
cy.wait('@get-geometry');

cy.contains('Your account').click();
cy.contains('Sign out').click();
cy.contains('Sign in').click();
cy.contains('Inspector').click();
cy.url().should('include', '/my/planned');
// Wait for offline stuff, which can take time
cy.get('.top_banner--offline', { timeout: 10000 }).contains('Reports saved offline', { timeout: 10000 });

cy.visit('http://borsetshire.localhost:3001/auth');
cy.get('[name=username]').type('super@example.org');
Expand Down
2 changes: 2 additions & 0 deletions .cypress/cypress/integration/buckinghamshire.js
Expand Up @@ -5,11 +5,13 @@ describe('buckinghamshire cobrand', function() {
cy.fixture('roads.xml');
cy.route('**mapserver/bucks*Whole_Street*', 'fixture:roads.xml').as('roads-layer');
cy.route('/report/new/ajax*').as('report-ajax');
cy.route('/around\?ajax*').as('update-results');
cy.route('/around/nearby*').as('around-ajax');
cy.visit('http://buckinghamshire.localhost:3001/');
cy.contains('Buckinghamshire');
cy.get('[name=pc]').type('SL9 0NX');
cy.get('[name=pc]').parents('form').submit();
cy.wait('@update-results');
});

it('sets the site_code correctly', function() {
Expand Down
4 changes: 4 additions & 0 deletions .cypress/cypress/integration/simple_spec.js
Expand Up @@ -18,6 +18,7 @@ describe('Clicking the map', function() {
cy.get('[name=password_sign_in]').type('password');
cy.get('[name=password_sign_in]').parents('form').submit();
cy.get('#map_sidebar').should('contain', 'check and confirm your details');
cy.get('#form_service').should('have.value', 'desktop');
cy.get('#map_sidebar').parents('form').submit();
cy.get('body').should('contain', 'Thank you for reporting this issue');
cy.visit('http://fixmystreet.localhost:3001/_test/setup/simple-service-check').then(function(w) {
Expand Down Expand Up @@ -60,9 +61,12 @@ describe('Leaving updates', function() {

describe('Clicking the "big green banner" on a map page', function() {
before(function() {
cy.server();
cy.route('/around\?ajax*').as('update-results');
cy.visit('/');
cy.get('[name=pc]').type(Cypress.env('postcode'));
cy.get('[name=pc]').parents('form').submit();
cy.wait('@update-results');
cy.get('.big-green-banner').click();
});

Expand Down

0 comments on commit e802f8b

Please sign in to comment.