Skip to content

Commit 8a85718

Browse files
mattwr18joaopapereira
authored andcommitted
Refactor create_events.feature
- stubbing all backend requests - we were manually visiting the newlyCreatedEventInfo page - now we are testing that event creation causes the user to be redirected
1 parent 7bb6e19 commit 8a85718

File tree

4 files changed

+110
-51
lines changed

4 files changed

+110
-51
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[
2+
{
3+
"id": 1,
4+
"title": "Autograder",
5+
"description": "Autograder for the EdX CS169.x SaaS course",
6+
"status": "Active",
7+
"created_at": "2018-10-18T20:54:13.525Z",
8+
"updated_at": "2018-10-18T20:54:13.525Z",
9+
"user_id": 1,
10+
"slug": "autograder",
11+
"github_url": "https://github.com/saasbook/rag",
12+
"pivotaltracker_url": null,
13+
"pitch": null,
14+
"commit_count": 200,
15+
"image_url": "http://i.imgur.com/23ePvyN.jpg",
16+
"last_github_update": null,
17+
"slack_channel_name": null,
18+
"tag_list": [],
19+
"languages": ["Ruby"]
20+
},
21+
{
22+
"id": 2,
23+
"title": "LocalSupport",
24+
"description": "VAH's Local Support site is at www.harrowcn.org.uk",
25+
"status": "Active",
26+
"created_at": "2018-10-18T20:54:13.525Z",
27+
"updated_at": "2018-10-18T20:54:13.525Z",
28+
"user_id": 3,
29+
"slug": "localsupport",
30+
"github_url": "https://github.com/AgileVentures/LocalSupport/",
31+
"pivotaltracker_url": "https://www.pivotaltracker.com/n/projects/742821",
32+
"pitch": null,
33+
"commit_count": 3655,
34+
"image_url": null,
35+
"last_github_update": null,
36+
"slack_channel_name": null,
37+
"tag_list": [],
38+
"languages": ["Ruby"]
39+
},
40+
{
41+
"id": 3,
42+
"title": "Project 5",
43+
"description": "VAH's Local Support site is at www.harrowcn.org.uk",
44+
"status": "Active",
45+
"created_at": "2018-10-18T20:54:13.525Z",
46+
"updated_at": "2018-10-18T20:54:13.525Z",
47+
"user_id": 3,
48+
"slug": "localsupport",
49+
"github_url": "https://github.com/AgileVentures/LocalSupport/",
50+
"pivotaltracker_url": "https://www.pivotaltracker.com/n/projects/742821",
51+
"pitch": null,
52+
"commit_count": 3655,
53+
"image_url": null,
54+
"last_github_update": null,
55+
"slack_channel_name": null,
56+
"tag_list": [],
57+
"languages": ["Ruby"]
58+
}
59+
]
Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
{
2-
"id": 1,
3-
"name": "NewEvent",
4-
"category": "PairProgramming",
5-
"description": "",
6-
"repeats": "never",
7-
"repeats_every_n_weeks": null,
8-
"repeats_weekly_each_days_of_the_week_mask": 0,
9-
"repeat_ends": false,
10-
"repeat_ends_on": null,
11-
"time_zone": "UTC",
12-
"created_at": "2025-01-05T13:02:16.681Z",
13-
"updated_at": null,
14-
"url": null,
15-
"slug": "newevent",
16-
"start_datetime": "2025-01-05T00:00:00.000Z",
17-
"duration": 30,
18-
"exclusions": [],
19-
"project_id": null,
20-
"creator_id": 3493,
21-
"for": "All",
22-
"modifier_id": null,
23-
"creator_attendance": null,
24-
"time": "2019-02-24T00:00:00.000Z",
25-
"creator": "Mad Writer",
26-
"modifier": "Mad Writer",
27-
"creatorGravatarUrl": "https://www.gravatar.com/avatar/9249736dae1898d537770886061c06f9?s=32&d=retro",
28-
"modifierGravatarUrl": "https://www.gravatar.com/avatar/9249736dae1898d537770886061c06f9?s=32&d=retro",
29-
"videos": [],
30-
"createdAt": "2018-03-12T16:30:55.399Z",
31-
"updatedAt": "2018-03-12T16:30:55.399Z"
1+
{
2+
"event":{
3+
"id":1,
4+
"name":"NewEvent",
5+
"category":"PairProgramming",
6+
"description":"",
7+
"repeats":"never",
8+
"repeats_every_n_weeks":null,
9+
"repeats_weekly_each_days_of_the_week_mask":0,
10+
"repeat_ends":false,
11+
"repeat_ends_on":null,
12+
"time_zone":"UTC",
13+
"created_at":"2025-01-05T13:02:16.681Z",
14+
"updated_at":null,
15+
"url":null,
16+
"slug":"newevent",
17+
"start_datetime":"2025-01-05T00:00:00.000Z",
18+
"duration":30,
19+
"exclusions":[],
20+
"project_id":null,
21+
"creator_id":3493,
22+
"for":"All",
23+
"modifier_id":null,
24+
"creator_attendance":null,
25+
"time":"2019-02-24T00:00:00.000Z",
26+
"creator":"Mad Writer",
27+
"modifier":"Mad Writer",
28+
"creatorGravatarUrl":"https://www.gravatar.com/avatar/9249736dae1898d537770886061c06f9?s=32&d=retro",
29+
"modifierGravatarUrl":"https://www.gravatar.com/avatar/9249736dae1898d537770886061c06f9?s=32&d=retro",
30+
"createdAt":"2018-03-12T16:30:55.399Z",
31+
"updatedAt":"2018-03-12T16:30:55.399Z"
32+
},
33+
"videos":[]
3234
}

cypress/integration/common/web_steps.js

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -202,38 +202,37 @@ Given('I am logged in', () => {
202202
})
203203
cy.wait('@postLogInInfo')
204204
})
205+
Then('I visit the new events page', () => {
206+
cy.fixture('activeProjects').then(activeProjects => {
207+
cy.route(/\/api\/v1\/projects\/active/, activeProjects).as('fetchActiveProjects')
208+
cy.visit('/events/new')
209+
.get('h1')
210+
.should('contain', 'Creating a new Event')
211+
cy.window()
212+
.its('store')
213+
.invoke('dispatch', { type: 'GET_ACTIVE_PROJECTS', payload: activeProjects })
214+
})
215+
cy.wait('@fetchActiveProjects')
216+
})
205217

206218
Then('I should be able to create a new event quickly', () => {
207-
cy.fixture('newlyCreatedEvent').then(newlyCreatedEvent => {
219+
cy.fixture('newlyCreatedEventInfo').then(newlyCreatedEventInfo => {
208220
cy.route({
209221
method: 'POST',
210222
url: /\/events/,
211-
response: newlyCreatedEvent,
223+
response: newlyCreatedEventInfo,
212224
status: 200
213225
}).as('newlyCreatedEvent')
214-
cy.visit('/events/new')
215-
.get('h1')
216-
.should('contain', 'Creating a new Event')
217-
.get('input[name=name]')
226+
cy.get('input[name=name]')
218227
.type('NewEvent')
219228
.get('button[type=submit]')
220229
.click()
221-
cy.window()
222-
.its('store')
223-
.invoke('dispatch', { type: 'GET_EVENT_INFO', payload: newlyCreatedEvent })
224-
})
225-
cy.wait('@newlyCreatedEvent')
226-
})
227-
228-
When("I should be redirected to the event's info page", () => {
229-
cy.fixture('newlyCreatedEventInfo').then(newlyCreatedEventInfo => {
230-
cy.route(/\/api\/v1\/events\/newevent/, newlyCreatedEventInfo).as('getEvent')
231-
cy.visit('/events/newevent')
230+
.url().should('include', '/events/newevent')
232231
cy.window()
233232
.its('store')
234233
.invoke('dispatch', { type: 'GET_EVENT_INFO', payload: newlyCreatedEventInfo })
235234
})
236-
cy.wait('@getEvent')
235+
cy.wait('@newlyCreatedEvent')
237236
})
238237

239238
Then("I should see the newly created event's info", () => {
@@ -246,7 +245,6 @@ Then("I should see the newly created event's info", () => {
246245
.should('contain', 'Event for: All')
247246
.get('img.ui.circular.image')
248247
.should('have.attr', 'src')
249-
.and('contain', 'https://www.gravatar.com/avatar/9249736dae1898d537770886061c06f9?s=32&d=retro')
250248
.get('p')
251249
.should('contain', 'created by:')
252250
})

cypress/integration/create_events.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Feature: Create new event
44

55
Scenario: Quick create
66
Given I am logged in
7+
And I visit the new events page
78
Then I should be able to create a new event quickly
8-
And I should be redirected to the event's info page
99
And I should see the newly created event's info

0 commit comments

Comments
 (0)