From 211808273b3417c45d9d604a5a9cc69495567913 Mon Sep 17 00:00:00 2001 From: Gerard Date: Mon, 25 Dec 2023 02:39:39 +0100 Subject: [PATCH 1/7] create coordinate cypress --- e2e/features/CreateCoordinate.feature | 14 +++++ e2e/steps/create-coordinate.ts | 59 +++++++++++++++++++ .../coordinate-list.component.html | 2 +- src/app/navbar/navbar.component.html | 2 +- 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 e2e/features/CreateCoordinate.feature create mode 100644 e2e/steps/create-coordinate.ts diff --git a/e2e/features/CreateCoordinate.feature b/e2e/features/CreateCoordinate.feature new file mode 100644 index 0000000..5dc9d96 --- /dev/null +++ b/e2e/features/CreateCoordinate.feature @@ -0,0 +1,14 @@ +Feature: Create Coordinate + In order to use the app + As admin + I want to create a coordinate + + Scenario: Create a new coordinate + Given I'm in the homepage logged in as an admin + When I go to the coordinate list page + And I click on add coordinte button + And I fill the form with + | FIELD | VALUE | + | coordinate | 41.40338,2.17403 | + And I click the "Create" button + Then I am redirected to the coordinate list page diff --git a/e2e/steps/create-coordinate.ts b/e2e/steps/create-coordinate.ts new file mode 100644 index 0000000..0a5b653 --- /dev/null +++ b/e2e/steps/create-coordinate.ts @@ -0,0 +1,59 @@ +import { DataTable } from '@cucumber/cucumber'; +import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps'; + + +/* + + Scenario: Create a new coordinate + Given I'm in the homepage logged in as an admin + When I go to the coordinate list page + And I click on add coordinte button + And I fill the form with + | FIELD | VALUE | + | coordinate | 41.40338,2.17403 | + And I click the "Submit" button + Then I am redirected to the coordinate list page + +*/ + +Given(/^I'm in the homepage logged in as an admin$/, function () { + cy.visit('http://localhost:4200'); + cy.get('.nav-link').contains('Login').click(); + cy.get('#username').type('root').blur(); + cy.get('#password').type('password').blur(); + cy.get('button').contains('Submit').click(); +}); +When(/^I go to the coordinate list page$/, function () { + cy.get('.nav-link').contains('Coordinate').click(); + cy.get('.dropdown-item.coordinateListNavbar').click(); +}); +When(/^I click on add coordinte button$/, function () { + cy.get('.createCoordinateBtn').click(); +}); +Then(/^I am redirected to the coordinate list page$/, function () { + cy.url().should('match', /\/coordinates\/\d+/); +}); +/*Then(/^Submit button should be disabled$/, function () { + cy.get('button').contains('Submit').should('be.disabled'); +});*/ +Given(/^I'm in the homepage logged in as an user$/, function () { + cy.visit('http://localhost:4200'); + cy.get('.nav-link').contains('Login').click(); + cy.get('#username').type('demo').blur(); + cy.get('#password').type('password').blur(); + cy.get('button').contains('Submit').click(); +}); +Then(/^I should not see the seed create button$/, function () { + cy.get('#createSeed').should('not.exist'); +}); +When(/^I fill the form with$/, function (table: DataTable) { + table.rows().forEach((pair: string[]) => + cy + .get('#' + pair[0]) + .type(pair[1]) + .blur() + ); +}); +When(/^I click the add common name button$/, function () { + cy.get('#add-commonName').click(); +}); diff --git a/src/app/coordinate/coordinate-list/coordinate-list.component.html b/src/app/coordinate/coordinate-list/coordinate-list.component.html index 6400419..39506ca 100644 --- a/src/app/coordinate/coordinate-list/coordinate-list.component.html +++ b/src/app/coordinate/coordinate-list/coordinate-list.component.html @@ -6,7 +6,7 @@

Coordinates List

diff --git a/src/app/navbar/navbar.component.html b/src/app/navbar/navbar.component.html index 785d2e0..e8c19c4 100644 --- a/src/app/navbar/navbar.component.html +++ b/src/app/navbar/navbar.component.html @@ -34,7 +34,7 @@ From ec5bc127242b0fca50a8ffa7663a6cc8b258206a Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 26 Dec 2023 01:32:58 +0100 Subject: [PATCH 2/7] coordinates cypress create mod --- .../CreateCoordinate.feature | 12 ++++++++- .../{ => coordinates}/create-coordinate.ts | 27 +++---------------- 2 files changed, 14 insertions(+), 25 deletions(-) rename e2e/features/{ => coordinates}/CreateCoordinate.feature (51%) rename e2e/steps/{ => coordinates}/create-coordinate.ts (60%) diff --git a/e2e/features/CreateCoordinate.feature b/e2e/features/coordinates/CreateCoordinate.feature similarity index 51% rename from e2e/features/CreateCoordinate.feature rename to e2e/features/coordinates/CreateCoordinate.feature index 5dc9d96..5e7747a 100644 --- a/e2e/features/CreateCoordinate.feature +++ b/e2e/features/coordinates/CreateCoordinate.feature @@ -11,4 +11,14 @@ Feature: Create Coordinate | FIELD | VALUE | | coordinate | 41.40338,2.17403 | And I click the "Create" button - Then I am redirected to the coordinate list page + Then I am redirected to the coordinate detail page + + + Scenario: Create a new incorrect coordinate + Given I'm in the homepage logged in as an admin + When I go to the coordinate list page + And I click on add coordinte button + And I fill the form with + | FIELD | VALUE | + | coordinate | 300.40338,2.17403 | + Then Create button should be disabled diff --git a/e2e/steps/create-coordinate.ts b/e2e/steps/coordinates/create-coordinate.ts similarity index 60% rename from e2e/steps/create-coordinate.ts rename to e2e/steps/coordinates/create-coordinate.ts index 0a5b653..85aa63a 100644 --- a/e2e/steps/create-coordinate.ts +++ b/e2e/steps/coordinates/create-coordinate.ts @@ -1,21 +1,6 @@ import { DataTable } from '@cucumber/cucumber'; import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps'; - -/* - - Scenario: Create a new coordinate - Given I'm in the homepage logged in as an admin - When I go to the coordinate list page - And I click on add coordinte button - And I fill the form with - | FIELD | VALUE | - | coordinate | 41.40338,2.17403 | - And I click the "Submit" button - Then I am redirected to the coordinate list page - -*/ - Given(/^I'm in the homepage logged in as an admin$/, function () { cy.visit('http://localhost:4200'); cy.get('.nav-link').contains('Login').click(); @@ -23,19 +8,16 @@ Given(/^I'm in the homepage logged in as an admin$/, function () { cy.get('#password').type('password').blur(); cy.get('button').contains('Submit').click(); }); -When(/^I go to the coordinate list page$/, function () { +When(/^I go to the coordinate detail page$/, function () { cy.get('.nav-link').contains('Coordinate').click(); cy.get('.dropdown-item.coordinateListNavbar').click(); }); When(/^I click on add coordinte button$/, function () { cy.get('.createCoordinateBtn').click(); }); -Then(/^I am redirected to the coordinate list page$/, function () { - cy.url().should('match', /\/coordinates\/\d+/); +Then(/^Create button should be disabled$/, function () { + cy.get('button').contains('Create').should('be.disabled'); }); -/*Then(/^Submit button should be disabled$/, function () { - cy.get('button').contains('Submit').should('be.disabled'); -});*/ Given(/^I'm in the homepage logged in as an user$/, function () { cy.visit('http://localhost:4200'); cy.get('.nav-link').contains('Login').click(); @@ -54,6 +36,3 @@ When(/^I fill the form with$/, function (table: DataTable) { .blur() ); }); -When(/^I click the add common name button$/, function () { - cy.get('#add-commonName').click(); -}); From e1be11f5ab7121261e87ccbd93c3a8f9826c17d6 Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 26 Dec 2023 01:33:10 +0100 Subject: [PATCH 3/7] coordinates cypress delete --- .../coordinates/DeleteCoordinate.feature | 19 ++++++++++++++ e2e/steps/coordinates/delete-coordinate.ts | 26 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 e2e/features/coordinates/DeleteCoordinate.feature create mode 100644 e2e/steps/coordinates/delete-coordinate.ts diff --git a/e2e/features/coordinates/DeleteCoordinate.feature b/e2e/features/coordinates/DeleteCoordinate.feature new file mode 100644 index 0000000..5e60916 --- /dev/null +++ b/e2e/features/coordinates/DeleteCoordinate.feature @@ -0,0 +1,19 @@ +Feature: Delete Coordinate + In order to use the app + As admin + I want to delete a coordinate + + Scenario: Delete a new coordinate + Given I'm in the homepage logged in as an admin + And I go to the coordinate list page + And I click on add coordinte button + And I fill the form with + | FIELD | VALUE | + | coordinate | 41.40338,2.17403 | + And I click the "Create" button + And I am redirected to the coordinate detail page + When I click the "Delete" button + Then I am redirected to the coordinate delete page + And I click the "Delete" button + Then I am redirected to the coordinate list page + diff --git a/e2e/steps/coordinates/delete-coordinate.ts b/e2e/steps/coordinates/delete-coordinate.ts new file mode 100644 index 0000000..a8b8a4f --- /dev/null +++ b/e2e/steps/coordinates/delete-coordinate.ts @@ -0,0 +1,26 @@ +import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps'; + +Given(/^I'm in the homepage logged in as an admin$/, function () { + cy.visit('http://localhost:4200'); + cy.get('.nav-link').contains('Login').click(); + cy.get('#username').type('root').blur(); + cy.get('#password').type('password').blur(); + cy.get('button').contains('Submit').click(); +}); +Given(/^I go to the coordinate list page$/, function () { + cy.get('.nav-link').contains('Coordinate').click(); + cy.get('.dropdown-item.coordinateListNavbar').click(); +}); +Given(/^I click on add coordinte button$/, function () { + cy.get('.createCoordinateBtn').click(); +}); +Given(/^I am redirected to the coordinate detail page$/, function () { + cy.url().should('match', /\/coordinates\/\d+/); +}); +When(/^I am redirected to the coordinate delete page$/, function () { + cy.url().should('match', /\/coordinates\/\d+\/delete/); +}); + +Then(/^I am redirected to the coordinate list page$/, function () { + cy.url().should('match', /\/coordinates/); +}); From f3a7ee39be5a6b763bed63e32090580a1746b244 Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 26 Dec 2023 02:06:28 +0100 Subject: [PATCH 4/7] coordinates cypress modify --- .../coordinates/ModifyCoordinate.feature | 21 +++++++++++++++++++ e2e/steps/coordinates/modify-coordinate.ts | 15 +++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 e2e/features/coordinates/ModifyCoordinate.feature create mode 100644 e2e/steps/coordinates/modify-coordinate.ts diff --git a/e2e/features/coordinates/ModifyCoordinate.feature b/e2e/features/coordinates/ModifyCoordinate.feature new file mode 100644 index 0000000..155d6c6 --- /dev/null +++ b/e2e/features/coordinates/ModifyCoordinate.feature @@ -0,0 +1,21 @@ +Feature: Modify Coordinate + In order to use the app + As admin + I want to modify a coordinate + + Scenario: Modify a new coordinate + Given I'm in the homepage logged in as an admin + And I go to the coordinate list page + And I click on add coordinte button + And I fill the form with + | FIELD | VALUE | + | coordinate | 41.40338,2.17403 | + And I click the "Create" button + And I am redirected to the coordinate detail page + And I click the "Edit" button + And I am redirected to the coordinate edit page + When I clear and fill the form with + | FIELD | VALUE | + | coordinate | 42.40338,3.17403 | + And I click the "Update" button + Then I am redirected to the coordinate detail page diff --git a/e2e/steps/coordinates/modify-coordinate.ts b/e2e/steps/coordinates/modify-coordinate.ts new file mode 100644 index 0000000..4f969ca --- /dev/null +++ b/e2e/steps/coordinates/modify-coordinate.ts @@ -0,0 +1,15 @@ +import {Given, When} from 'cypress-cucumber-preprocessor/steps'; +import {DataTable} from "@cucumber/cucumber"; + +Given(/^I am redirected to the coordinate edit page$/, function () { + cy.url().should('match', /\/coordinates\/\d+\/edit/); + +}); + +When('I clear and fill the form with', (table: DataTable) => { + cy.wait(1000); + table.rows().forEach(function (pair: string[]) { + cy.get('#' + pair[0]).clear(); + cy.get('#' + pair[0]).type(pair[1]).blur(); + }); +}); From ee3e2fe15cad028ada6ed5f47e8bf0bf47fe3c25 Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 26 Dec 2023 02:06:34 +0100 Subject: [PATCH 5/7] coordinates cypress read --- e2e/features/coordinates/ReadCoordinate.feature | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 e2e/features/coordinates/ReadCoordinate.feature diff --git a/e2e/features/coordinates/ReadCoordinate.feature b/e2e/features/coordinates/ReadCoordinate.feature new file mode 100644 index 0000000..7922c47 --- /dev/null +++ b/e2e/features/coordinates/ReadCoordinate.feature @@ -0,0 +1,17 @@ +Feature: Read Coordinate + In order to use the app + As admin + I want to read a coordinate + + Scenario: Modify a new coordinate + Given I'm in the homepage logged in as an admin + And I go to the coordinate list page + And I click on add coordinte button + And I fill the form with + | FIELD | VALUE | + | coordinate | 41.40338,2.17403 | + And I click the "Create" button + And I am redirected to the coordinate detail page + And I go to the coordinate list page + When I click the "View" button + Then I am redirected to the coordinate detail page From c4c6340ceec4ab588ccf56c5114cfeef24b01c9c Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 26 Dec 2023 02:06:53 +0100 Subject: [PATCH 6/7] coordinates cypress delete format --- e2e/features/coordinates/DeleteCoordinate.feature | 4 ++-- e2e/steps/coordinates/delete-coordinate.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/features/coordinates/DeleteCoordinate.feature b/e2e/features/coordinates/DeleteCoordinate.feature index 5e60916..21c3bff 100644 --- a/e2e/features/coordinates/DeleteCoordinate.feature +++ b/e2e/features/coordinates/DeleteCoordinate.feature @@ -8,8 +8,8 @@ Feature: Delete Coordinate And I go to the coordinate list page And I click on add coordinte button And I fill the form with - | FIELD | VALUE | - | coordinate | 41.40338,2.17403 | + | FIELD | VALUE | + | coordinate | 41.40338,2.17403 | And I click the "Create" button And I am redirected to the coordinate detail page When I click the "Delete" button diff --git a/e2e/steps/coordinates/delete-coordinate.ts b/e2e/steps/coordinates/delete-coordinate.ts index a8b8a4f..f791431 100644 --- a/e2e/steps/coordinates/delete-coordinate.ts +++ b/e2e/steps/coordinates/delete-coordinate.ts @@ -1,4 +1,4 @@ -import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps'; +import {Given, Then, When} from 'cypress-cucumber-preprocessor/steps'; Given(/^I'm in the homepage logged in as an admin$/, function () { cy.visit('http://localhost:4200'); From 1d373df2f7db71745c3715bcecb1420b24f5e1e9 Mon Sep 17 00:00:00 2001 From: Gerard Date: Tue, 26 Dec 2023 02:06:59 +0100 Subject: [PATCH 7/7] coordinates cypress create format --- e2e/features/coordinates/CreateCoordinate.feature | 8 ++++---- e2e/steps/coordinates/create-coordinate.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/e2e/features/coordinates/CreateCoordinate.feature b/e2e/features/coordinates/CreateCoordinate.feature index 5e7747a..3e49224 100644 --- a/e2e/features/coordinates/CreateCoordinate.feature +++ b/e2e/features/coordinates/CreateCoordinate.feature @@ -8,8 +8,8 @@ Feature: Create Coordinate When I go to the coordinate list page And I click on add coordinte button And I fill the form with - | FIELD | VALUE | - | coordinate | 41.40338,2.17403 | + | FIELD | VALUE | + | coordinate | 41.40338,2.17403 | And I click the "Create" button Then I am redirected to the coordinate detail page @@ -19,6 +19,6 @@ Feature: Create Coordinate When I go to the coordinate list page And I click on add coordinte button And I fill the form with - | FIELD | VALUE | - | coordinate | 300.40338,2.17403 | + | FIELD | VALUE | + | coordinate | 300.40338,2.17403 | Then Create button should be disabled diff --git a/e2e/steps/coordinates/create-coordinate.ts b/e2e/steps/coordinates/create-coordinate.ts index 85aa63a..111eb63 100644 --- a/e2e/steps/coordinates/create-coordinate.ts +++ b/e2e/steps/coordinates/create-coordinate.ts @@ -1,5 +1,5 @@ -import { DataTable } from '@cucumber/cucumber'; -import { Given, When, Then, And } from 'cypress-cucumber-preprocessor/steps'; +import {DataTable} from '@cucumber/cucumber'; +import {Given, Then, When} from 'cypress-cucumber-preprocessor/steps'; Given(/^I'm in the homepage logged in as an admin$/, function () { cy.visit('http://localhost:4200');