-
Notifications
You must be signed in to change notification settings - Fork 142
fix: display errors when adding a new repo #1120
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
Open
andypols
wants to merge
8
commits into
finos:main
Choose a base branch
from
andypols:fix-display-repo-add-errors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−76
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9e4c0c7
chore: upgrade cypress
andypols 2c3fdae
chore: fix NewRepo to report errors returned by addRepo
andypols 88e11c8
Merge branch 'main' into fix-display-repo-add-errors
andypols 61b4afa
chore: merge: 1.19.2
andypols a9b147e
chore: add back package-lock.json and remove form .gitignore
andypols 45be2e2
Delete package-lock.json
jescalada 11149c9
chore: regenerate package-lock.json
jescalada 65b93b3
chore: revert package-lock.json to state from main
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,119 @@ | ||
describe('Repo', () => { | ||
beforeEach(() => { | ||
cy.login('admin', 'admin'); | ||
|
||
cy.visit('/dashboard/repo'); | ||
|
||
// prevent failures on 404 request and uncaught promises | ||
cy.on('uncaught:exception', () => false); | ||
}); | ||
|
||
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"]'; | ||
describe('Anonymous users', () => { | ||
it('Prevents anonymous users from adding repos', () => { | ||
cy.get('[data-testid="repo-list-view"]') | ||
jescalada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.find('[data-testid="add-repo-button"]') | ||
.should('not.exist'); | ||
}); | ||
|
||
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 | ||
}); | ||
}); | ||
}); | ||
|
||
describe('Regular users', () => { | ||
beforeEach(() => { | ||
cy.login('user', 'user'); | ||
|
||
cy | ||
// tooltip isn't open to start with | ||
.get(tooltipQuery) | ||
cy.visit('/dashboard/repo'); | ||
}); | ||
|
||
after(() => { | ||
cy.logout(); | ||
}); | ||
|
||
it('Prevents regular users from adding repos', () => { | ||
cy.get('[data-testid="repo-list-view"]') | ||
.find('[data-testid="add-repo-button"]') | ||
.should('not.exist'); | ||
}); | ||
}); | ||
|
||
describe('Admin users', () => { | ||
beforeEach(() => { | ||
cy.login('admin', 'admin'); | ||
|
||
cy.visit('/dashboard/repo'); | ||
}); | ||
|
||
it('Admin users can add repos', () => { | ||
cy.get('[data-testid="repo-list-view"]').find('[data-testid="add-repo-button"]').click(); | ||
|
||
cy.get('[data-testid="add-repo-dialog"]').within(() => { | ||
cy.get('[data-testid="repo-project-input"]').type('uuidjs'); | ||
cy.get('[data-testid="repo-name-input"]').type('uuidjs'); | ||
cy.get('[data-testid="repo-url-input"]').type('https://github.com/uuidjs/uuid.git'); | ||
cy.get('[data-testid="add-repo-button"]').click(); | ||
}); | ||
|
||
cy.get('a[href="/dashboard/repo/uuidjs"]', { timeout: 10000 }).click(); | ||
|
||
cy.get('[data-testid="delete-repo-button"]').click(); | ||
}); | ||
|
||
it('Prevents adding an existing repo', () => { | ||
cy.get('[data-testid="repo-list-view"]').find('[data-testid="add-repo-button"]').click(); | ||
|
||
cy.get('[data-testid="add-repo-dialog"]').within(() => { | ||
cy.get('[data-testid="repo-project-input"]').type('finos'); | ||
cy.get('[data-testid="repo-name-input"]').type('git-proxy'); | ||
cy.get('[data-testid="repo-url-input"]').type('https://github.com/finos/git-proxy.git'); | ||
cy.get('[data-testid="add-repo-button"]').click(); | ||
}); | ||
|
||
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 | ||
cy.get('[data-testid="repo-error"]') | ||
.should('be.visible') | ||
.and('contain.text', 'Repository already exists!'); | ||
}); | ||
}); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -42,13 +42,18 @@ const configure = async (passport) => { | |
}; | ||
|
||
/** | ||
* Create the default admin user if it doesn't exist | ||
* Create the default admin and regular test users. | ||
*/ | ||
const createDefaultAdmin = async () => { | ||
const admin = await db.findUser("admin"); | ||
if (!admin) { | ||
await db.createUser("admin", "admin", "[email protected]", "none", true); | ||
} | ||
const createIfNotExists = async (username, password, email, type, isAdmin) => { | ||
const user = await db.findUser(username); | ||
if (!user) { | ||
await db.createUser(username, password, email, type, isAdmin); | ||
} | ||
}; | ||
|
||
await createIfNotExists('admin', 'admin', '[email protected]', 'none', true); | ||
jescalada marked this conversation as resolved.
Show resolved
Hide resolved
|
||
await createIfNotExists('user', 'user', '[email protected]', 'none', false); | ||
}; | ||
|
||
module.exports = { configure, createDefaultAdmin, type }; |
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
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.