From f879bcafc6d2ee87828140f887c4e5fe6dfaf28e Mon Sep 17 00:00:00 2001 From: davidvader Date: Thu, 12 Sep 2024 13:24:13 -0500 Subject: [PATCH] enhance: add payload.parameters to deployments table --- cypress/fixtures/deployments_5.json | 69 ++++++++++++++++++++++++ cypress/integration/deployment.spec.js | 39 ++++++++++++-- src/elm/Pages/Org_/Repo_/Deployments.elm | 18 +++++++ 3 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 cypress/fixtures/deployments_5.json diff --git a/cypress/fixtures/deployments_5.json b/cypress/fixtures/deployments_5.json new file mode 100644 index 000000000..f7bddddb5 --- /dev/null +++ b/cypress/fixtures/deployments_5.json @@ -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": {} + } +] diff --git a/cypress/integration/deployment.spec.js b/cypress/integration/deployment.spec.js index fbaddf174..a9c63b2f8 100644 --- a/cypress/integration/deployment.spec.js +++ b/cypress/integration/deployment.spec.js @@ -3,7 +3,7 @@ */ context('Deployment', () => { - context('server returning deployment', () => { + context('server returning deployments', () => { beforeEach(() => { cy.server(); cy.route( @@ -11,16 +11,33 @@ context('Deployment', () => { '*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() @@ -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'); + }); }); }); diff --git a/src/elm/Pages/Org_/Repo_/Deployments.elm b/src/elm/Pages/Org_/Repo_/Deployments.elm index 23530f7d8..c6a168872 100644 --- a/src/elm/Pages/Org_/Repo_/Deployments.elm +++ b/src/elm/Pages/Org_/Repo_/Deployments.elm @@ -20,6 +20,7 @@ import Html , a , div , span + , td , text , tr ) @@ -29,6 +30,7 @@ import Html.Attributes , class , href , rows + , scope ) import Http import Http.Detailed @@ -369,6 +371,7 @@ tableHeaders = , ( Nothing, "commit" ) , ( Nothing, "ref" ) , ( Nothing, "description" ) + , ( Nothing, "parameters" ) , ( Nothing, "builds" ) , ( Nothing, "created by" ) , ( Nothing, "created at" ) @@ -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 = []