-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(secrets): cypress tests for secrets #161
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d490768
wrapped secret in RemoteData, added resourceError helper class, added…
plyr4 cf4ef3e
lint
plyr4 93c4400
adding test labels to Table.View
plyr4 99a2639
more generic cypress tests for rendering secrets
plyr4 9c93153
cypress tests. linting.
plyr4 842e0b2
Merge branch 'master' into test_secrets
plyr4 0e60888
oof, forgot to update hooks
plyr4 8db0b3b
remove redundant case
plyr4 22b733a
updating grammar in add repos test
plyr4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,62 @@ | ||
[ | ||
{ | ||
"id": 513, | ||
"org": "github", | ||
"repo": "*", | ||
"team": "", | ||
"name": "docker_username", | ||
"value": "[secure]", | ||
"type": "org", | ||
"images": [], | ||
"events": ["push"], | ||
"allow_command": true | ||
}, | ||
{ | ||
"id": 511, | ||
"org": "github", | ||
"repo": "*", | ||
"team": "", | ||
"name": "docker_password", | ||
"value": "[secure]", | ||
"type": "org", | ||
"images": [], | ||
"events": ["push"], | ||
"allow_command": true | ||
}, | ||
{ | ||
"id": 509, | ||
"org": "github", | ||
"repo": "*", | ||
"team": "", | ||
"name": "push", | ||
"value": "[secure]", | ||
"type": "org", | ||
"images": [], | ||
"events": ["push"], | ||
"allow_command": true | ||
}, | ||
{ | ||
"id": 511, | ||
"org": "github", | ||
"repo": "*", | ||
"team": "", | ||
"name": "pull_request", | ||
"value": "[secure]", | ||
"type": "org", | ||
"images": [], | ||
"events": ["push", "pull_request"], | ||
"allow_command": true | ||
}, | ||
{ | ||
"id": 509, | ||
"org": "github", | ||
"repo": "*", | ||
"team": "", | ||
"name": "deployment", | ||
"value": "[secure]", | ||
"type": "org", | ||
"images": [], | ||
"events": ["push", "pull_request", "comment", "deployment"], | ||
"allow_command": 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
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,84 @@ | ||
/* | ||
* Copyright (c) 2020 Target Brands, Inc. All rights reserved. | ||
* Use of this source code is governed by the LICENSE file in this repository. | ||
*/ | ||
|
||
context('Secrets', () => { | ||
context('server returning secrets error', () => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.route({ | ||
method: 'GET', | ||
url: '*api/v1/secrets/native/org/github/**', | ||
status: 500, | ||
response: 'server error', | ||
}); | ||
cy.login('/-/secrets/native/org/github'); | ||
}); | ||
|
||
it('secrets table should not show', () => { | ||
cy.get('[data-test=secrets]').should('not.be.visible'); | ||
}); | ||
it('error should show', () => { | ||
cy.get('[data-test=alerts]') | ||
.should('exist') | ||
.contains('Error'); | ||
}); | ||
it('error banner should show', () => { | ||
cy.get('[data-test=secrets-error]') | ||
.should('exist') | ||
.contains('try again later'); | ||
}); | ||
}); | ||
context('server returning 5 secrets', () => { | ||
beforeEach(() => { | ||
cy.server(); | ||
cy.route( | ||
'GET', | ||
'*api/v1/secrets/native/org/github/**', | ||
'fixture:secrets_org_5.json', | ||
).as('secrets'); | ||
cy.login('/-/secrets/native/org/github'); | ||
}); | ||
|
||
it('secrets table should show', () => { | ||
cy.get('[data-test=secrets-table]').should('be.visible'); | ||
}); | ||
|
||
it('secrets table should show 5 secrets', () => { | ||
cy.get('[data-test=secrets-row]').should('have.length', 5); | ||
}); | ||
|
||
it('pagination controls should not show', () => { | ||
cy.get('[data-test=pager-previous]').should('not.be.visible'); | ||
}); | ||
|
||
context('secret', () => { | ||
beforeEach(() => { | ||
cy.get('[data-test=secrets-row]') | ||
.first() | ||
.as('firstSecret'); | ||
cy.get('[data-test=secrets-row]') | ||
.last() | ||
.as('lastSecret'); | ||
}); | ||
it('should show name', () => { | ||
cy.get('@firstSecret').within(() => { | ||
cy.get('[data-test=secrets-row-name]').contains('docker_username'); | ||
}); | ||
cy.get('@lastSecret').within(() => { | ||
cy.get('[data-test=secrets-row-name]').contains('deployment'); | ||
}); | ||
}); | ||
it('clicking name should route to edit secret page', () => { | ||
cy.get('@firstSecret').within(() => { | ||
cy.get('[data-test=secrets-row-name]').click({ force: true }); | ||
cy.location('pathname').should( | ||
'eq', | ||
'/-/secrets/native/org/github/docker_username', | ||
); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -761,29 +761,6 @@ update msg model = | |
Err error -> | ||
( model, addError error ) | ||
|
||
SecretsResponse response -> | ||
case response of | ||
Ok ( meta, secrets ) -> | ||
let | ||
secretsModel = | ||
model.secretsModel | ||
|
||
mergedSecrets = | ||
case secretsModel.secrets of | ||
Success s -> | ||
RemoteData.succeed <| Util.mergeListsById s secrets | ||
|
||
_ -> | ||
RemoteData.succeed secrets | ||
|
||
pager = | ||
Pagination.get meta.headers | ||
in | ||
( { model | secretsModel = { secretsModel | secrets = mergedSecrets, pager = pager } }, Cmd.none ) | ||
|
||
Err error -> | ||
( model, addError error ) | ||
|
||
SecretResponse response -> | ||
case response of | ||
Ok ( _, secret ) -> | ||
|
@@ -837,6 +814,27 @@ update msg model = | |
Err error -> | ||
( model, addError error ) | ||
|
||
SecretsResponse response -> | ||
let | ||
secretsModel = | ||
model.secretsModel | ||
in | ||
case response of | ||
Ok ( _, secrets ) -> | ||
let | ||
mergedSecrets = | ||
case secretsModel.secrets of | ||
Success s -> | ||
RemoteData.succeed <| Util.mergeListsById s secrets | ||
|
||
_ -> | ||
RemoteData.succeed secrets | ||
in | ||
( { model | secretsModel = { secretsModel | secrets = mergedSecrets } }, Cmd.none ) | ||
|
||
Err error -> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added account for GET failure |
||
( { model | secretsModel = { secretsModel | secrets = toFailure error } }, addError error ) | ||
|
||
UpdateRepoEvent org repo field value -> | ||
let | ||
payload : UpdateRepositoryPayload | ||
|
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ Use of this source code is governed by the LICENSE file in this repository. | |
module Pages.AddRepos exposing (Msgs, PartialModel, view) | ||
|
||
import Dict | ||
import Errors exposing (viewResourceError) | ||
import Favorites | ||
exposing | ||
( ToggleFavorite | ||
|
@@ -121,12 +122,7 @@ view model actions = | |
loading | ||
|
||
RemoteData.Failure _ -> | ||
div [] | ||
[ p [] | ||
[ text <| | ||
"There was an error fetching your available repositories... Click Refresh or try again later!" | ||
] | ||
] | ||
viewResourceError { resourceLabel = "your available repositories", testLabel = "repos" } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added a helper class for the "try again later!" we test for |
||
|
||
|
||
{-| viewSourceRepos : takes model and source repos and renders them based on user search | ||
|
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helper function for rendering GET failures