-
Notifications
You must be signed in to change notification settings - Fork 158
test: fix Cypress test data dependency #1154
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3b244b7
test: add CSRF token Cypress command
jescalada 3a7bf1c
test(e2e): add logger task for debugging
jescalada a033697
test(e2e): refactor repo.cy.js to create and delete test repo
jescalada 81126ed
Merge branch 'main' into cypress-test-data-dependency
jescalada 6695f7f
test(unit): revert addRepoTest data cleanup
jescalada c03a36a
Merge branch 'main' into cypress-test-data-dependency
jescalada 475b19a
chore: add check before splitting csrfCookie
jescalada 51da326
chore: improve checks in getCSRFToken command
jescalada 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,57 +1,82 @@ | ||
| describe('Repo', () => { | ||
| beforeEach(() => { | ||
| let repoName; | ||
| let cloneURL; | ||
| let csrfToken; | ||
| let cookies; | ||
|
|
||
| before(() => { | ||
| cy.login('admin', 'admin'); | ||
|
|
||
| cy.visit('/dashboard/repo'); | ||
| // Create a new repo | ||
| cy.getCSRFToken().then((csrfToken) => { | ||
| repoName = `${Date.now()}`; | ||
| cloneURL = `http://localhost:8000/cypress-test/${repoName}.git`; | ||
|
|
||
| // prevent failures on 404 request and uncaught promises | ||
| cy.on('uncaught:exception', () => false); | ||
| cy.request({ | ||
| method: 'POST', | ||
| url: 'http://localhost:8080/api/v1/repo', | ||
| body: { | ||
| project: 'cypress-test', | ||
| name: repoName, | ||
| url: `https://github.com/cypress-test/${repoName}.git` | ||
| }, | ||
| headers: { | ||
| cookie: cookies?.join('; ') || '', | ||
| 'X-CSRF-TOKEN': csrfToken | ||
| } | ||
| }).then((res) => { | ||
| expect(res.status).to.eq(200); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Code button for repo row', () => { | ||
| it('Opens tooltip with correct content and can copy', () => { | ||
| const cloneURL = 'http://localhost:8000/finos/git-proxy.git'; | ||
| const tooltipQuery = 'div[role="tooltip"]'; | ||
|
|
||
| cy | ||
| // tooltip isn't open to start with | ||
| .get(tooltipQuery) | ||
| .should('not.exist'); | ||
|
|
||
| cy | ||
| // find the entry for finos/git-proxy | ||
| .get('a[href="/dashboard/repo/git-proxy"]') | ||
| // take it's parent row | ||
| .closest('tr') | ||
| // find the nearby span containing Code we can click to open the tooltip | ||
| .find('span') | ||
| .contains('Code') | ||
| .should('exist') | ||
| .click(); | ||
|
|
||
| cy | ||
| // find the newly opened tooltip | ||
| .get(tooltipQuery) | ||
| .should('exist') | ||
| .find('span') | ||
| // check it contains the url we expect | ||
| .contains(cloneURL) | ||
| .should('exist') | ||
| .parent() | ||
| // find the adjacent span that contains the svg | ||
| .find('span') | ||
| .next() | ||
| // check it has the copy icon first and click it | ||
| .get('svg.octicon-copy') | ||
| .should('exist') | ||
| .click() | ||
| // check the icon has changed to the check icon | ||
| .get('svg.octicon-copy') | ||
| .should('not.exist') | ||
| .get('svg.octicon-check') | ||
| .should('exist'); | ||
|
|
||
| // failed to successfully check the clipboard | ||
| after(() => { | ||
| // Delete the repo | ||
| cy.getCSRFToken().then((csrfToken) => { | ||
| cy.request({ | ||
| method: 'DELETE', | ||
| url: `http://localhost:8080/api/v1/repo/${repoName}/delete`, | ||
| headers: { | ||
| cookie: cookies?.join('; ') || '', | ||
| 'X-CSRF-TOKEN': csrfToken | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| it('Opens tooltip with correct content and can copy', () => { | ||
| cy.visit('/dashboard/repo'); | ||
| cy.on('uncaught:exception', () => false); | ||
|
|
||
| const tooltipQuery = 'div[role="tooltip"]'; | ||
|
|
||
| // Check the tooltip isn't open to start with | ||
| cy.get(tooltipQuery) | ||
| .should('not.exist'); | ||
|
|
||
| // Find the repo's Code button and click it | ||
| cy.get(`a[href="/dashboard/repo/${repoName}"]`) | ||
| .closest('tr') | ||
| .find('span') | ||
| .contains('Code') | ||
| .should('exist') | ||
| .click(); | ||
|
|
||
| // Check tooltip is open and contains the correct clone URL | ||
| cy.get(tooltipQuery) | ||
| .should('exist') | ||
| .find('span') | ||
| .contains(cloneURL) | ||
| .should('exist') | ||
| .parent() | ||
| .find('span') | ||
| .next() | ||
| .get('svg.octicon-copy') | ||
| .should('exist') | ||
| .click() | ||
| .get('svg.octicon-copy') | ||
| .should('not.exist') | ||
| .get('svg.octicon-check') | ||
| .should('exist'); | ||
| }); | ||
| }); |
This file contains hidden or 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 hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.