Skip to content

Commit

Permalink
enhance: add payload.parameters to deployments table (#818)
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 authored Sep 12, 2024
1 parent 7d63d00 commit 1db0fe8
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 3 deletions.
69 changes: 69 additions & 0 deletions cypress/fixtures/deployments_5.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[
{
"id": 5051,
"number": 1,
"repo_id": 1,
"url": "https://github.com/github/octocat.git/deployments/5051",
"user": "user",
"commit": "ce729516b279c7d7e66012387b39a8c13463fac5",
"ref": "refs/heads/main",
"task": "deploy:vela",
"target": "production",
"description": "Deployment request from Vela",
"payload": {
"foo": "bar"
}
},
{
"id": 5052,
"number": 2,
"repo_id": 1,
"url": "https://github.com/github/octocat.git/deployments/5052",
"user": "user",
"commit": "ce729516b279c7d7e66012387b39a8c13463fac5",
"ref": "refs/heads/main",
"task": "deploy:vela",
"target": "production",
"description": "Deployment request from Vela",
"payload": {}
},
{
"id": 5053,
"number": 3,
"repo_id": 1,
"url": "https://github.com/github/octocat.git/deployments/5053",
"user": "user",
"commit": "ce729516b279c7d7e66012387b39a8c13463fac5",
"ref": "refs/heads/main",
"task": "deploy:vela",
"target": "production",
"description": "Deployment request from Vela",
"payload": {}
},
{
"id": 5054,
"number": 4,
"repo_id": 1,
"url": "https://github.com/github/octocat.git/deployments/5054",
"user": "user",
"commit": "ce729516b279c7d7e66012387b39a8c13463fac5",
"ref": "refs/heads/main",
"task": "deploy:vela",
"target": "production",
"description": "Deployment request from Vela",
"payload": {}
},
{
"id": 5055,
"number": 5,
"repo_id": 1,
"url": "https://github.com/github/octocat.git/deployments/5055",
"user": "user",
"commit": "ce729516b279c7d7e66012387b39a8c13463fac5",
"ref": "refs/heads/main",
"task": "deploy:vela",
"target": "production",
"description": "Deployment request from Vela",
"payload": {}
}
]
39 changes: 36 additions & 3 deletions cypress/integration/deployment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,41 @@
*/

context('Deployment', () => {
context('server returning deployment', () => {
context('server returning deployments', () => {
beforeEach(() => {
cy.server();
cy.route(
'POST',
'*api/v1/deployments/github/octocat',
'fixture:deployment.json',
);
cy.login('/github/octocat/deployments/add');
cy.route(
'GET',
'*api/v1/deployments/github/octocat*',
'fixture:deployments_5.json',
);
cy.route('GET', '*api/v1/hooks/github/octocat*', []);
cy.route('GET', '*api/v1/user', 'fixture:user_admin.json');
cy.route(
'GET',
'*api/v1/repos/github/octocat',
'fixture:repository.json',
);
cy.route(
'GET',
'*api/v1/repos/github/octocat/builds*',
'fixture:builds_5.json',
);
});

it('add parameter button should be disabled', () => {
cy.login('/github/octocat/deployments/add');
cy.get('[data-test=button-parameter-add]')
.should('exist')
.should('not.be.enabled')
.contains('Add');
});
it('add parameter should work as intended', () => {
cy.login('/github/octocat/deployments/add');
cy.get('[data-test=parameters-list]')
.should('exist')
.children()
Expand Down Expand Up @@ -50,5 +67,21 @@ context('Deployment', () => {
.should('exist')
.should('have.value', '');
});
it('deployments table should show', () => {
cy.login('/github/octocat/deployments');
cy.get('[data-test=deployments-table]').should('be.visible');
});
it('deployments table should contain deployments', () => {
cy.login('/github/octocat/deployments');
cy.get('[data-test=deployments-row]')
.should('exist')
.contains('Deployment request from Vela');
});
it('deployments table should list of parameters', () => {
cy.login('/github/octocat/deployments');
cy.get('[data-test=cell-list-item-parameters]')
.should('exist')
.contains('foo=bar');
});
});
});
18 changes: 18 additions & 0 deletions src/elm/Pages/Org_/Repo_/Deployments.elm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import Html
, a
, div
, span
, td
, text
, tr
)
Expand All @@ -29,6 +30,7 @@ import Html.Attributes
, class
, href
, rows
, scope
)
import Http
import Http.Detailed
Expand Down Expand Up @@ -369,6 +371,7 @@ tableHeaders =
, ( Nothing, "commit" )
, ( Nothing, "ref" )
, ( Nothing, "description" )
, ( Nothing, "parameters" )
, ( Nothing, "builds" )
, ( Nothing, "created by" )
, ( Nothing, "created at" )
Expand Down Expand Up @@ -432,6 +435,21 @@ viewDeployment shared repo deployment =
[ text deployment.description
]
}
, td
[ attribute "data-label" "parameters"
, scope "row"
, class "break-word"
]
[ Components.Table.viewListCell
{ dataLabel = "parameters"
, items =
deployment.payload
|> Maybe.withDefault []
|> List.map (\parameter -> parameter.key ++ "=" ++ parameter.value)
, none = "no parameters"
, itemWrapperClassList = []
}
]
, Components.Table.viewItemCell
{ dataLabel = "builds"
, parentClassList = []
Expand Down

0 comments on commit 1db0fe8

Please sign in to comment.