-
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(dashboard): render dashboard page and repo cards (#796)
Co-authored-by: wass3rw3rk <49894298+wass3rw3rk@users.noreply.github.com> Co-authored-by: david may <1301201+wass3r@users.noreply.github.com>
- Loading branch information
1 parent
e2aa22c
commit d0dd9e9
Showing
25 changed files
with
1,696 additions
and
73 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,149 @@ | ||
{ | ||
"dashboard": { | ||
"id": "86671eb5-a3ff-49e1-ad85-c3b2f648dcb2", | ||
"name": "example", | ||
"created_at": 1715749911, | ||
"created_by": "CookieCat", | ||
"updated_at": 1715749911, | ||
"updated_by": "CookieCat", | ||
"admins": [ | ||
{ | ||
"id": 1, | ||
"name": "CookieCat", | ||
"active": true | ||
} | ||
], | ||
"repos": [ | ||
{ | ||
"id": 2, | ||
"name": "github/repo1" | ||
}, | ||
{ | ||
"id": 1, | ||
"name": "github/repo2" | ||
} | ||
] | ||
}, | ||
"repos": [ | ||
{ | ||
"org": "github", | ||
"name": "repo1", | ||
"counter": 25, | ||
"active": true, | ||
"builds": [ | ||
{ | ||
"number": 25, | ||
"started": 1715965620, | ||
"finished": 1715965674, | ||
"sender": "github", | ||
"status": "success", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo1/25" | ||
}, | ||
{ | ||
"number": 24, | ||
"started": 1715965597, | ||
"finished": 1715965620, | ||
"sender": "github", | ||
"status": "canceled", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo1/24" | ||
}, | ||
{ | ||
"number": 23, | ||
"started": 1715964030, | ||
"finished": 1715964083, | ||
"sender": "github", | ||
"status": "success", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo1/23" | ||
}, | ||
{ | ||
"number": 22, | ||
"started": 1715963978, | ||
"finished": 1715964028, | ||
"sender": "github", | ||
"status": "success", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo1/22" | ||
}, | ||
{ | ||
"number": 21, | ||
"started": 1715919426, | ||
"finished": 1715919479, | ||
"sender": "github", | ||
"status": "success", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo1/21" | ||
} | ||
] | ||
}, | ||
{ | ||
"org": "github", | ||
"name": "repo2", | ||
"active": true, | ||
"builds": [ | ||
{ | ||
"number": 15, | ||
"started": 1715965620, | ||
"finished": 1715965674, | ||
"sender": "github", | ||
"status": "failure", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo2/15" | ||
}, | ||
{ | ||
"number": 14, | ||
"started": 1715965597, | ||
"finished": 1715965620, | ||
"sender": "github", | ||
"status": "canceled", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo2/14" | ||
}, | ||
{ | ||
"number": 13, | ||
"started": 1715964030, | ||
"finished": 1715964083, | ||
"sender": "github", | ||
"status": "success", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo2/13" | ||
}, | ||
{ | ||
"number": 12, | ||
"started": 1715963978, | ||
"finished": 1715964028, | ||
"sender": "github", | ||
"status": "success", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo2/12" | ||
}, | ||
{ | ||
"number": 11, | ||
"started": 1715919426, | ||
"finished": 1715919479, | ||
"sender": "github", | ||
"status": "success", | ||
"event": "push", | ||
"branch": "main", | ||
"link": "/github/repo2/11" | ||
} | ||
] | ||
}, | ||
{ | ||
"org": "github", | ||
"name": "repo3", | ||
"active": true | ||
} | ||
] | ||
} |
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,18 @@ | ||
{ | ||
"dashboard": { | ||
"id": "86671eb5-a3ff-49e1-ad85-c3b2f648dcb2", | ||
"name": "example2", | ||
"created_at": 1715749911, | ||
"created_by": "CookieCat", | ||
"updated_at": 1715749911, | ||
"updated_by": "CookieCat", | ||
"admins": [ | ||
{ | ||
"id": 1, | ||
"name": "CookieCat", | ||
"active": true | ||
} | ||
], | ||
"repos": [] | ||
} | ||
} |
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,126 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
context('Dashboards', () => { | ||
context('server returns dashboard with 3 cards, one without builds', () => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.route( | ||
'GET', | ||
'*api/v1/dashboards/86671eb5-a3ff-49e1-ad85-c3b2f648dcb2', | ||
'fixture:dashboard.json', | ||
); | ||
cy.login('/dashboards/86671eb5-a3ff-49e1-ad85-c3b2f648dcb2'); | ||
}); | ||
|
||
it('shows 3 dashboard cards', () => { | ||
cy.get('[data-test=dashboard-card]').should('have.length', 3); | ||
}); | ||
|
||
it('shows an empty state when there are no builds', () => { | ||
cy.get('[data-test=dashboard-card]') | ||
.last() | ||
.contains('waiting for builds'); | ||
}); | ||
|
||
it('shows success build icon in header in the first card', () => { | ||
cy.get('[data-test=dashboard-card]') | ||
.first() | ||
.within(() => { | ||
cy.get('.-icon').should('have.class', '-success'); | ||
}); | ||
}); | ||
|
||
it('shows failure build icon in header in the first card', () => { | ||
cy.get('[data-test=dashboard-card]') | ||
.eq(1) | ||
.within(() => { | ||
cy.get('.-icon').should('have.class', '-failure'); | ||
}); | ||
}); | ||
|
||
it('org link in card header goes to org page', () => { | ||
cy.get('[data-test=dashboard-card]') | ||
.first() | ||
.within(() => { | ||
cy.get('.card-org').click(); | ||
cy.location('pathname').should('eq', '/github'); | ||
}); | ||
}); | ||
|
||
it('repo link in card header goes to repo page', () => { | ||
cy.get('[data-test=dashboard-card]') | ||
.first() | ||
.within(() => { | ||
cy.get('.card-repo').click(); | ||
cy.location('pathname').should('eq', '/github/repo1'); | ||
}); | ||
}); | ||
|
||
it('build link in card goes to build page', () => { | ||
cy.get('[data-test=dashboard-card]') | ||
.first() | ||
.within(() => { | ||
cy.get('.card-build-data li:first-child a').click(); | ||
cy.location('pathname').should('eq', '/github/repo1/25'); | ||
}); | ||
}); | ||
|
||
it('recent build link goes to respective build page', () => { | ||
cy.get('[data-test=recent-build-link-25]').click(); | ||
cy.location('pathname').should('eq', '/github/repo1/25'); | ||
}); | ||
}); | ||
|
||
context('server returning dashboard without repos', () => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.route( | ||
'GET', | ||
'*api/v1/dashboards/86671eb5-a3ff-49e1-ad85-c3b2f648dcb2', | ||
'fixture:dashboard_no_repos.json', | ||
); | ||
cy.login('/dashboards/86671eb5-a3ff-49e1-ad85-c3b2f648dcb2'); | ||
}); | ||
|
||
it('shows message when there are no repositories added', () => { | ||
cy.get('[data-test=dashboard]').contains( | ||
`This dashboard doesn't have repositories added yet`, | ||
); | ||
}); | ||
}); | ||
|
||
context('dashboard not found', () => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.route({ | ||
method: 'GET', | ||
status: 404, | ||
url: '*api/v1/dashboards/deadbeef', | ||
response: { | ||
error: | ||
'unable to read dashboard deadbeef: ERROR: invalid input syntax for type uuid: "deadbeef" (SQLSTATE 22P02)', | ||
}, | ||
}); | ||
cy.login('/dashboards/deadbeef'); | ||
}); | ||
|
||
it('shows a not found message', () => { | ||
cy.get('[data-test=dashboard]').contains( | ||
'Dashboard "deadbeef" not found. Please check the URL.', | ||
); | ||
}); | ||
}); | ||
|
||
context('main dashboards page shows message', () => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.login('/dashboards'); | ||
}); | ||
|
||
it('shows the welcome message', () => { | ||
cy.get('[data-test=dashboards]').contains('Welcome to dashboards!'); | ||
}); | ||
}); | ||
}); |
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
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
Oops, something went wrong.