Skip to content

Commit cd86f94

Browse files
committed
Moved test data to cypress config file
1 parent 56a2e1a commit cd86f94

File tree

6 files changed

+39
-55
lines changed

6 files changed

+39
-55
lines changed

cypress.json

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
{
22
"baseUrl": "http://localhost:3000",
33
"env": {
4-
"testUsername": "user1",
5-
"testUserEmail": "[email protected]",
6-
"testUserPassword": "password",
7-
"testStoryTitle": "This is a test story",
8-
"testStoryProduct": "EOS Icons",
9-
"testCategory": "Documentation"
4+
"testUser":{
5+
"username": "user1",
6+
"email": "[email protected]",
7+
"password": "password"
8+
},
9+
"updatedUser": {
10+
"name": "user1-updated",
11+
"bio": "Hello, this is a updated bio for testing",
12+
"profession": "updated-profession",
13+
"company": "updated-company",
14+
"linkedin": "updated-linkedin",
15+
"twitter": "updated-twitter"
16+
},
17+
"testStory": {
18+
"title": "This is a test story",
19+
"product": "EOS Icons",
20+
"category": "Documentation"
21+
}
1022
},
1123
"testFiles": ["auth.spec.js","new_story.spec.js","user_story.spec.js","dashboard.spec.js", "user_account.spec.js"]
1224
}

cypress/integration/auth.spec.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,7 @@
22

33
describe("Authentication Tests", () => {
44

5-
const testUser = {
6-
username: Cypress.env('testUsername'),
7-
email: Cypress.env('testUserEmail'),
8-
password: Cypress.env('testUserPassword')
9-
}
5+
const testUser = Cypress.env("testUser")
106

117
beforeEach('visit the page and wait it to load', () => {
128

@@ -159,4 +155,4 @@ describe("Authentication Tests", () => {
159155
cy.contains("Identifier or password invalid")
160156
})
161157

162-
})
158+
})

cypress/integration/dashboard.spec.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,9 @@ describe('Tests for dashboard',()=>{
1313

1414

1515
describe('Test the filters and search for stories in Home page', () => {
16-
const testStory = {
17-
title: Cypress.env('testStoryTitle'),
18-
product: Cypress.env('testStoryProduct'),
19-
category: Cypress.env('testCategory')
20-
}
16+
const testStory = Cypress.env("testStory")
2117

22-
const testUser = {
23-
username: Cypress.env('testUsername')
24-
}
18+
const testUser = Cypress.env("testUser")
2519

2620
const selectProduct = (productName) => {
2721
cy.get(`[data-cy=${productName.split(' ').join('-')}-card]`).click({

cypress/integration/new_story.spec.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
/// <reference types="cypress" />
22

33
describe("Tests for creating a new story", () => {
4-
const testUser = {
5-
username: Cypress.env('testUsername'),
6-
email: Cypress.env('testUserEmail'),
7-
password: Cypress.env('testUserPassword')
8-
}
4+
5+
const testUser = Cypress.env("testUser")
96

107
const testStory = {
11-
title: Cypress.env('testStoryTitle'),
12-
product: Cypress.env('testStoryProduct'),
13-
category: Cypress.env('testCategory'),
14-
priority: 'High',
15-
description: '{enter}Testing User Story'
8+
...Cypress.env("testStory"),
9+
... {
10+
priority: 'High',
11+
description: '{enter}Testing User Story'
12+
}
1613
}
1714

1815
before('Log in the user', () => {

cypress/integration/user_account.spec.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,10 @@
11
/// <reference types="cypress" />
22

33
describe("Tests for user's profile page", () => {
4-
const testUser = {
5-
username: Cypress.env('testUsername'),
6-
email: Cypress.env('testUserEmail'),
7-
password: Cypress.env('testUserPassword')
8-
}
94

10-
const updatedUser = {
11-
name: testUser.username + '-updated',
12-
bio: 'Hello, this is a updated bio for testing',
13-
profession: 'updated-profession',
14-
company: 'updated-company',
15-
linkedin: 'updated-linkedin',
16-
twitter: 'updated-twitter',
17-
}
5+
const testUser = Cypress.env("testUser")
6+
7+
const updatedUser = Cypress.env("updatedUser")
188

199
// Function to update the detaiil of a user with the given text
2010
const updateDetail = (field, value) => {
@@ -113,4 +103,3 @@ describe("Tests for user's profile page", () => {
113103
})
114104

115105
})
116-

cypress/integration/user_story.spec.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
11
/// <reference types="cypress" />
22

33
describe('Tests for story page', () => {
4-
const testUser = {
5-
username: Cypress.env('testUsername'),
6-
email: Cypress.env('testUserEmail'),
7-
password: Cypress.env('testUserPassword')
8-
}
4+
const testUser = Cypress.env("testUser")
95

106
const testStory = {
11-
title: Cypress.env('testStoryTitle'),
12-
product: Cypress.env('testStoryProduct'),
13-
category: Cypress.env('testCategory'),
14-
priority: 'High',
15-
description: '{enter}Testing User Story',
16-
descriptionText: 'Testing User Story'
7+
...Cypress.env("testStory"),
8+
...{
9+
priority: 'High',
10+
description: '{enter}Testing User Story',
11+
descriptionText: 'Testing User Story'
12+
}
1713
}
1814

1915
const editedDescription = 'Edited story description'

0 commit comments

Comments
 (0)