-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: more cypress tests and code improvements
- Loading branch information
Showing
9 changed files
with
522 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
{ | ||
"build_id": 4, | ||
"nodes": { | ||
"0": { | ||
"id": 0, | ||
"cluster": 0, | ||
"name": "postgres", | ||
"status": "pending", | ||
"started_at": 1698069639, | ||
"finished_at": 1698069655, | ||
"steps": [] | ||
}, | ||
"1": { | ||
"id": 1, | ||
"cluster": 0, | ||
"name": "kafka", | ||
"status": "running", | ||
"started_at": 1698069638, | ||
"finished_at": 1698069655, | ||
"steps": [] | ||
}, | ||
"2": { | ||
"id": 2, | ||
"cluster": 0, | ||
"name": "zookeeper", | ||
"status": "canceled", | ||
"started_at": 1698069638, | ||
"finished_at": 1698069655, | ||
"steps": [] | ||
}, | ||
"3": { | ||
"id": 3, | ||
"cluster": 1, | ||
"name": "init", | ||
"status": "success", | ||
"started_at": 1697565012, | ||
"finished_at": 1697565012, | ||
"steps": [ | ||
{ | ||
"id": 2484, | ||
"build_id": 1, | ||
"repo_id": 1, | ||
"number": 1, | ||
"name": "init", | ||
"image": "#init", | ||
"stage": "", | ||
"status": "success", | ||
"error": "", | ||
"exit_code": 0, | ||
"created": 1697565011, | ||
"started": 1697565012, | ||
"finished": 1697565012, | ||
"host": "worker", | ||
"runtime": "docker", | ||
"distribution": "linux" | ||
} | ||
] | ||
}, | ||
"4": { | ||
"id": 4, | ||
"cluster": 1, | ||
"name": "clone", | ||
"status": "failure", | ||
"started_at": 1697565012, | ||
"finished_at": 1697565017, | ||
"steps": [ | ||
{ | ||
"id": 2485, | ||
"build_id": 1, | ||
"repo_id": 1, | ||
"number": 2, | ||
"name": "clone", | ||
"image": "target/vela-git:v0.8.0@sha256:02de004ae9dbf184c70039cb9ce431c31d6e7580eb9e6ec64a97ebf108aa65cb", | ||
"stage": "", | ||
"status": "failure", | ||
"error": "", | ||
"exit_code": 0, | ||
"created": 1697565011, | ||
"started": 1697565012, | ||
"finished": 1697565017, | ||
"host": "worker", | ||
"runtime": "docker", | ||
"distribution": "linux" | ||
} | ||
] | ||
}, | ||
"5": { | ||
"id": 5, | ||
"cluster": 1, | ||
"name": "stage-a", | ||
"status": "killed", | ||
"started_at": 1697565017, | ||
"finished_at": 1697565028, | ||
"steps": [ | ||
{ | ||
"id": 2486, | ||
"build_id": 1, | ||
"repo_id": 1, | ||
"number": 3, | ||
"name": "sleep 10", | ||
"image": "golang:latest", | ||
"stage": "", | ||
"status": "killed", | ||
"error": "", | ||
"exit_code": 0, | ||
"created": 1697565011, | ||
"started": 1697565017, | ||
"finished": 1697565028, | ||
"host": "worker", | ||
"runtime": "docker", | ||
"distribution": "linux" | ||
} | ||
] | ||
}, | ||
"6": { | ||
"id": 6, | ||
"cluster": 1, | ||
"name": "stage-b", | ||
"status": "running", | ||
"started_at": 1697565017, | ||
"finished_at": 1697565028, | ||
"steps": [ | ||
{ | ||
"id": 2487, | ||
"build_id": 1, | ||
"repo_id": 1, | ||
"number": 4, | ||
"name": "sleep 10", | ||
"image": "golang:latest", | ||
"stage": "", | ||
"status": "running", | ||
"error": "", | ||
"exit_code": 0, | ||
"created": 1697565011, | ||
"started": 1697565017, | ||
"finished": 0, | ||
"host": "worker", | ||
"runtime": "docker", | ||
"distribution": "linux" | ||
} | ||
] | ||
} | ||
}, | ||
"edges": [ | ||
{ | ||
"cluster": 0, | ||
"source": 0, | ||
"destination": 1, | ||
"status": "canceled" | ||
}, | ||
{ | ||
"cluster": 0, | ||
"source": 1, | ||
"destination": 2, | ||
"status": "canceled" | ||
}, | ||
{ | ||
"cluster": 0, | ||
"source": 2, | ||
"destination": 3, | ||
"status": "canceled" | ||
}, | ||
{ | ||
"cluster": 1, | ||
"source": 4, | ||
"destination": 5, | ||
"status": "success" | ||
}, | ||
{ | ||
"cluster": 1, | ||
"source": 5, | ||
"destination": 6, | ||
"status": "success" | ||
}, | ||
{ | ||
"cluster": 1, | ||
"source": 3, | ||
"destination": 4, | ||
"status": "success" | ||
}, | ||
{ | ||
"cluster": 1, | ||
"source": 4, | ||
"destination": 5, | ||
"status": "success" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,169 @@ | ||
/* | ||
* Copyright (c) 2022 Target Brands, Inc. All rights reserved. | ||
* Use of this source code is governed by the LICENSE file in this repository. | ||
*/ | ||
|
||
context('Build Graph', () => { | ||
context('logged in and server returning build graph error', () => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.stubBuildErrors(); | ||
cy.stubBuildsErrors(); | ||
cy.stubStepsErrors(); | ||
cy.login('/github/octocat/1/graph'); | ||
}); | ||
it('error alert should show', () => { | ||
cy.get('[data-test=alerts]').should('exist').contains('Error'); | ||
}); | ||
}); | ||
context( | ||
'logged in and server returning a build graph, build and steps', | ||
() => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.route('GET', '*api/v1/repos/*/*/builds*', 'fixture:builds_5.json'); | ||
cy.route( | ||
'GET', | ||
'*api/v1/repos/*/*/builds/*', | ||
'fixture:build_success.json', | ||
); | ||
cy.route( | ||
'GET', | ||
'*api/v1/repos/*/*/builds/*/graph', | ||
'fixture:build_graph.json', | ||
); | ||
cy.login('/github/octocat/1/graph'); | ||
}); | ||
it('build graph root should be visible', () => { | ||
cy.get('.elm-build-graph-root').should('be.visible'); | ||
}); | ||
it('node should reflect build information', () => { | ||
cy.get('.elm-build-graph-node-3').should( | ||
'have.id', | ||
'#3,init,success,false', | ||
); | ||
cy.get('.d3-build-graph-node-outline-3').should( | ||
'have.class', | ||
'-success', | ||
); | ||
}); | ||
it('edge should contain build information', () => { | ||
cy.get('.elm-build-graph-edge-3-4').should( | ||
'have.id', | ||
'#3,4,success,false', | ||
); | ||
cy.get('.d3-build-graph-edge-path-3-4').should( | ||
'have.class', | ||
'-success', | ||
); | ||
}); | ||
it('click node should apply focus', () => { | ||
cy.get('.elm-build-graph-node-3') | ||
.should('have.id', '#3,init,success,false') | ||
.within(e => { | ||
cy.get('a').first().click({ force: true }); | ||
}); | ||
cy.get('.elm-build-graph-node-3').should( | ||
'have.id', | ||
'#3,init,success,true', | ||
); | ||
cy.get('.d3-build-graph-node-outline-3').should('have.class', '-focus'); | ||
}); | ||
|
||
it('node styles should reflect status', () => { | ||
// services | ||
cy.get('.d3-build-graph-node-outline-0').should( | ||
'have.class', | ||
'-pending', | ||
); | ||
cy.get('.d3-build-graph-node-outline-1').should( | ||
'have.class', | ||
'-running', | ||
); | ||
cy.get('.d3-build-graph-node-outline-2').should( | ||
'have.class', | ||
'-canceled', | ||
); | ||
|
||
// stages | ||
cy.get('.d3-build-graph-node-outline-3').should( | ||
'have.class', | ||
'-success', | ||
); | ||
cy.get('.d3-build-graph-node-outline-4').should( | ||
'have.class', | ||
'-failure', | ||
); | ||
cy.get('.d3-build-graph-node-outline-5').should( | ||
'have.class', | ||
'-killed', | ||
); | ||
}); | ||
it('legend should show', () => { | ||
cy.get('.elm-build-graph-legend').should('be.visible'); | ||
cy.get('.elm-build-graph-legend-item').should('have.length', 7); | ||
}); | ||
it('actions should show', () => { | ||
cy.get('.elm-build-graph-actions').should('be.visible'); | ||
cy.get('[data-test=build-graph-action-toggle-services]').should( | ||
'be.visible', | ||
); | ||
cy.get('[data-test=build-graph-action-toggle-steps]').should( | ||
'be.visible', | ||
); | ||
cy.get('[data-test=build-graph-action-filter]').should('be.visible'); | ||
cy.get('[data-test=build-graph-action-filter-clear]').should( | ||
'be.visible', | ||
); | ||
}); | ||
it('click "show services" should hide services', () => { | ||
cy.get('.elm-build-graph-node-0').should('contain', 'postgres'); | ||
cy.get('[data-test=build-graph-action-toggle-services]') | ||
.should('be.visible') | ||
.click({ force: true }); | ||
cy.get('.elm-build-graph-node-0').should('not.contain', 'postgres'); | ||
cy.get('[data-test=build-graph-action-toggle-services]') | ||
.should('be.visible') | ||
.click({ force: true }); | ||
cy.get('.elm-build-graph-node-0').should('contain', 'postgres'); | ||
}); | ||
it('click "show steps" should hide steps', () => { | ||
cy.get('.elm-build-graph-node-5').should('contain', 'sleep'); | ||
cy.get('[data-test=build-graph-action-toggle-steps]') | ||
.should('be.visible') | ||
.click({ force: true }); | ||
cy.get('.elm-build-graph-node-5').should('not.contain', 'sleep'); | ||
cy.get('[data-test=build-graph-action-toggle-steps]') | ||
.should('be.visible') | ||
.click({ force: true }); | ||
cy.get('.elm-build-graph-node-5').should('contain', 'sleep'); | ||
}); | ||
it('filter input and clear button should control focus', () => { | ||
cy.get('.elm-build-graph-node-5').should( | ||
'have.id', | ||
'#5,stage-a,killed,false', | ||
); | ||
cy.get('.d3-build-graph-node-outline-5').should( | ||
'not.have.class', | ||
'-focus', | ||
); | ||
cy.get('[data-test=build-graph-action-filter]') | ||
.should('be.visible') | ||
.type('stage-a'); | ||
cy.get('.elm-build-graph-node-5').should( | ||
'have.id', | ||
'#5,stage-a,killed,true', | ||
); | ||
cy.get('.d3-build-graph-node-outline-5').should('have.class', '-focus'); | ||
// clear button | ||
cy.get('[data-test=build-graph-action-filter-clear]') | ||
.should('be.visible') | ||
.click({ force: true }); | ||
cy.get('.d3-build-graph-node-outline-5').should( | ||
'not.have.class', | ||
'-focus', | ||
); | ||
}); | ||
}, | ||
); | ||
}); |
Oops, something went wrong.