Skip to content

Commit

Permalink
fix(deployments): add correct build variable to declared params
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Jan 16, 2025
1 parent 406fe8e commit 801a89d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 16 deletions.
66 changes: 51 additions & 15 deletions cypress/integration/deployment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ context('Deployment', () => {
.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]')
Expand All @@ -50,23 +51,64 @@ context('Deployment', () => {
.should('be.enabled')
.contains('Add')
.click();
it('toast should show', () => {
cy.get('[data-test=alerts]').should('exist').contains('Success');
});

cy.get('[data-test=parameters-list]')
.should('exist')
.children()
.first()
.children()
.last()
.should('contain.text', 'remove');
.should('exist');

cy.get('[data-test=button-parameter-remove-key1]').should(
'contain.text',
'remove',
);
cy.get('[data-test=input-parameter-key]')
.should('exist')
.should('have.value', '');
cy.get('[data-test=input-parameter-value]')
.should('exist')
.should('have.value', '');

cy.get('[data-test=input-parameter-key]').type('key2');
cy.get('[data-test=input-parameter-value]').type('val2');
cy.get('[data-test=button-parameter-add]').click();
cy.get('[data-test=copy-parameter-key2]').should('exist');

cy.get('[data-test=input-parameter-key]').type('key3');
cy.get('[data-test=input-parameter-value]').type('val3');
cy.get('[data-test=button-parameter-add]').click();
cy.get('[data-test=parameters-list]')
.children()
.first()
.contains('remove')
.click();
cy.get('[data-test=parameters-list]')
.should('exist')
.children()
.first()
.should('contain.text', 'key2=val2remove$DEPLOYMENT_PARAMETER_KEY2');
});

it('should handle multiple parameters', () => {
cy.login('/github/octocat/deployments/add');
cy.get('[data-test=input-parameter-key]').type('key4');
cy.get('[data-test=input-parameter-value]').type('val4');
cy.get('[data-test=button-parameter-add]').click();
cy.get('[data-test=input-parameter-key]').type('key5');
cy.get('[data-test=input-parameter-value]').type('val5');
cy.get('[data-test=button-parameter-add]').click();
cy.get('[data-test=parameters-list]').children().should('have.length', 2);
cy.get('[data-test=parameters-list]')
.children()
.first()
.children()
.first()
.should('contain.text', 'key4=val4');
cy.get('[data-test=parameters-list]')
.children()
.last()
.children()
.first()
.should('contain.text', 'key5=val5');
});

it('deployments table should show', () => {
cy.login('/github/octocat/deployments');
cy.get('[data-test=deployments-table]').should('be.visible');
Expand All @@ -83,11 +125,5 @@ context('Deployment', () => {
.should('exist')
.contains('foo=bar');
});
it('deployments table should list parameters copy text', () => {
cy.login('/github/octocat/deployments');
cy.get('[data-test=copy-parameter-foo]')
.should('exist')
.contains('$DEPLOYMENT_PARAMETER_FOO');
});
});
});
3 changes: 2 additions & 1 deletion src/elm/Pages/Org_/Repo_/Deployments/Add.elm
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ view shared route model =
, button
[ class "button"
, class "-outline"
, Util.testAttribute ("button-parameter-remove-" ++ parameter.key)
, onClick <| RemoveParameter parameter
]
[ text "remove"
Expand All @@ -608,7 +609,7 @@ view shared route model =
, class "-white"
, attribute "data-clipboard-text" ("$DEPLOYMENT_PARAMETER_" ++ String.toUpper parameter.key)
, attribute "aria-label" "copy token"
, Util.testAttribute "copy-token"
, Util.testAttribute ("copy-parameter" ++ parameter.key)
]
[ FeatherIcons.copy
|> FeatherIcons.withSize 18
Expand Down

0 comments on commit 801a89d

Please sign in to comment.