-
Notifications
You must be signed in to change notification settings - Fork 122
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
UI interface tests #455
Merged
UI interface tests #455
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,74 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const oc = require('../../src/index'); | ||
const path = require('path'); | ||
const request = require('minimal-request'); | ||
|
||
describe('registry (ui interface)', () => { | ||
|
||
let registry, result, error, headers; | ||
|
||
const next = (done) => (e, r, d) => { | ||
error = e; | ||
result = r; | ||
headers = d.response.headers; | ||
done(); | ||
}; | ||
|
||
const conf = { | ||
local: true, | ||
path: path.resolve('test/fixtures/components'), | ||
port: 3030, | ||
baseUrl: 'http://localhost:3030/', | ||
env: { name: 'local' }, | ||
verbosity: 0, | ||
dependencies: ['underscore'], | ||
discovery: true | ||
}; | ||
|
||
const initializeRegistry = (configuration, cb) => { | ||
registry = new oc.Registry(configuration); | ||
registry.start(cb); | ||
}; | ||
|
||
before(done => initializeRegistry(conf, done)); | ||
|
||
after(done => registry.close(done)); | ||
|
||
describe('GET / with Accept: text/html', () => { | ||
before((done) => { | ||
request({ | ||
url: 'http://localhost:3030', | ||
headers: { accept: 'text/html' } | ||
}, next(done)); | ||
}); | ||
|
||
it('should not error', () => { | ||
expect(error).to.be.null; | ||
}); | ||
|
||
it('should respond with html result', () => { | ||
expect(headers['content-type']).to.equal('text/html; charset=utf-8'); | ||
expect(result).to.match(/<!DOCTYPE html><html>/); | ||
}); | ||
}); | ||
|
||
describe('GET /oc-client/~info with Accept: text/html', () => { | ||
before((done) => { | ||
request({ | ||
url: 'http://localhost:3030/oc-client/~info', | ||
headers: { accept: 'text/html' } | ||
}, next(done)); | ||
}); | ||
|
||
it('should not error', () => { | ||
expect(error).to.be.null; | ||
}); | ||
|
||
it('should respond with html result', () => { | ||
expect(headers['content-type']).to.equal('text/html; charset=utf-8'); | ||
expect(result).to.match(/<!DOCTYPE html><html>/); | ||
}); | ||
}); | ||
}); |
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.
would you be able to test it with a path, ex.
http://localhost:3030/v2/
?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.
I would be able to, not sure why should I?
The purpose of this tests is mostly ensure that we have a kind of smoke test for when we change the registry so that the UI doesn't break. Tests for testing the "prefix" parameter (what would be like a
/v2/
segment - are already there on a unit level.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.
I've recently encountered a bug where
/v2/
was being removed when browsing components. But if it's covered elsewhere then it doesn't matterThere 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.
Ok @pbazydlo, so can you approve?