Skip to content

Commit 9801a91

Browse files
committed
Removed redundant contains
1 parent 9d3bf31 commit 9801a91

File tree

2 files changed

+20
-22
lines changed

2 files changed

+20
-22
lines changed

cypress/integration/user_story.spec.js

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,31 +23,27 @@ describe('Test new User Registration Workflow', () => {
2323

2424
cy
2525
.get('[data-cy=btn-signin]')
26-
.should('have.attr', 'href', '/login')
27-
.contains('Sign In')
2826
.click()
2927

30-
cy.url().should('equal', 'http://localhost:3000/login')
28+
cy.url().should('equal', `${Cypress.config().baseUrl}/login`)
3129

3230
cy
3331
.get('[data-cy=link-create-account]')
34-
.should('have.attr', 'href', '/register')
35-
.contains('Create an account')
3632
.click()
3733

38-
cy.url().should('equal', 'http://localhost:3000/register')
34+
cy.url().should('equal', `${Cypress.config().baseUrl}/register`)
3935

40-
cy.get('[data-cy=username]').should('have.attr', 'type', 'text').type(testUser.username)
36+
cy.get('[data-cy=username]').type(testUser.username)
4137

42-
cy.get('[data-cy=email]').should('have.attr', 'type', 'text').type(testUser.email)
38+
cy.get('[data-cy=email]').type(testUser.email)
4339

4440
cy.get('[data-cy=password]').should('have.attr', 'type', 'password').type(testUser.password)
4541

46-
cy.get('[data-cy=tc]').should('have.attr', 'type', 'checkbox').click()
42+
cy.get('[data-cy=tc]').click()
4743

48-
cy.get('[data-cy=btn-register]').contains('Register').click()
44+
cy.get('[data-cy=btn-register]').click()
4945

50-
cy.url().should('equal', 'http://localhost:3000/')
46+
cy.url().should('equal', `${Cypress.config().baseUrl}/`)
5147

5248
cy.saveLocalStorage()
5349
})
@@ -64,11 +60,9 @@ describe('Test new User Registration Workflow', () => {
6460
it('Allows user to create new story', () => {
6561
cy
6662
.get('[data-cy=btn-new-story]')
67-
.should('have.attr', 'href', '/newStory')
68-
.contains('+ New Story')
6963
.click()
7064

71-
cy.url().should('equal', 'http://localhost:3000/newStory')
65+
cy.url().should('equal', `${Cypress.config().baseUrl}/newStory`)
7266

7367
cy.get('[data-cy=title]').type(testStory.title)
7468

@@ -82,9 +76,9 @@ describe('Test new User Registration Workflow', () => {
8276
.get('[data-cy=description-editor]')
8377
.type(testStory.description)
8478

85-
cy.get('[data-cy=btn-submit]').contains('Submit').click()
79+
cy.get('[data-cy=btn-submit]').click()
8680

87-
cy.url().should('equal', 'http://localhost:3000/')
81+
cy.url().should('equal', `${Cypress.config().baseUrl}/`)
8882
})
8983

9084
it('Displays story in home page, once created', () => {
@@ -98,23 +92,23 @@ describe('Test new User Registration Workflow', () => {
9892
})
9993

10094
it('Allows user to edit the story created by them', () => {
101-
cy.get('[data-cy=btn-edit]', { timeout: 1000}).contains('Edit').click()
95+
cy.get('[data-cy=btn-edit]', { timeout: 1000 }).click()
10296

10397
cy.get('[data-cy=edit-description]').type(editedDescription)
10498

105-
cy.get('[data-cy=story-buttons]').contains('Save').click()
99+
cy.get('[data-cy=btn-save]').click()
106100

107101
cy.get('[data-cy=story-description]').contains(editedDescription)
108102
})
109103

110104
it('Allows user to comment on a story', () => {
111-
cy.get('[data-cy=nav-eos-logo]').should('have.attr', 'href', '/').click()
105+
cy.get('[data-cy=nav-eos-logo]').click()
112106

113107
cy.get('[data-cy=stories]').contains(testStory.title).click()
114108

115109
cy.get('[data-cy=comment-input-2]').type(testComment)
116110

117-
cy.get('[data-cy=btn-comment-2]').contains('Add Comment').click()
111+
cy.get('[data-cy=btn-comment-2]').click()
118112

119113
cy.get('[data-cy=comment-content]').contains(testComment)
120114

src/pages/Story.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ const Story = (props) => {
152152
data-cy='story-description'
153153
/>
154154
)}
155-
<div className='story-buttons-container' data-cy='story-buttons'>
155+
<div className='story-buttons-container'>
156156
{editMode && !editor ? (
157157
<>
158158
<Button
@@ -179,7 +179,11 @@ const Story = (props) => {
179179
''
180180
)}
181181
{editor ? (
182-
<Button className='btn btn-default' onClick={save}>
182+
<Button
183+
className='btn btn-default'
184+
onClick={save}
185+
data-cy='btn-save'
186+
>
183187
Save
184188
</Button>
185189
) : (

0 commit comments

Comments
 (0)