mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
test: move url shortener tests to api_integration (#14411)
Integration tests should go into the corresponding directory under test and should use the appropriate testing framework that is designed for long-running tests like those. Tests under tests directories should be fast-running unit tests only.
This commit is contained in:
parent
0e7ddf3d26
commit
ae1b1e4fd5
3 changed files with 35 additions and 36 deletions
|
@ -50,40 +50,4 @@ describe('routes', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('url shortener', () => {
|
||||
const shortenOptions = {
|
||||
method: 'POST',
|
||||
url: '/shorten',
|
||||
payload: {
|
||||
url: '/app/kibana#/visualize/create'
|
||||
}
|
||||
};
|
||||
|
||||
it('generates shortened urls', (done) => {
|
||||
kbnTestServer.makeRequest(kbnServer, shortenOptions, (res) => {
|
||||
expect(typeof res.payload).to.be('string');
|
||||
expect(res.payload.length > 0).to.be(true);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('redirects shortened urls', (done) => {
|
||||
kbnTestServer.makeRequest(kbnServer, shortenOptions, (res) => {
|
||||
expect(res).to.have.property('statusCode', 200);
|
||||
|
||||
const gotoOptions = {
|
||||
method: 'GET',
|
||||
url: '/goto/' + res.payload
|
||||
};
|
||||
kbnTestServer.makeRequest(kbnServer, gotoOptions, (res) => {
|
||||
expect(res.statusCode).to.be(302);
|
||||
expect(res.headers.location).to.be(shortenOptions.payload.url);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -3,6 +3,7 @@ export default function ({ loadTestFile }) {
|
|||
loadTestFile(require.resolve('./index_patterns'));
|
||||
loadTestFile(require.resolve('./scripts'));
|
||||
loadTestFile(require.resolve('./search'));
|
||||
loadTestFile(require.resolve('./shorten'));
|
||||
loadTestFile(require.resolve('./suggestions'));
|
||||
});
|
||||
}
|
||||
|
|
34
test/api_integration/apis/shorten/index.js
Normal file
34
test/api_integration/apis/shorten/index.js
Normal file
|
@ -0,0 +1,34 @@
|
|||
import expect from 'expect.js';
|
||||
|
||||
export default function ({ getService }) {
|
||||
const esArchiver = getService('esArchiver');
|
||||
const supertest = getService('supertest');
|
||||
|
||||
describe('url shortener', () => {
|
||||
before(() => esArchiver.load('saved_objects/basic'));
|
||||
after(() => esArchiver.unload('saved_objects/basic'));
|
||||
|
||||
it('generates shortened urls', async () => {
|
||||
const resp = await supertest
|
||||
.post('/shorten')
|
||||
.set('content-type', 'application/json')
|
||||
.send({ url: '/app/kibana#/visualize/create' })
|
||||
.expect(200);
|
||||
|
||||
expect(typeof resp.text).to.be('string');
|
||||
expect(resp.text.length > 0).to.be(true);
|
||||
});
|
||||
|
||||
it('redirects shortened urls', async () => {
|
||||
const resp = await supertest
|
||||
.post('/shorten')
|
||||
.set('content-type', 'application/json')
|
||||
.send({ url: '/app/kibana#/visualize/create' });
|
||||
|
||||
await supertest
|
||||
.get(`/goto/${resp.text}`)
|
||||
.expect(302)
|
||||
.expect('location', '/app/kibana#/visualize/create');
|
||||
});
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue