-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
76 additions
and
7 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,8 +1,76 @@ | ||
describe('My First Test', () => { | ||
it('Does not do much!', () => { | ||
cy.visit('http://localhost:3000/testing-cypress/') | ||
describe('example to-do app', () => { | ||
beforeEach(() => { | ||
cy.visit("https://example.cypress.io/todo") | ||
}); | ||
|
||
cy.wait(1000) | ||
cy.contains('Baitaptracnghiem') | ||
it("displays two todo items by default", ()=>{ | ||
cy.get('.todo-list li').should("have.length", 2); | ||
|
||
cy.get('.todo-list li').first().should('have.text', 'Pay electric bill') | ||
cy.get('.todo-list li').last().should('have.text', 'Walk the dog') | ||
}); | ||
|
||
it('can add new todo items', () => { | ||
const newItem = 'Feed the cat'; | ||
|
||
// add new todo item | ||
cy.get('[data-test=new-todo]').type(`${newItem}{enter}`); | ||
|
||
// | ||
cy.get('.todo-list li') | ||
.should('have.length', 3) // add new todo item successfully | ||
.last().should('have.text', newItem); // test that newItem | ||
}); | ||
|
||
it('can check off an item as completed', () => { | ||
// check pay electric bill | ||
cy.contains('Pay electric bill') | ||
.parent().find('input[type=checkbox]').check(); | ||
|
||
cy.contains('Pay electric bill').parents('li') | ||
.should('have.class','completed'); | ||
}); | ||
|
||
context('with a checked task', () => { | ||
beforeEach(() => { | ||
cy.contains('Pay electric bill').parent() | ||
.find('input[type=checkbox]').check(); | ||
}) | ||
|
||
it('can filter for uncompleted tasks', () => { | ||
// We'll click on the "active" button in order to | ||
// display only incomplete items | ||
cy.contains('Active').click(); | ||
|
||
cy.get('.todo-list li').should('have.length', 1) | ||
.first().should('have.text', 'Walk the dog') | ||
|
||
cy.contains('Pay electric bill').should('not.exist') | ||
}) | ||
|
||
it('can filter for completed tasks', () => { | ||
cy.contains('Completed').click() | ||
|
||
cy.get('.todo-list li') | ||
.should('have.length', 1) | ||
.first() | ||
.should('have.text', 'Pay electric bill') | ||
|
||
cy.contains('Walk the dog').should('not.exist') | ||
}) | ||
|
||
it('can delete all completed tasks', () => { | ||
cy.contains('Clear completed').click() | ||
|
||
cy.get('.todo-list li') | ||
.should('have.length', 1) | ||
.should('not.have.text', 'Pay electric bill') | ||
|
||
cy.contains('Clear completed').should('not.exist') | ||
}); | ||
}) | ||
|
||
after(() => { | ||
cy.wait(5000); | ||
}) | ||
}) | ||
}); |