Skip to content

Commit

Permalink
Update gui.cy.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hani-13 authored Jun 30, 2024
1 parent 079914e commit c8b8096
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions frontend/cypress/e2e/gui.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,16 @@ describe('Testing todo-items', () => {
// Check that the text 'Review video' is present in at least one item
cy.get('ul.todo-list li.todo-item span.editable').should('contain', 'Review video');

// if duplicates are allowed, expect 4, otherwise expect 3
cy.get('ul.todo-list').children('.todo-item').should('have.length', 4);
});



it('TC5: Mark to-do item as “done”', () => {
// Click the checker span to mark the todo item as done
cy.get('ul.todo-list li.todo-item').find('span.checker').click();
it('TC5: Mark todo item as “done”', () => {
// Select the second todo item and click the checker span to mark it as done
cy.get('ul.todo-list li.todo-item').first().find('span.checker').click();

// Verify that the span now has the 'checked' class
cy.get('ul.todo-list li.todo-item').find('span.checker').should('have.class', 'checked');
// Verify that the span now has the 'checked' class for the second item
cy.get('ul.todo-list li.todo-item').first().find('span.checker').should('have.class', 'checked');
});


Expand All @@ -83,7 +81,7 @@ describe('Testing todo-items', () => {
cy.get('ul.todo-list li.todo-item').first().find('span.checker').click();

// Verify that the span no longer has the 'checked' class indicating it is no longer marked as done
cy.get('ul.todo-list li.todo-item').first().find('span.checker').should('not.have.class', 'checked');
cy.get('ul.todo-list li.todo-item').first().find('span.checker').should('have.class', 'unchecked');
});

it('TC7: Toggle item repeatedly', () => {
Expand All @@ -105,16 +103,10 @@ describe('Testing todo-items', () => {


it('TC8: Delete to-do item from the list', () => {
// First, find the number of todo items before the deletion
cy.get('ul.todo-list li.todo-item').then(itemsBeforeDeletion => {
const initialCount = itemsBeforeDeletion.length;

// Perform the deletion on the first todo item
cy.get('ul.todo-list li.todo-item').first().find('span.remover').click();
// Perform the deletion on the first todo item
cy.get('ul.todo-list li.todo-item').first().find('span.remover').click();

// After the delete action, check that the number of items is now one less
cy.get('ul.todo-list li.todo-item').should('have.length', initialCount - 1);
});
});


Expand All @@ -127,9 +119,7 @@ describe('Testing todo-items', () => {
cy.wrap($item).find('span.remover').click();
});

cy.get('ul.todo-list').should('not.have.descendants', 'li.todo-item');

// Finally, check that no todo items are left
// check that no todo items are left
cy.get('ul.todo-list li.todo-item').should('not.exist');
});

Expand Down

0 comments on commit c8b8096

Please sign in to comment.