Skip to content
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
merged 3 commits into from
Apr 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions test/acceptance/registry-ui.js
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/',
Copy link
Collaborator

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/?

Copy link
Member Author

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.

Copy link
Collaborator

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 matter

Copy link
Member Author

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?

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>/);
});
});
});