2020-03-11 15:09:37 +00:00
|
|
|
// this file can't be migrated to jest because it relies on the browser to perform integration tests:
|
|
|
|
// see: https://gitlab.com/gitlab-org/gitlab/-/issues/194207#note_301878738
|
2019-04-25 12:11:01 +00:00
|
|
|
import { FIXTURES_PATH } from 'spec/test_constants';
|
2019-12-09 12:07:58 +00:00
|
|
|
import BalsamiqViewer from '~/blob/balsamiq/balsamiq_viewer';
|
2019-04-25 12:11:01 +00:00
|
|
|
|
|
|
|
const bmprPath = `${FIXTURES_PATH}/blob/balsamiq/test.bmpr`;
|
2017-05-15 07:48:54 +00:00
|
|
|
|
|
|
|
describe('Balsamiq integration spec', () => {
|
|
|
|
let container;
|
|
|
|
let endpoint;
|
|
|
|
let balsamiqViewer;
|
|
|
|
|
2019-03-26 16:03:28 +00:00
|
|
|
preloadFixtures('static/balsamiq_viewer.html');
|
2017-05-15 07:48:54 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
2019-03-26 16:03:28 +00:00
|
|
|
loadFixtures('static/balsamiq_viewer.html');
|
2017-05-15 07:48:54 +00:00
|
|
|
|
|
|
|
container = document.getElementById('js-balsamiq-viewer');
|
|
|
|
balsamiqViewer = new BalsamiqViewer(container);
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('successful response', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
beforeEach(done => {
|
2017-05-15 07:48:54 +00:00
|
|
|
endpoint = bmprPath;
|
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
balsamiqViewer
|
|
|
|
.loadFile(endpoint)
|
|
|
|
.then(done)
|
|
|
|
.catch(done.fail);
|
2017-05-15 07:48:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show loading icon', () => {
|
|
|
|
expect(document.querySelector('.loading')).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders the balsamiq previews', () => {
|
|
|
|
expect(document.querySelectorAll('.previews .preview').length).not.toEqual(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('error getting file', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
beforeEach(done => {
|
2017-05-15 07:48:54 +00:00
|
|
|
endpoint = 'invalid/path/to/file.bmpr';
|
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
balsamiqViewer
|
|
|
|
.loadFile(endpoint)
|
|
|
|
.then(done.fail, null)
|
|
|
|
.catch(done);
|
2017-05-15 07:48:54 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('does not show loading icon', () => {
|
|
|
|
expect(document.querySelector('.loading')).toBeNull();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render the balsamiq previews', () => {
|
|
|
|
expect(document.querySelectorAll('.previews .preview').length).toEqual(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|