-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
210 additions
and
71 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 |
---|---|---|
@@ -1,2 +1 @@ | ||
VITE_API_URI=http://localhost:8080 | ||
VITE_SERVER_URI=http://localhost:8000 |
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,55 @@ | ||
describe('Repo', () => { | ||
beforeEach(() => { | ||
cy.visit('/admin/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/test-repo.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/test-repo | ||
.get('a[href="/admin/repo/test-repo"]') | ||
// 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 | ||
}); | ||
}); | ||
}); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -92,6 +92,7 @@ | |
} | ||
] | ||
}, | ||
"domains": {}, | ||
"privateOrganizations": [], | ||
"urlShortener": "", | ||
"contactEmail": "", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
const { GIT_PROXY_SERVER_PORT: PROXY_HTTP_PORT, GIT_PROXY_UI_PORT: UI_PORT } = | ||
require('../config/env').Vars; | ||
const config = require('../config'); | ||
|
||
module.exports = { | ||
getProxyURL: (req) => { | ||
const defaultURL = `${req.protocol}://${req.headers.host}`.replace( | ||
`:${UI_PORT}`, | ||
`:${PROXY_HTTP_PORT}`, | ||
); | ||
return config.getDomains().proxy ?? defaultURL; | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const chai = require('chai'); | ||
const sinon = require('sinon'); | ||
const express = require('express'); | ||
const chaiHttp = require('chai-http'); | ||
const { getProxyURL } = require('../src/service/proxyURL'); | ||
const config = require('../src/config'); | ||
|
||
chai.use(chaiHttp); | ||
chai.should(); | ||
const expect = chai.expect; | ||
|
||
const genSimpleServer = () => { | ||
const app = express(); | ||
app.get('/', (req, res) => { | ||
res.contentType('text/html'); | ||
res.send(getProxyURL(req)); | ||
}); | ||
return app; | ||
}; | ||
|
||
describe('proxyURL', async () => { | ||
afterEach(() => { | ||
sinon.restore(); | ||
}); | ||
|
||
it('pulls the request path with no override', async () => { | ||
const app = genSimpleServer(); | ||
const res = await chai.request(app).get('/').send(); | ||
res.should.have.status(200); | ||
|
||
// request url without trailing slash | ||
const reqURL = res.request.url.slice(0, -1); | ||
expect(res.text).to.equal(reqURL); | ||
expect(res.text).to.match(/https?:\/\/127.0.0.1:\d+/); | ||
}); | ||
|
||
it('can override providing a proxy value', async () => { | ||
const proxyURL = 'https://amazing-proxy.path.local'; | ||
// stub getDomains | ||
const configGetDomainsStub = sinon.stub(config, 'getDomains').returns({ proxy: proxyURL }); | ||
|
||
const app = genSimpleServer(); | ||
const res = await chai.request(app).get('/').send(); | ||
res.should.have.status(200); | ||
|
||
// the stub worked | ||
expect(configGetDomainsStub.calledOnce).to.be.true; | ||
|
||
expect(res.text).to.equal(proxyURL); | ||
}); | ||
}); |
Oops, something went wrong.