Skip to content

Commit

Permalink
Merge branch 'main' into fix/handle-new-pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
wass3r authored Feb 25, 2025
2 parents 0142d9b + fa30de5 commit 4800579
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 5 deletions.
40 changes: 40 additions & 0 deletions cypress/integration/deployment.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,46 @@ context('Deployment', () => {
});
});

it('parameter of bar=foo properly prepopulates deployment form', () => {
cy.login(
'/github/octocat/deployments/add?description=Deployment%20request%20from%20Vela&parameters=bar%253Dfoo&ref=master&target=production&task=deploy%3Avela',
);
cy.get('[data-test=parameters-list]')
.should('exist')
.children()
.first()
.should('contain.text', 'bar=foo');
});

it('parameter of foo=bar=cat properly prepopulates deployment form', () => {
cy.login(
'/github/octocat/deployments/add?description=Deployment%20request%20from%20Vela&parameters=foo%253Dbar%253Dcat&ref=master&target=production&task=deploy%3Avela',
);
cy.get('[data-test=parameters-list]')
.should('exist')
.children()
.first()
.should('contain.text', 'foo=bar=cat');
});

it('multiple parameters properly prepopulate deployment form', () => {
cy.login(
'/github/octocat/deployments/add?description=Deployment%20request%20from%20Vela&parameters=bar%253Dfoo,foo%253Dbar%253Dcat&ref=master&target=production&task=deploy%3Avela',
);

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

cy.get('[data-test=parameters-list]')
.should('exist')
.children()
.eq(1)
.should('contain.text', 'bar=foo');
});

it('deployments table should show', () => {
cy.login('/github/octocat/deployments');
cy.get('[data-test=deployments-table]').should('be.visible');
Expand Down
3 changes: 3 additions & 0 deletions cypress/integration/status_workers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ context('Workers', () => {
it('should show status', () => {
cy.get('@firstWorker').within(() => {
cy.get('[data-test=cell-status]').contains('busy');
cy.get('[data-test=cell-running-builds]').contains(
'github/octocat/1',
);
});
});
context('error', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/elm/Pages/Org_/Repo_/Deployments/Add.elm
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ init shared route () =
|> Maybe.withDefault ""
|> String.split ","
|> List.filterMap Url.percentDecode
|> List.map (String.split "=")
|> List.map (Util.splitFirst "=")
|> List.filterMap
(\d ->
case d of
Expand Down
8 changes: 4 additions & 4 deletions src/elm/Pages/Status/Workers.elm
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ viewWorker shared worker =
]
}
, Components.Table.viewItemCell
{ dataLabel = "running builds"
{ dataLabel = "running-builds"
, parentClassList = []
, itemClassList = []
, children =
Expand Down Expand Up @@ -384,9 +384,9 @@ viewWorkerBuildsLinks worker =
(build.link
|> String.split "/"
|> List.reverse
|> List.head
|> Maybe.withDefault ""
|> String.append "#"
|> List.take 3
|> List.reverse
|> String.join "/"
)
]
)
Expand Down
20 changes: 20 additions & 0 deletions src/elm/Utils/Helpers.elm
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ module Utils.Helpers exposing
, pageToString
, relativeTimeNoSeconds
, secondsToMillis
, splitFirst
, stringToAllowlist
, stringToMaybe
, successful
Expand Down Expand Up @@ -128,6 +129,25 @@ testAttribute tag =
attribute "data-test" tag


{-| splitFirst : splits a string at the first occurrence of delimiter and returns a list of strings.
-}
splitFirst : String -> String -> List String
splitFirst delimiter str =
case String.indexes delimiter str of
[] ->
[ str ]

index :: _ ->
let
before =
String.left index str

after =
String.dropLeft (index + String.length delimiter) str
in
[ before, after ]


{-| secondsToMillis : converts seconds to milliseconds.
-}
secondsToMillis : Int -> Int
Expand Down

0 comments on commit 4800579

Please sign in to comment.