-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add more tests from master branch
- Loading branch information
1 parent
ab1a4dd
commit 238a840
Showing
27 changed files
with
446 additions
and
127 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/// <reference types="Cypress" /> | ||
/// <reference types="../support" /> | ||
|
||
describe(`product`, () => { | ||
it(`can view product details`, () => { | ||
cy.visit('/'); | ||
|
||
cy.findAllByTestId('productBox').first().click(); | ||
|
||
cy.findByText('Share').click(); | ||
|
||
cy.findByTestId('add-qty-btn').click().click(); | ||
cy.findByTestId('reduce-qty-btn').click(); | ||
cy.findByText('Add To Cart').click(); | ||
|
||
cy.findByTestId('reduce-qty-btn').click(); | ||
cy.findByText('Add To Cart').click(); | ||
|
||
cy.findByText('Cart').click(); | ||
|
||
cy.findByLabelText('Increase Quantity', { | ||
timeout: 6000, | ||
}) | ||
.click() | ||
.click(); | ||
cy.findByLabelText('Reduce Quantity').click(); | ||
|
||
cy.findAllByLabelText('Remove', { exact: false }).first().click(); | ||
}); | ||
|
||
it(`can checkout cart`, () => { | ||
cy.visit('/'); | ||
|
||
cy.findAllByTestId('productBox').last().click(); | ||
|
||
cy.findByTestId('add-qty-btn').click().click(); | ||
cy.findByText('Add To Cart').click(); | ||
|
||
cy.findByAltText('Shopit').click(); | ||
|
||
cy.findAllByTestId('productBox').eq(3).click(); | ||
cy.findByText('Add To Cart').click(); | ||
|
||
cy.findByText('Cart').click(); | ||
cy.findByText('Check Out').click(); | ||
|
||
cy.findByLabelText('Card Number').type('5555555555554444'); | ||
cy.findByLabelText('Name').type('Malcolm Kee'); | ||
cy.findByLabelText('Valid Thru').type('1225'); | ||
cy.findByLabelText('CVC').type('123'); | ||
cy.findByText('Pay').click(); | ||
cy.findByText('Back to Home').click(); | ||
}); | ||
|
||
it(`focus on content input when user name is default`, () => { | ||
cy.createUser({ | ||
name: 'Winnie The Pooth', | ||
}).then((user) => { | ||
cy.visit('/'); | ||
cy.findByText('Login').click(); | ||
cy.findByLabelText('Email') | ||
.type(user.email) | ||
.get('form') | ||
.within((subject) => { | ||
cy.findByText('Login', { | ||
container: subject, | ||
selector: 'button', | ||
}).click(); | ||
}); | ||
|
||
cy.findByAltText('Shopit', { | ||
selector: 'a', | ||
}) | ||
.first() | ||
.click(); | ||
|
||
cy.findAllByTestId('productBox').eq(5).click(); | ||
|
||
cy.findByLabelText('Your Review', { | ||
timeout: 6000, | ||
}).type('I love honey{enter}do you?'); | ||
cy.findByText('Add').click(); | ||
cy.findByLabelText('Your Review').should('be.focused'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/// <reference types="Cypress" /> | ||
/// <reference types="../support" /> | ||
|
||
describe(`support`, () => { | ||
it(`can load all support pages`, () => { | ||
cy.visit('/help'); | ||
|
||
cy.findByText('Account').click(); | ||
|
||
cy.findByText('If you forget password, just create another one.', { | ||
exact: false, | ||
}).should('be.visible'); | ||
|
||
cy.findByText('Payment').click(); | ||
cy.findByText("when you can't even pay?", { exact: false }).should( | ||
'be.visible' | ||
); | ||
|
||
cy.findByText('Shipping').click(); | ||
cy.findByText('3-5 years', { exact: false }).should('be.visible'); | ||
|
||
cy.findByText('Complaint').click(); | ||
cy.findByText('Category').should('be.visible'); | ||
}); | ||
|
||
it(`can submit complain`, () => { | ||
cy.visit('/'); | ||
cy.findAllByText('Help').first().click(); | ||
|
||
cy.findByText('Complaint').click(); | ||
|
||
cy.findByLabelText('I want to make complain about').select('deliver'); | ||
cy.findByText('Next').click(); | ||
|
||
cy.findByLabelText('Date of incident') | ||
.click() | ||
.get('.datepick-popup') | ||
.within(() => { | ||
cy.findByText('2').click(); | ||
}); | ||
cy.findByLabelText('Details about the incident').type( | ||
'I say hi{enter}Then he say goodbye.' | ||
); | ||
|
||
cy.findByLabelText('Upload File').attachFile('mk-icon.png', { | ||
subjectType: 'drag-n-drop', | ||
force: true, | ||
}); | ||
cy.findByText('Next').click(); | ||
|
||
cy.findByLabelText('Your Full Name').type('Mashi Maro'); | ||
cy.findByLabelText('Your Phone Number').type('12345678'); | ||
cy.findByText('Submit').click(); | ||
|
||
cy.findByText('Shipping').click(); | ||
}); | ||
|
||
it(`cancel while upload`, () => { | ||
cy.server(); | ||
|
||
cy.route({ | ||
url: /upload$/, | ||
method: 'PUT', | ||
delay: 2000, | ||
}); | ||
|
||
cy.visit('/'); | ||
cy.findAllByText('Help').first().click(); | ||
|
||
cy.findByText('Complaint').click(); | ||
|
||
cy.findByLabelText('I want to make complain about').select('deliver'); | ||
cy.findByText('Next').click(); | ||
|
||
cy.findByLabelText('Upload File').attachFile('mk-icon.png', { | ||
subjectType: 'drag-n-drop', | ||
force: true, | ||
}); | ||
|
||
cy.findByLabelText('Remove').click(); | ||
}); | ||
|
||
it(`shows error when upload fails`, () => { | ||
cy.visit('/help'); | ||
|
||
cy.server(); | ||
|
||
cy.route({ | ||
url: /upload$/, | ||
method: 'PUT', | ||
status: 500, | ||
response: 'Internal Server Error', | ||
delay: 200, | ||
}); | ||
|
||
cy.findByText('Complaint').click(); | ||
|
||
cy.findByLabelText('I want to make complain about').select('deliver'); | ||
cy.findByText('Next').click(); | ||
|
||
cy.findByLabelText('Upload File').attachFile('mk-icon.png', { | ||
subjectType: 'drag-n-drop', | ||
force: true, | ||
}); | ||
|
||
cy.findByText('Failed to Upload').should('be.visible'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"compilerOptions": { | ||
"baseUrl": "src" | ||
}, | ||
"include": ["src"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import * as React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { user } from 'lib/test-util'; | ||
import { Alert } from './alert'; | ||
|
||
describe(`<Alert />`, () => { | ||
it(`renders and dismissed`, () => { | ||
const msg = 'Hello'; | ||
render( | ||
<Alert color="danger" dismissible> | ||
<p>{msg}</p> | ||
</Alert> | ||
); | ||
|
||
expect(screen.getByText(msg)).toBeVisible(); | ||
|
||
user.click(screen.getByLabelText('Close')); | ||
expect(screen.queryByText(msg)).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.