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
|
Cypress.Commands.add('cleanUpXHR', function() {
cy.visit('/404', { failOnStatusCode: false });
});
describe('Staff user tests', function() {
it('report as defaults to body', function() {
cy.server();
cy.route('/report/new/ajax*').as('report-ajax');
cy.request({
method: 'POST',
url: '/auth?r=/',
form: true,
body: { username: 'cs_full@example.org', password_sign_in: 'password' }
});
cy.visit('/');
cy.contains('Go');
cy.get('[name=pc]').type(Cypress.env('postcode'));
cy.get('[name=pc]').parents('form').submit();
cy.url().should('include', '/around');
cy.get('#map_box').click(240, 249);
cy.get('[name=form_as]').should('have.value', 'body');
cy.cleanUpXHR();
});
it('report title and detail are correctly prefilled', function() {
cy.server();
cy.route('/report/new/ajax*').as('report-ajax');
cy.request({
method: 'POST',
url: '/auth?r=/',
form: true,
body: { username: 'cs_full@example.org', password_sign_in: 'password' }
});
cy.visit('/');
cy.contains('Go');
cy.get('[name=pc]').type(Cypress.env('postcode'));
cy.get('[name=pc]').parents('form').submit();
cy.url().should('include', '/around');
cy.get('#map_box').click(240, 249);
cy.wait('@report-ajax');
cy.get('select:eq(3)').select('Graffiti');
cy.get('[name=title]').should('have.value', 'A Graffiti problem has been found');
cy.get('[name=detail]').should('have.value', 'A Graffiti problem has been found by Borsetshire');
cy.cleanUpXHR();
});
});
|