Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 3d4d933

Browse files
committed
Add E2E tests for event creation
1 parent 45adeed commit 3d4d933

File tree

3 files changed

+101
-6
lines changed

3 files changed

+101
-6
lines changed

cypress/fixtures/events.json

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"results": [
3+
{
4+
"id": "b2a60543-6356-4ab5-b766-d66b96187b14",
5+
"name": "asdasdfas",
6+
"country": {
7+
"countryName": "United Kingdom",
8+
"continent": "EU",
9+
"alpha2": "GB",
10+
"alpha3": "GBR",
11+
"countryNumber": 826
12+
},
13+
"city": {
14+
"nameWithHierarchy": "Sheffield"
15+
},
16+
"address": "108 The Moor, Sheffield, S1 4PD",
17+
"createdAt": "2019-06-10T10:46:58.549Z",
18+
"createdBy": null,
19+
"type": "one-off",
20+
"description": "<div><!--block-->Please bring:<br><br></div><ul><li><!--block-->A laptop. Borrow one from somebody if needs be.</li><li><!--block--><strong>A parent! (Very important). If you are 12 or under, your parent must stay with you during the session.</strong></li></ul>",
21+
"dojoId": "4f2ebdec-ce05-4a85-840c-f59fb0a19ca7",
22+
"position": null,
23+
"public": true,
24+
"status": "published",
25+
"recurringType": null,
26+
"dates": [
27+
{
28+
"startTime": "2019-07-12T10:00:00.000Z",
29+
"endTime": "2019-07-12T12:00:00.000Z"
30+
}
31+
],
32+
"ticketApproval": false,
33+
"notifyOnApplicant": false,
34+
"eventbriteId": null,
35+
"eventbriteUrl": null,
36+
"useDojoAddress": false,
37+
"startTime": "2019-07-12T10:00:00.000Z",
38+
"endTime": "2019-07-12T12:00:00.000Z",
39+
"sessions": [
40+
{
41+
"id": "59f9ec57-15a0-4ad0-9de4-e1f341270943",
42+
"name": "Dojo",
43+
"description": "Dojo Session",
44+
"eventId": "b2a60543-6356-4ab5-b766-d66b96187b14",
45+
"status": "active",
46+
"tickets": [
47+
{
48+
"id": "b54f281a-beb4-43f5-aac0-bc670f0f2cd2",
49+
"sessionId": "59f9ec57-15a0-4ad0-9de4-e1f341270943",
50+
"name": "Youth",
51+
"type": "ninja",
52+
"quantity": 5,
53+
"deleted": 0,
54+
"totalApplications": 0,
55+
"approvedApplications": 0
56+
},
57+
{
58+
"id": "a83806d5-3a77-4617-9f08-b1becbb0279f",
59+
"sessionId": "59f9ec57-15a0-4ad0-9de4-e1f341270943",
60+
"name": "Mentor",
61+
"type": "mentor",
62+
"quantity": 6,
63+
"deleted": 0,
64+
"totalApplications": 0,
65+
"approvedApplications": 0
66+
}
67+
]
68+
}
69+
]
70+
}
71+
],
72+
"total": 7
73+
}

cypress/integration/events/event-form_spec.js

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,38 @@ describe('Event form', () => {
44
beforeEach(() => {
55
cy.server();
66
cy.route('/api/2.0/users/instance', 'fx:parentLoggedIn');
7-
cy.route('/api/2.0/dojos/d1', 'fx:dojo').as('dojo');
7+
cy.route('/api/2.0/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6', 'fx:dojo').as('dojo');
8+
cy.route('/api/3.0/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6/events?pageSize=1&page=1&orderBy=startTime&direction=desc&related=sessions.tickets', 'fx:events').as('events')
89
});
910

1011
it('should display the form', () => {
11-
cy.visit('/dashboard/dojos/d1/events/new');
12+
cy.visit('/dashboard/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6/events/new');
13+
cy.wait('@events');
1214
cy.wait('@dojo');
1315
cy.get(page.header).should('be.visible');
1416
cy.get(page.submitButton).should('be.visible');
15-
cy.get(page.submitButton).invoke('text').should('contain', 'Publish and email members');
17+
cy.get(page.submitButton).invoke('text').should('contain', 'Publish');
1618
cy.get(page.youthTickets).should('be.visible');
1719
cy.get(page.mentorTickets).should('be.visible');
1820
});
21+
22+
it('forwards to dojo page on publish', () => {
23+
cy.route('POST', '/api/3.0/events', 'fx:events');
24+
cy.visit('/dashboard/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6/events/new');
25+
cy.wait('@events');
26+
cy.wait('@dojo');
27+
cy.get('[data-cy=title]').type('New event');
28+
cy.get(page.submitButton).click();
29+
cy.url().should('include', '/dojos/ie/dublin/cd-rom');
30+
});
31+
32+
it('displays error message if form incomplete', () => {
33+
cy.route('POST', '/api/3.0/events', 'fx:events');
34+
cy.visit('/dashboard/dojos/b850b40e-1e10-4e3a-8a46-d076c94946c6/events/new');
35+
cy.wait('@events');
36+
cy.wait('@dojo');
37+
cy.get(page.submitButton).click();
38+
cy.get('[data-cy=title-error]').should('be.visible');
39+
cy.get('[data-cy=title-error]').invoke('text').should('eq', 'Title is required');
40+
});
1941
});

src/events/cd-event-form.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<h3 class="text-danger">{{ $t('There was an error processing this request. Please try again or contact support') }}</h3>
1212
</div>
1313
<h4 class="cd-event__section-title">{{ $t('Event Title') }}</h4>
14-
<p class="text-danger" v-show="errors.has('name:required')">{{ $t('Title is required') }}</p>
15-
<input type="text" name="name" v-model="name" class="form-control" data-vv-name="name" v-validate="'required'" data-vv-validate-on="blur" :placeholder="$t('e.g. October Dojo')">
14+
<p class="text-danger" data-cy="title-error" v-show="errors.has('name:required')">{{ $t('Title is required') }}</p>
15+
<input type="text" data-cy="title" name="name" v-model="name" class="form-control" data-vv-name="name" v-validate="'required'" data-vv-validate-on="blur" :placeholder="$t('e.g. October Dojo')">
1616

1717
<div class="cd-event-form__location">
1818
<!-- is the text relevant when it's been modified? -->
@@ -341,7 +341,7 @@
341341
related: 'sessions.tickets',
342342
},
343343
});
344-
344+
//
345345
this.latestEvent = latestEvent.body.results[0];
346346
this.dojo = (await DojosService.getDojoById(dojoId)).body;
347347
this.populateForm();

0 commit comments

Comments
 (0)