Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 0 additions & 5 deletions frontend/tests/tests/test_analytics.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
var gamodule = require("gamodule");

window.apidata = {
base_url: "/",
prefix: "/"
};

QUnit.module("Google Analytics");
QUnit.test("test without analytics", function (assert) {
var result=[];
Expand Down
22 changes: 20 additions & 2 deletions frontend/tests/tests/user/mock_jsapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
name: "app1",
ui_name: "Application 1",
icon_128: "",
description: "description",
description: "This is obviously application 1",
policy: {
allow_home: true,
volume_source: "",
Expand All @@ -33,8 +33,26 @@ module.exports = {
volume_mode: ""
},
configurables: []
},
container: {
url_id: "654321"
}
}
},
"51993": {
image: {
name: "app3",
ui_name: "Application 3",
icon_128: "",
description: "This is application 3",
policy: {
allow_home: false,
volume_source: "foo",
volume_target: "bar",
volume_mode: "baz"
},
configurables: []
}
},
},
create: function() {
},
Expand Down
169 changes: 76 additions & 93 deletions frontend/tests/tests/user/test_application_label.js
Original file line number Diff line number Diff line change
@@ -1,106 +1,89 @@
var Vue = require("vuejs");
var ApplicationListModel = require("user/ApplicationListModel");
var ApplicationLabel = require("user/vue-components/ApplicationLabel");
let Vue = require("vuejs");
let ApplicationListModel = require("user/ApplicationListModel");
let ApplicationLabel = require("user/vue-components/ApplicationLabel");
require("filters");

QUnit.module("user.app_label");
QUnit.test("application name", function(assert) {
var done = assert.async();

var model = new ApplicationListModel();
var appLabel = new ApplicationLabel({
data: function() { return { model: model }; }
}).$mount();

model.update().done(function() {
Vue.nextTick(function() {
assert.equal(
appLabel.$el.querySelector('li > a > span').innerHTML,
model.appList[0].appData.image.ui_name
);

// Simulate changing currentApp
model.selectedIndex = 1;

Vue.nextTick(function() {
assert.equal(
appLabel.$el.querySelector('li > a > span').innerHTML,
model.appList[1].appData.image.ui_name
);

done();
});
let model, appLabel;

QUnit.module("user.app_label", {
beforeEach: function(assert) {
let done = assert.async();

model = new ApplicationListModel();
appLabel = new ApplicationLabel({
data: function() { return { model: model }; }
}).$mount();

model.update().done(function() {
Vue.nextTick(function() {done();});
});
}
});

QUnit.test("application name", function(assert) {
let done = assert.async();

assert.equal(
appLabel.$el.querySelector('li > a > span').innerHTML,
model.appList[0].appData.image.ui_name
);

// Simulate changing currentApp
model.selectedIndex = 1;

Vue.nextTick(function() {
assert.equal(
appLabel.$el.querySelector('li > a > span').innerHTML,
model.appList[1].appData.image.ui_name
);

done();
});
});

QUnit.test("rendering stop button", function (assert) {
var done = assert.async();

var model = new ApplicationListModel();
var appLabel = new ApplicationLabel({
data: function() { return { model: model }; }
}).$mount();

model.update().done(function() {
// Simulate application stopped
model.appList[0].status = 'STOPPED';

Vue.nextTick(function() {
assert.equal(
appLabel.$el.querySelector('li > a > span').innerHTML,
model.appList[0].appData.image.ui_name
);

// Test stop button disabled
assert.ok(
appLabel.$el.querySelector('#stop-button').classList.contains('disabled')
);

// Simulate application running
model.appList[0].status = 'RUNNING';

// Test stop button enabled
Vue.nextTick(function() {
assert.notOk(
appLabel.$el.querySelector('#stop-button').classList.contains('disabled')
);

done();
});
});
let done = assert.async();

assert.equal(
appLabel.$el.querySelector('li > a > span').innerHTML,
model.appList[0].appData.image.ui_name
);

// Test stop button disabled
assert.ok(
appLabel.$el.querySelector('#stop-button').classList.contains('disabled')
);

// Select running application
model.selectedIndex = 1;

// Test stop button enabled
Vue.nextTick(function() {
assert.notOk(
appLabel.$el.querySelector('#stop-button').classList.contains('disabled')
);

done();
});
});

QUnit.test("rendering share button", function (assert) {
var done = assert.async();

var model = new ApplicationListModel();
var appLabel = new ApplicationLabel({
data: function() { return { model: model }; }
}).$mount();

model.update().done(function() {
// Simulate application stopped
model.appList[0].status = 'STOPPED';

Vue.nextTick(function() {
// Test share button disabled
assert.ok(
appLabel.$el.querySelector('#share-button').classList.contains('disabled')
);

// Simulate application running
model.appList[0].status = 'RUNNING';

// Test share button disabled (Because clipboard save is not supported in test environment)
Vue.nextTick(function() {
assert.ok(
appLabel.$el.querySelector('#share-button').classList.contains('disabled')
);

done();
});
});
let done = assert.async();

// Test share button disabled
assert.ok(
appLabel.$el.querySelector('#share-button').classList.contains('disabled')
);

// Select running application
model.selectedIndex = 1;

// Test share button disabled (Because clipboard save is not supported in test environment)
Vue.nextTick(function() {
assert.ok(
appLabel.$el.querySelector('#share-button').classList.contains('disabled')
);

done();
});
});
39 changes: 17 additions & 22 deletions frontend/tests/tests/user/test_application_list_view.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
var Vue = require("vuejs");
var ApplicationListModel = require("user/ApplicationListModel");
var ApplicationListView = require("user/vue-components/ApplicationListView");
let Vue = require("vuejs");
let ApplicationListModel = require("user/ApplicationListModel");
let ApplicationListView = require("user/vue-components/ApplicationListView");
require("filters");

QUnit.module("user.app_list_view");
QUnit.test("rendering list", function (assert) {
var done = assert.async();
let model, appListView;

QUnit.module("user.app_list_view", {
beforeEach: function() {
model = new ApplicationListModel();
appListView = new ApplicationListView({
data: function() { return { model: model }; }
}).$mount();
}
});

var model = new ApplicationListModel();
var appListView = new ApplicationListView({
data: function() { return { model: model }; }
}).$mount();
QUnit.test("rendering list", function (assert) {
let done = assert.async();

assert.ok(model.loading);
assert.equal(
Expand All @@ -37,12 +42,7 @@ QUnit.test("rendering list", function (assert) {
});

QUnit.test("rendering nothing in the list", function (assert) {
var done = assert.async();

var model = new ApplicationListModel();
var appListView = new ApplicationListView({
data: function() { return { model: model }; }
}).$mount();
let done = assert.async();

model.loading = false;

Expand All @@ -65,12 +65,7 @@ QUnit.test("rendering nothing in the list", function (assert) {
});

QUnit.test("search form", function (assert) {
var done = assert.async();

var model = new ApplicationListModel();
var appListView = new ApplicationListView({
data: function() { return { model: model }; }
}).$mount();
let done = assert.async();

model.update().done(function() { Vue.nextTick(function() {
assert.notEqual(appListView.visibleList.length, 0);
Expand Down
Loading