summaryrefslogtreecommitdiff
path: root/spec/javascripts
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 15:57:13 +0100
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-04-07 16:12:59 +0100
commitb70d828f836f58aa9bc1af34fb6019857524619f (patch)
tree579ccac6b9d0f12ab5446500fdd5e85b7f42873d /spec/javascripts
parent99918be7312b11dd650924e39b2bf8b65a4004d8 (diff)
parent37e7fe2cc90de24c563fe70e4eff6f5d954bb630 (diff)
downloadgitlab-ce-b70d828f836f58aa9bc1af34fb6019857524619f.tar.gz
Merge branch 'master' into new-resolvable-discussion
Diffstat (limited to 'spec/javascripts')
-rw-r--r--spec/javascripts/build_spec.js106
1 files changed, 53 insertions, 53 deletions
diff --git a/spec/javascripts/build_spec.js b/spec/javascripts/build_spec.js
index cb48f14fd9a..edd4b3c1440 100644
--- a/spec/javascripts/build_spec.js
+++ b/spec/javascripts/build_spec.js
@@ -64,58 +64,33 @@ describe('Build', () => {
});
});
- describe('initial build trace', () => {
- beforeEach(() => {
- new Build();
- });
-
- it('displays the initial build trace', () => {
- expect($.ajax.calls.count()).toBe(1);
- const [{ url, dataType, success, context }] = $.ajax.calls.argsFor(0);
- expect(url).toBe(
- `${BUILD_URL}/trace.json`,
- );
- expect(dataType).toBe('json');
- expect(success).toEqual(jasmine.any(Function));
- spyOn(gl.utils, 'setCiStatusFavicon').and.callFake(() => {});
-
- success.call(context, { html: '<span>Example</span>', status: 'running' });
-
- expect($('#build-trace .js-build-output').text()).toMatch(/Example/);
- });
-
- it('removes the spinner', () => {
- const [{ success, context }] = $.ajax.calls.argsFor(0);
- spyOn(gl.utils, 'setCiStatusFavicon').and.callFake(() => {});
- success.call(context, { trace_html: '<span>Example</span>', status: 'success' });
-
- expect($('.js-build-refresh').length).toBe(0);
- });
- });
-
describe('running build', () => {
beforeEach(function () {
- $('.js-build-options').data('buildStatus', 'running');
this.build = new Build();
- spyOn(this.build, 'location').and.returnValue(BUILD_URL);
});
it('updates the build trace on an interval', function () {
+ spyOn(gl.utils, 'visitUrl');
+
jasmine.clock().tick(4001);
- expect($.ajax.calls.count()).toBe(2);
- let [{ url, dataType, success, context }] = $.ajax.calls.argsFor(1);
- expect(url).toBe(
- `${BUILD_URL}/trace.json?state=`,
- );
- expect(dataType).toBe('json');
- expect(success).toEqual(jasmine.any(Function));
-
- success.call(context, {
+ expect($.ajax.calls.count()).toBe(1);
+
+ // We have to do it this way to prevent Webpack to fail to compile
+ // when destructuring assignments and reusing
+ // the same variables names inside the same scope
+ let args = $.ajax.calls.argsFor(0)[0];
+
+ expect(args.url).toBe(`${BUILD_URL}/trace.json`);
+ expect(args.dataType).toBe('json');
+ expect(args.success).toEqual(jasmine.any(Function));
+
+ args.success.call($, {
html: '<span>Update<span>',
status: 'running',
state: 'newstate',
append: true,
+ complete: false,
});
expect($('#build-trace .js-build-output').text()).toMatch(/Update/);
@@ -123,17 +98,20 @@ describe('Build', () => {
jasmine.clock().tick(4001);
- expect($.ajax.calls.count()).toBe(3);
- [{ url, dataType, success, context }] = $.ajax.calls.argsFor(2);
- expect(url).toBe(`${BUILD_URL}/trace.json?state=newstate`);
- expect(dataType).toBe('json');
- expect(success).toEqual(jasmine.any(Function));
+ expect($.ajax.calls.count()).toBe(2);
+
+ args = $.ajax.calls.argsFor(1)[0];
+ expect(args.url).toBe(`${BUILD_URL}/trace.json`);
+ expect(args.dataType).toBe('json');
+ expect(args.data.state).toBe('newstate');
+ expect(args.success).toEqual(jasmine.any(Function));
- success.call(context, {
+ args.success.call($, {
html: '<span>More</span>',
status: 'running',
state: 'finalstate',
append: true,
+ complete: true,
});
expect($('#build-trace .js-build-output').text()).toMatch(/UpdateMore/);
@@ -141,19 +119,22 @@ describe('Build', () => {
});
it('replaces the entire build trace', () => {
+ spyOn(gl.utils, 'visitUrl');
+
jasmine.clock().tick(4001);
- let [{ success, context }] = $.ajax.calls.argsFor(1);
- success.call(context, {
+ let args = $.ajax.calls.argsFor(0)[0];
+ args.success.call($, {
html: '<span>Update</span>',
status: 'running',
- append: true,
+ append: false,
+ complete: false,
});
expect($('#build-trace .js-build-output').text()).toMatch(/Update/);
jasmine.clock().tick(4001);
- [{ success, context }] = $.ajax.calls.argsFor(2);
- success.call(context, {
+ args = $.ajax.calls.argsFor(1)[0];
+ args.success.call($, {
html: '<span>Different</span>',
status: 'running',
append: false,
@@ -163,15 +144,34 @@ describe('Build', () => {
expect($('#build-trace .js-build-output').text()).toMatch(/Different/);
});
+ it('shows information about truncated log', () => {
+ jasmine.clock().tick(4001);
+ const [{ success }] = $.ajax.calls.argsFor(0);
+
+ success.call($, {
+ html: '<span>Update</span>',
+ status: 'success',
+ append: false,
+ truncated: true,
+ size: '50',
+ });
+
+ expect(
+ $('#build-trace .js-truncated-info').text().trim(),
+ ).toContain('Showing last 50 KiB of log');
+ expect($('#build-trace .js-truncated-info-size').text()).toMatch('50');
+ });
+
it('reloads the page when the build is done', () => {
spyOn(gl.utils, 'visitUrl');
jasmine.clock().tick(4001);
- const [{ success, context }] = $.ajax.calls.argsFor(1);
- success.call(context, {
+ const [{ success }] = $.ajax.calls.argsFor(0);
+ success.call($, {
html: '<span>Final</span>',
status: 'passed',
append: true,
+ complete: true,
});
expect(gl.utils.visitUrl).toHaveBeenCalledWith(BUILD_URL);