kibana/test/api_integration/apis/shorten/index.js
Tyler Smalley c272bdbc25
Revert: [7.x] [FTR][CI] Use default distribution for all tests (#102019)
* Revert "[FTR] Use importExport for saved_object/basic archive (#100244) (#102016)"

This reverts commit 9851b7bcfa.

* Revert "[7.x] [FTR][CI] Use default distribution for all tests (#94968) (#101118)"

This reverts commit 73225daa87.
2021-06-13 23:29:03 -07:00

44 lines
1.5 KiB
JavaScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import expect from '@kbn/expect';
export default function ({ getService }) {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');
describe('url shortener', () => {
before(() => esArchiver.load('test/api_integration/fixtures/es_archiver/saved_objects/basic'));
after(() => esArchiver.unload('test/api_integration/fixtures/es_archiver/saved_objects/basic'));
it('generates shortened urls', async () => {
const resp = await supertest
.post('/api/shorten_url')
.set('content-type', 'application/json')
.send({ url: '/app/visualize#/create' })
.expect(200);
expect(resp.body).to.have.property('urlId');
expect(typeof resp.body.urlId).to.be('string');
expect(resp.body.urlId.length > 0).to.be(true);
});
it('redirects shortened urls', async () => {
const resp = await supertest
.post('/api/shorten_url')
.set('content-type', 'application/json')
.send({ url: '/app/visualize#/create' });
const urlId = resp.body.urlId;
await supertest
.get(`/goto/${urlId}`)
.expect(302)
.expect('location', '/app/visualize#/create');
});
});
}