Skip to content

Commit

Permalink
Merge pull request #107 from tillias/dev
Browse files Browse the repository at this point in the history
#106 #96 Refactoring and final e2e tests
  • Loading branch information
tillias authored Nov 11, 2020
2 parents e58b8e8 + 88b4695 commit bdaff0e
Show file tree
Hide file tree
Showing 32 changed files with 599 additions and 209 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=microcatalog&metric=coverage)](https://sonarcloud.io/dashboard?id=microcatalog)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=microcatalog&metric=alert_status)](https://sonarcloud.io/dashboard?id=microcatalog)
[![microservice-catalog](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/simple/ge12oz&style=flat&logo=cypress)](https://dashboard.cypress.io/projects/ge12oz/runs)
[![microservice-catalog](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/count/ge12oz&style=flat&logo=cypress)](https://dashboard.cypress.io/projects/ge12oz/runs)
[![microservice-catalog](https://img.shields.io/endpoint?url=https://dashboard.cypress.io/badge/count/ge12oz/master&style=flat-square&logo=cypress)](https://dashboard.cypress.io/projects/ge12oz/runs)
[![This project is using Percy.io for visual regression testing.](https://percy.io/static/images/percy-badge.svg)](https://percy.io/bb9225f6/microservice-catalog)
[![Docker Image Version (latest by date)](https://img.shields.io/docker/v/tillias/microcatalog)](https://hub.docker.com/r/tillias/microcatalog)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
Expand Down
4 changes: 2 additions & 2 deletions cypress/integration/catalog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe.only('catalog and search', () => {
cy.get('.btn-primary:nth-child(1)').click();

cy.get('.card-body').should('have.length', 1);
cy.get('h6').should('have.text', 'This is custom old service description\n');
cy.get('h6').contains('This is custom old service description');

})

Expand Down Expand Up @@ -115,7 +115,7 @@ describe.only('catalog and search', () => {
cy.get('.btn-primary:nth-child(1)').click();

cy.get('.card-body').should('have.length', 1);
cy.get('h6').should('have.text', 'This is custom old service description\n');
cy.get('h6').contains('This is custom old service description');
})

it('advanced filter case insensitive search by swagger url', function () {
Expand Down
142 changes: 114 additions & 28 deletions cypress/integration/dependency-dashboard-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,34 @@ describe('dependency dashboard', () => {
team: {
id: 1,
}
});
})
}

function createDependencyUI(source: string, target: string) {
createMicroserviceRequest(source);
createMicroserviceRequest(target);

cy.visit('/dashboard/dependencies');

cy.get(':nth-child(6) > .btn').click();

cy.get(':nth-child(2) > :nth-child(2) > jhi-microservice-search > .d-flex > .form-control')
.type(firstMicroservice);
cy.get('.ngb-highlight').click();

cy.get(':nth-child(3) > :nth-child(2) > jhi-microservice-search > .d-flex > .form-control')
.type(secondMicroservice);
cy.get('.ngb-highlight').click();

cy.server();
cy.route('GET', '/api/dependencies').as('apiRequest');

cy.get('.btn-primary').click();

// click on firstMicroservice and validate edge is added in edge legend
cy.get('ngx-spinner').should('not.be.visible');

cy.wait('@apiRequest');
}

it('create microservice', function () {
Expand Down Expand Up @@ -110,64 +137,123 @@ describe('dependency dashboard', () => {
})

it('create dependency', function () {
createDependencyUI(firstMicroservice, secondMicroservice);

cy.get('canvas').click();
cy.get('canvas').click(331, 303, {force: true});

cy.get('jhi-edge-legend.ng-star-inserted > :nth-child(2) > .text-primary > a')
.should('have.text', newDependency);
})

it('delete dependency', function () {
createMicroserviceRequest(firstMicroservice);
createMicroserviceRequest(secondMicroservice);

cy.createDependency(newDependency, firstMicroservice, secondMicroservice);

cy.visit('/dashboard/dependencies');

cy.get('canvas').click();
cy.get('canvas').click(331, 303, {force: true});

cy.get(':nth-child(8) > .btn').click();

cy.get('#jhi-confirm-delete-dependency').click();

cy.get('canvas').click();
cy.get('canvas').click(269, 247, {force: true});

cy.get('jhi-edge-legend.ng-star-inserted > :nth-child(1) > h5').should('not.be.visible');
})

it('create dependency with start selected', function () {

createMicroserviceRequest(firstMicroservice);
createMicroserviceRequest(secondMicroservice);

cy.visit('/dashboard/dependencies');

cy.get('canvas').click();
cy.get('canvas').click(412, 176, {force: true}); // firstMicroservice

cy.get(':nth-child(6) > .btn').click(); // create dependency

cy.get(':nth-child(1) > .text-primary').should('has.text', 'TestService1 -> undefined');
})

it('create dependency with start and end selected', function () {

createMicroserviceRequest(firstMicroservice);
createMicroserviceRequest(secondMicroservice);

cy.visit('/dashboard/dependencies');

cy.get('canvas').click();
cy.get('canvas').click(412, 176, {force: true}); // firstMicroservice
cy.get('canvas').click(261, 245, {force: true, ctrlKey: true}); // secondMicroservice

cy.get(':nth-child(6) > .btn').click(); // create dependency

cy.get(':nth-child(1) > .text-primary').should('has.text', 'TestService1 -> TestService2');
cy.get(':nth-child(4) > .btn-warning').click(); // swap
cy.get(':nth-child(1) > .text-primary').should('has.text', 'TestService2 -> TestService1');
})

it('dependency having same source and target is not allowed', function () {
createMicroserviceRequest(firstMicroservice);
cy.visit('/dashboard/dependencies');
cy.get(':nth-child(6) > .btn').click();

cy.get(':nth-child(2) > :nth-child(2) > jhi-microservice-search > .d-flex > .form-control')
.type(firstMicroservice);
cy.get('.ngb-highlight').click();

cy.get(':nth-child(3) > :nth-child(2) > jhi-microservice-search > .d-flex > .form-control')
.type(secondMicroservice);
.type(firstMicroservice);
cy.get('.ngb-highlight').click();

cy.server();
cy.route('GET', '/api/microservices').as('apiRequest');
cy.route('POST', '/api/dependencies').as('apiRequest');

cy.get('.btn-primary').click();

// click on firstMicroservice and validate edge is added in edge legend
cy.get('ngx-spinner').should('not.be.visible');


cy.wait('@apiRequest');

cy.get('canvas').click();
cy.get('canvas').click(331, 303, {force: true});
cy.wait('@apiRequest').then((response) => {
expect(response.status).to.eq(422);
});

cy.get('jhi-edge-legend.ng-star-inserted > :nth-child(2) > .text-primary > a')
.should('have.text', newDependency);
cy.get('.alert');
})

xit('delete dependency', function () {
cy.visit('/dashboard/dependencies');
it('duplicate dependency now allowed', function () {

// TODO
})
createMicroserviceRequest(firstMicroservice);
createMicroserviceRequest(secondMicroservice);

xit('create dependency with start selected', function () {
cy.createDependency(newDependency, firstMicroservice, secondMicroservice);

cy.visit('/dashboard/dependencies');

// TODO
})
// create same dependency once again
cy.get(':nth-child(6) > .btn').click();

xit('create dependency with start and end selected', function () {
cy.get(':nth-child(2) > :nth-child(2) > jhi-microservice-search > .d-flex > .form-control')
.type(firstMicroservice);
cy.get('.ngb-highlight').click();

cy.visit('/dashboard/dependencies');
cy.get(':nth-child(3) > :nth-child(2) > jhi-microservice-search > .d-flex > .form-control')
.type(secondMicroservice);
cy.get('.ngb-highlight').click();

// TODO
})
cy.server();
cy.route('POST', '/api/dependencies').as('apiRequest');

xit('create dependency with swap', function () {
cy.get('.btn-primary').click(); // create dependency

cy.visit('/dashboard/dependencies');
cy.wait('@apiRequest').then((response) => {
expect(response.status).to.eq(422);
});

// TODO
cy.get('.alert');
})

})
13 changes: 9 additions & 4 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// add new command to the existing Cypress interface

declare namespace Cypress {
interface Chainable {
login: typeof login
Expand Down Expand Up @@ -60,10 +61,14 @@ function deleteMicroservice(name: string): void {
});
}

function createDependency(dependency: any): void {
function createDependency(name: string, source: string, target: string): void {
cy.request({
url: '/api/dependencies',
body: dependency,
url: '/api/dependencies/with/name',
body: {
dependencyName: name,
sourceName: source,
targetName: target
},
method: 'POST',
headers: {
Authorization: getBearerHeader()
Expand All @@ -87,5 +92,5 @@ Cypress.Commands.add('loginUser', () => loginUser());
Cypress.Commands.add('logout', () => logout());
Cypress.Commands.add('createMicroservice', (body) => createMicroservice(body));
Cypress.Commands.add('deleteMicroservice', (name) => deleteMicroservice(name));
Cypress.Commands.add('createDependency', (body) => createDependency(body));
Cypress.Commands.add('createDependency', (name, source, target) => createDependency(name, source, target));
Cypress.Commands.add('deleteDependency', (name) => deleteDependency(name));
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.microcatalog.domain.custom;

import com.github.microcatalog.domain.Microservice;
import com.github.microcatalog.service.dto.custom.MicroserviceDto;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

Expand All @@ -15,7 +15,7 @@
public class ReleasePath {
private Instant createdOn;
private List<ReleaseGroup> groups = new ArrayList<>();
private Microservice target;
private MicroserviceDto target;

public Instant getCreatedOn() {
return createdOn;
Expand Down Expand Up @@ -53,16 +53,16 @@ public void setGroups(List<ReleaseGroup> releaseGroups) {
this.groups = releaseGroups;
}

public Microservice getTarget() {
public MicroserviceDto getTarget() {
return target;
}

public ReleasePath target(Microservice microservice) {
public ReleasePath target(MicroserviceDto microservice) {
this.target = microservice;
return this;
}

public void setTarget(Microservice microservice) {
public void setTarget(MicroserviceDto microservice) {
this.target = microservice;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.github.microcatalog.domain.custom;

import com.github.microcatalog.domain.Microservice;
import com.github.microcatalog.service.dto.custom.MicroserviceDto;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

Expand All @@ -11,32 +11,32 @@
*/
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ReleaseStep {
private Microservice workItem;
private List<Microservice> parentWorkItems;
private MicroserviceDto workItem;
private List<MicroserviceDto> parentWorkItems;

public Microservice getWorkItem() {
public MicroserviceDto getWorkItem() {
return workItem;
}

public ReleaseStep workItem(Microservice microservice) {
public ReleaseStep workItem(MicroserviceDto microservice) {
this.workItem = microservice;
return this;
}

public void setWorkItem(Microservice microservice) {
public void setWorkItem(MicroserviceDto microservice) {
this.workItem = microservice;
}

public List<Microservice> getParentWorkItems() {
public List<MicroserviceDto> getParentWorkItems() {
return parentWorkItems;
}

public ReleaseStep parentWorkItems(List<Microservice> microservices) {
public ReleaseStep parentWorkItems(List<MicroserviceDto> microservices) {
this.parentWorkItems = microservices;
return this;
}

public void setParentWorkItems(List<Microservice> parentWorkItems) {
public void setParentWorkItems(List<MicroserviceDto> parentWorkItems) {
this.parentWorkItems = parentWorkItems;
}
}
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
package com.github.microcatalog.domain.custom.impact.analysis;

import com.github.microcatalog.domain.Microservice;
import com.github.microcatalog.service.dto.custom.MicroserviceDto;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import java.util.List;

@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Item {
private Microservice target;
private List<Microservice> siblings;
private MicroserviceDto target;
private List<MicroserviceDto> siblings;

public Microservice getTarget() {
public MicroserviceDto getTarget() {
return target;
}

public Item target(Microservice microservice) {
public Item target(MicroserviceDto microservice) {
this.target = microservice;
return this;
}

public void setTarget(Microservice microservice) {
public void setTarget(MicroserviceDto microservice) {
this.target = microservice;
}

public List<Microservice> getSiblings() {
public List<MicroserviceDto> getSiblings() {
return siblings;
}

public Item siblings(List<Microservice> siblings) {
public Item siblings(List<MicroserviceDto> siblings) {
this.siblings = siblings;
return this;
}

public void setSiblings(List<Microservice> siblings) {
public void setSiblings(List<MicroserviceDto> siblings) {
this.siblings = siblings;
}
}
Loading

0 comments on commit bdaff0e

Please sign in to comment.