Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests for route #35

Closed
wants to merge 14 commits into from
16 changes: 16 additions & 0 deletions e2e/features/Route/CreateRoute.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Feature: Create a new route
In order to use the app
As a user
I want to create a new route

Scenario: Create a new route
Given I'm in the homepage logged in as user with username "demo" and password "password"
When I click on the "Route" menu option
And I fill the form with
| FIELD | VALUE |
| title | testRoute |
| description | That's a test route to make e2e tests |
And Select type "Running" from the dropdown of types
And I click the "Submit" button
Then I've created a new route with creation user "demo", title "testRoute", description "That's a test route to make e2e tests" and type "Running"
Then Delete first route
31 changes: 31 additions & 0 deletions e2e/features/Route/DeleteRoute.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Feature: Delete a route
In order to use the app
As a user
I want to delete a route

Scenario: Delete a route as root user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I logout
Given I log in as "root" with password "password"
Given I go to "List" option in menu "Route"
When I click on delete on first card
Then I confirm the delete


Scenario: Delete a route as normal user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I go to "List" option in menu "Route"
Then I try to click on delete on first card
Then Delete first route

Scenario: Delete a route as not logged user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I logout
Then I try to go to "Route" option in menu

76 changes: 76 additions & 0 deletions e2e/features/Route/EditRoute.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Feature: Edit a route
In order to use the app
As a user
I want to edit a route

Scenario: Check not allowed empty title on route edit
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I go to "List" option in menu "Route"
When I click on edit on first card
Then I try to modify the route title: " ", description: "Modified description for the modified route"
Then Delete first route

Scenario: Edit a route as normal user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I go to "List" option in menu "Route"
When I click on edit on first card
Then I modify the route title: "ModifiedRoute", description: "Modified description for the modified route"
Then Validate modified result values. title: "ModifiedRoute" and description: "Modified description for the modified route"
Then Delete first route

Scenario: Edit a route as normal user by detail
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I go to "List" option in menu "Route"
When I click on detail on first card
When I click on edit on first card
Then I modify the route title: "ModifiedRoute", description: "Modified description for the modified route"
Then Validate modified result values. title: "ModifiedRoute" and description: "Modified description for the modified route"
Then Delete first route

Scenario: Edit a route as normal user after creation
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
When I click on edit on first card
Then I modify the route title: "ModifiedRoute", description: "Modified description for the modified route"
Then Validate modified result values. title: "ModifiedRoute" and description: "Modified description for the modified route"
Then Delete first route

Scenario: Edit a route as root user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I logout
Given I log in as "root" with password "password"
Given I go to "List" option in menu "Route"
Then I try to select edit on first element
Then Delete first route

Scenario: Edit a route as root user by detail
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I logout
Given I log in as "root" with password "password"
Given I go to "List" option in menu "Route"
Then I try to select detail on first element
Then Delete first route

Scenario: Edit a route as not logged user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I logout
Then I try to go to "Route" option in menu
Given I log in as "root" with password "password"
Then Delete first route




33 changes: 33 additions & 0 deletions e2e/features/Route/ReadRoute.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
Feature: Read a route
In order to use the app
As a user
I want to read a route

Scenario: Read a route as root user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I logout
Given I log in as "root" with password "password"
Given I go to "List" option in menu "Route"
When I try to click on detail on first card
Then Delete first route


Scenario: Read a route as normal user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I go to "List" option in menu "Route"
When I click on detail on first card
Then I confirm that i see the route title "testRoute"
Then Delete first route

Scenario: Read a route as not logged user
Given I'm in the homepage
Given I log in as "demo" with password "password"
Given I've a route created with title "testRoute"
Given I logout
Then I try to go to "Route" option in menu
Then Delete first route

34 changes: 34 additions & 0 deletions e2e/steps/Route/create-route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import {Given, When, Then, And} from 'cypress-cucumber-preprocessor/steps';

Given('I\'m in the homepage logged in as user with username {string} and password {string}', (username,password) => {
cy.visit('http://localhost:4200');
cy.get('.nav-link').contains('Login').click();
cy.get('input[name=username]').type(username);
cy.get('input[name=password]').type(password);
cy.get('button[type=submit]').click();
//goToHomepage();
//login(username,password);
});

When('I click on the {string} menu option', (option) => {
//clickMenuOption(option);
cy.get('.nav-link').contains(option).click();
cy.get('#createRoute').click();
});

And('Select type {string} from the dropdown of types', (type) => {
cy.get('#type').select(type);
});

Then('I\'ve created a new route with creation user {string}, title {string}, description {string} and type {string}',(username,title,description,type) => {
checkElementText('#CreatedBy', username);
checkElementText('#Title', title);
checkElementText('#Description', description);
checkElementText('#Type', type);
});

function checkElementText(element:string, text:string) {
cy.get(element)
.invoke('text')
.should('contains', text);
}
67 changes: 67 additions & 0 deletions e2e/steps/Route/delete-route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import {Given, When, Then, And} from 'cypress-cucumber-preprocessor/steps';

function setElementValue(element:string, value:string) {
cy.get(element).type(value).blur();
}

function selectNavigationBar(navigationElement:string, navigationItem:string){
cy.get('.nav-link').contains(navigationElement).click();
cy.get('.nav-item.dropdown.show').find('.dropdown-item').contains(navigationItem).click();
}


Given('I\'ve a route created with title {string}', (routeTitle) => {
selectNavigationBar('Route','Create');
setElementValue('#title', routeTitle);
setElementValue('#description', 'Description');
cy.get('#type').select('Running');
cy.get('#submit').click();
cy.wait(300);
});

Given('I go to {string} option in menu {string}', ( subElement, option) => {
selectNavigationBar(option,subElement);
});

Given('I logout',() => {
cy.get('.nav-link').contains('Logout').click();
});

When('I click on delete on first card', () => {
cy.get('.btn-outline-danger').first().click();
});

///Todo: Fix this step
Then('I confirm the delete', () => {
cy.get('#deleteBtn').click();
});

Then('I try to click on delete on first card', () => {
cy.get('.btn').contains('Delete').should('not.exist');
});

Then('I try to go to {string} option in menu', (element) => {
cy.get('.nav-link').contains(element).should('not.exist');
});




function login(username:string, password:string) {
cy.get('.nav-link').contains('Login').click();
cy.get('#username').type(username).blur();
cy.get('#password').type(password).blur();
cy.get('button').contains('Submit').click();
}

Then('Delete first route', () => {
cy.get('.nav-link').contains('Logout').click();
login('root', 'password');
selectNavigationBar('Route','List');
cy.get('.btn-outline-danger').first().click();
cy.get('#deleteBtn').click();
});




39 changes: 39 additions & 0 deletions e2e/steps/Route/edit-route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {When, Then} from 'cypress-cucumber-preprocessor/steps';

When('I click on edit on first card', () => {
cy.get('.btn-outline-success').first().click();
});

When('I click on detail on first card', () => {
cy.get('.btn-outline-primary').first().click();
});

Then('I modify the route title: {string}, description: {string}',(title,description) => {
cy.wait(1000);
cy.get('#title').clear().type(title);
cy.get('#description').clear().type(description);
cy.get('#submit').click();
});

Then('I try to modify the route title: {string}, description: {string}',(title,description) => {
cy.wait(300);
cy.get('#title').clear().type(title);
cy.get('#description').clear().type(description);
cy.get('#submit').should('be.disabled');
});

Then('Validate modified result values. title: {string} and description: {string}',(title,description) =>{
cy.get('#Title').contains(title);
cy.get('#Description').contains(description);
});

Then('I try to select edit on first element', (element) => {
cy.get('.btn-outline-success').should('not.exist');
});

Then('I try to select detail on first element', (element) => {
cy.get('.btn-outline-primary').should('not.exist');
});



15 changes: 15 additions & 0 deletions e2e/steps/Route/read-route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {Given, When, Then, And} from 'cypress-cucumber-preprocessor/steps';


Then('I try to click on detail on first card', () => {
cy.get('.btn').contains('Detail').should('not.exist');
});

Then('I confirm that i see the route title {string}', (title) => {
cy.get('#Title').contains(title);
});





Loading
Loading