Skip to content

Commit

Permalink
Add stakeholder, stakeholder-groups (#2)
Browse files Browse the repository at this point in the history
* Add stakeholder groups

* Add the title to modals

* Add unit tests

* delete unused code

* rename files

* Add business services test full form

* Move e2e test to custom folders

* Enhance filtering test

* change controls default port to 8081

* Change controls db port to 5433

* Add readme docs

* Add stakeholder groups

* Restore proxy

* add stakeholder groups

* Change tabs order

* add placeholders

* Add select job

* Move select-stakeholders to the shared folder to avoid conflicting order of css

* Add test for stakeholders

* Remove sort by members and groups

* Reduce description width

* Change widh

* Changed 'name' field for to be 'role' (#1)

* Fix test and remove creatable

Co-authored-by: Marco Rizzi <mrizzi@users.noreply.github.com>
  • Loading branch information
carlosthe19916 and mrizzi authored Mar 8, 2021
1 parent d85fb56 commit 9b65a41
Show file tree
Hide file tree
Showing 85 changed files with 4,194 additions and 416 deletions.
60 changes: 57 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ This project depends on other resources:
- Keycloak
- Controls

## Start dependencines with docker-compose
## Start dependencies with docker-compose

Start the dependencies using `docker-compose.yml`:

Expand Down Expand Up @@ -56,7 +56,7 @@ Start the controls' database:
```shell
docker run -d \
--network konveyor --network-alias controls-db \
-p 5432:5432 \
-p 5433:5432 \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=controls_db \
Expand All @@ -68,7 +68,7 @@ Start the controls:
```shell
docker run -d \
--network konveyor --network-alias controls \
-p 8080:8080 \
-p 8081:8080 \
-e QUARKUS_HTTP_PORT=8080 \
-e QUARKUS_DATASOURCE_JDBC_URL=jdbc:postgresql://controls-db:5432/controls_db \
-e QUARKUS_DATASOURCE_USERNAME=user \
Expand All @@ -94,3 +94,57 @@ yarn start
```

You should be able to open http://localhost:3000 and start working on the UI.

# Use tackle-controls in dev mode

Fork/clone the `tackle-controls` repository:

```shell
git clone https://github.com/konveyor/tackle-controls
```

Start a database which will be used by the `tackle-controls` project:

```shell
docker run -d -p 5432:5432 \
-e POSTGRES_USER=username \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=controls_db \
postgres:13.1
```

Move your terminal to the `tackle-controls` repository you cloned and then:

```shell
./mvnw quarkus:dev \
-Dquarkus.http.port=8080 \
-Dquarkus.datasource.username=username \
-Dquarkus.datasource.password=password \
-Dquarkus.datasource.jdbc.url=jdbc:postgresql://localhost:5432/controls_db \
-Dquarkus.oidc.client-id=controls-api \
-Dquarkus.oidc.credentials.secret=secret \
-Dquarkus.oidc.auth-server-url=http://localhost:8180/auth/realms/konveyor
```

Finally, open `src/setupProxy.js` and change the port (from 8081 to 8080) of the `/api/controls` endpoint. It should look like:

```javascript
module.exports = function (app) {
app.use(
"/api/controls",
createProxyMiddleware({
target: "http://localhost:8080",
changeOrigin: true,
pathRewrite: {
"^/api/controls": "/controls",
},
})
);
};
```

You need to restart the local ui server. Stop the ui server and then execute:

```shell
yarn start
```
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ context("Test business service list", () => {
method: "POST",
headers: headers,
body: {
name: `any`,
email: `email${i}@domain.com`,
displayName: `stakeholder${i}`,
},
url: `${Cypress.env("controls_base_url")}/stakeholder`,
Expand Down Expand Up @@ -97,19 +97,56 @@ context("Test business service list", () => {
cy.wait("@apiCheck");
cy.get("tbody > tr").should("have.length", 10);

// Apply first filter
// Apply first filter: 'byName'
cy.get("input[aria-label='filter-text']").type("service12");
cy.get("button[aria-label='search']").click();

cy.wait("@apiCheck");
cy.get("tbody > tr").should("have.length", 1).contains("service12");

// Apply second filter
// Apply second filter: 'byName'
cy.get("input[aria-label='filter-text']").type("service5");
cy.get("button[aria-label='search']").click();

cy.wait("@apiCheck");
cy.get("tbody > tr").should("have.length", 2).contains("service5");
cy.get("tbody > tr")
.should("have.length", 2)
.should("contain", "service12")
.should("contain", "service5");

// Apply second filter: 'byOwner'
cy.get(".pf-c-toolbar button.pf-c-dropdown__toggle").click();
cy.get(".pf-c-dropdown__menu button.pf-c-dropdown__menu-item")
.eq(2)
.click();

cy.get("input[aria-label='filter-text']").type("stakeholder1");
cy.get("button[aria-label='search']").click();

cy.wait("@apiCheck");
cy.get("tbody > tr")
.should("have.length", 1)
.should("contain", "service12");

// Remove filter 'byOwner' chip
cy.get(".pf-c-chip button.pf-c-button").eq(2).click();

cy.wait("@apiCheck");
cy.get("tbody > tr")
.should("have.length", 2)
.should("contain", "service12")
.should("contain", "service5");

// Clear all filters
cy.get(".pf-c-toolbar__item > button.pf-m-link")
.contains("Clear all filters")
.click({ force: true });

cy.wait("@apiCheck");
cy.get("tbody > tr")
.should("have.length", 10)
.should("contain", "service1")
.should("contain", "service7");
});

it("Pagination", () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/// <reference types="cypress" />

context("Test NewBusinessService", () => {
beforeEach(() => {
cy.kcLogout();
cy.kcLogin("alice").as("tokens");

cy.get("@tokens").then((tokens) => {
const headers = {
"Content-Type": "application/json",
Accept: "application/hal+json",
Authorization: "Bearer " + tokens.access_token,
};

// Delete all business services
cy.request({
method: "GET",
headers: headers,
url: `${Cypress.env("controls_base_url")}/business-service?size=1000`,
})
.then((result) => {
result.body._embedded["business-service"].forEach((e) => {
cy.request({
method: "DELETE",
headers: headers,
url: `${Cypress.env("controls_base_url")}/business-service/${
e.id
}`,
});
});
})

// Delete all stakeholders
.then(() => {
cy.request({
method: "GET",
headers: headers,
url: `${Cypress.env("controls_base_url")}/stakeholder?size=1000`,
});
})
.then((response) => {
response.body._embedded["stakeholder"].forEach((elem) => {
cy.request({
method: "DELETE",
headers: headers,
url: `${Cypress.env("controls_base_url")}/stakeholder/${elem.id}`,
});
});
})

// Create stakeholders
.then(() => {
for (let i = 1; i <= 12; i++) {
cy.request({
method: "POST",
headers: headers,
body: {
email: `email${i}@domain.com`,
displayName: `stakeholder${i}`,
},
url: `${Cypress.env("controls_base_url")}/stakeholder`,
});
}
});
});
});

it("Minimun data", () => {
cy.intercept({
method: "GET",
url: "/api/controls/business-service",
}).as("apiCheck");

cy.visit("/controls/business-services");

// Open modal
cy.get("button[aria-label='create-business-service']").click();

// Verify primary button is disabled
cy.get("button[aria-label='submit']").should("be.disabled");

// Fill form
cy.get("input[name='name']").type("my business service");

cy.get("button[aria-label='submit']").should("not.be.disabled");
cy.get("form").submit();

cy.wait("@apiCheck");

// Verify table
cy.get("tbody > tr")
.should("have.length", 1)
.contains("my business service");
});

it("Fill all fields", () => {
cy.intercept({
method: "GET",
url: "/api/controls/business-service",
}).as("apiCheckBusinessService");

cy.intercept({
method: "GET",
url: "/api/controls/stakeholder",
}).as("apiCheckStakeholder");

cy.visit("/controls/business-services");

// Open modal
cy.get("button[aria-label='create-business-service']").click();

// Verify primary button is disabled
cy.get("button[aria-label='submit']").should("be.disabled");

// Fill form
cy.wait("@apiCheckStakeholder");
cy.get("input[name='name']").type("my name");
cy.get("textarea[name='description']").type("my description");

cy.get("button.pf-c-select__toggle-button").click();
cy.get("button.pf-c-select__menu-item")
.eq(0)
.click({ waitForAnimations: false });

cy.get("button[aria-label='submit']").should("not.be.disabled");
cy.get("form").submit();

cy.wait("@apiCheckBusinessService");

// Verify table
cy.get("tbody > tr")
.should("have.length", 1)
.should("contain", "my name")
.and("contain", "my description")
.and("contain", "stakeholder1");
});
});
Loading

0 comments on commit 9b65a41

Please sign in to comment.