aboutsummaryrefslogtreecommitdiffstats
path: root/.cypress/cypress/integration/simple_spec.js
blob: 074bf72bdbfb4619d25ddfb5208c28ffa4c7bcb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
describe('Clicking the map', function() {
    before(function(){
        cy.visit('/');
        cy.contains('Go');
        cy.get('[name=pc]').type(Cypress.env('postcode'));
        cy.get('[name=pc]').parents('form').submit();
    });

    it('allows me to report a new problem', function() {
        cy.url().should('include', '/around');
        cy.get('#map_box').click(200, 200);
        cy.get('#category_group').select('Flyposting');
        cy.get('[name=title]').type('Title');
        cy.get('[name=detail]').type('Detail');
        cy.get('.js-new-report-user-show').click();
        cy.get('.js-new-report-show-sign-in').should('be.visible').click();
        cy.get('#form_username_sign_in').type('user@example.org');
        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('#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) {
            expect(w.document.documentElement.innerText).to.equal('desktop');
        });
    });
});

describe('Leaving updates', function() {
    function leave_update() {
        cy.get('[name=update]').type('Update');
        cy.get('.js-new-report-user-show:last').click();
        cy.get('.js-new-report-show-sign-in:last').should('be.visible').click();
        // [id=]:last due to #2341
        cy.get('[id=form_username_sign_in]:last').type('user@example.org');
        cy.get('[name=password_sign_in]:last').type('password');
        cy.get('[name=password_sign_in]:last').parents('form:first').submit();
        cy.get('#map_sidebar').should('contain', 'check and confirm your details');
        cy.get('[name=submit_register]').parents('form').submit();
        cy.get('body').should('contain', 'Thank you for updating this issue');
    }

    it('works when visited directly', function() {
        cy.visit('/report/15');
        leave_update();
    });

    it('works when pulled in via JS', function() {
        cy.server();
        cy.route('/report/*').as('show-report');
        cy.route('/reports/*').as('show-all');
        cy.route('/mapit/area/*').as('get-geometry');
        cy.visit('/around?lon=-2.295894&lat=51.526877&zoom=0');
        // force to hopefully work around apparent Cypress SVG issue
        cy.get('image[title="Lights out in tunnel"]:last').click({force: true});
        cy.wait('@show-report');
        leave_update();
    });
});

describe('Clicking the "big green banner" on a map page', function() {
    before(function() {
        cy.visit('/');
        cy.get('[name=pc]').type(Cypress.env('postcode'));
        cy.get('[name=pc]').parents('form').submit();
        cy.get('.big-green-banner').click();
    });

    it('begins a new report', function() {
        cy.url().should('include', '/report/new');
        cy.get('#form_title').should('be.visible');
    });
});