Skip to content

Commit

Permalink
Test preview with dynamic fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
ifrost committed Nov 1, 2020
1 parent b3d8f80 commit 50c5a2b
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 7 deletions.
7 changes: 5 additions & 2 deletions js/core/view/control/dropdown.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
define(function(require) {

var Protoplast = require('protoplast');
var Protoplast = require('protoplast'),
BaseComponent = require('core/view/base-component');

var Dropdown = Protoplast.Component.extend({
var Dropdown = BaseComponent.extend({

html: '<select/>',

Expand All @@ -15,6 +16,8 @@ define(function(require) {
},

init: function() {
BaseComponent.init.call(this);

Protoplast.utils.bind(this, 'value', this.updateValue.bind(this));
Protoplast.utils.bind(this, 'options', this.setOptions.bind(this));

Expand Down
1 change: 1 addition & 0 deletions js/plugin/settings/model/settings-config-provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ define(function(require) {

createDropdown: function(key, label, options) {
var dropdown = Dropdown.create();
dropdown.id = key;
dropdown.options = options;
return SettingsEntry.create(key, label, dropdown);
},
Expand Down
2 changes: 1 addition & 1 deletion test/acceptance/helper/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ define(function(require) {

open_local_file: function(name, node) {
node.files.item = function() {
return this.files[name]
return this.files[name];
}.bind(this);
this.trigger(node, 'change');
},
Expand Down
7 changes: 6 additions & 1 deletion test/acceptance/helper/dom/settings-dom-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ define(function(require) {
*/
$load_last_opened: 'input[data-id="load_last_opened"]',

/**
* Font dropdown
*/
$font_family: 'select[data-id="font_family"]',

/**
* JavaScript PDF Viewer checkbox
*/
Expand All @@ -25,7 +30,7 @@ define(function(require) {
* @returns {boolean}
*/
js_pdf_viewer_is_checked: function() {
return $(this.$js_pdf_viewer).prop('checked')
return $(this.$js_pdf_viewer).prop('checked');
}

});
Expand Down
11 changes: 10 additions & 1 deletion test/acceptance/helper/user/base-user-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ define(function(require) {
throw new Error('Cannot click on selector "' + selector + '". Element not found.');
}
}
this.browser.tick(20000);
// previously tick(20000), replaced with a series of ticks to fix loading fonts dynamically (too long
// single tick causes timeouts in requirejs()
for (var i=0; i<100; i++) {
this.browser.tick(20);
}
},

click_button: function(label) {
Expand All @@ -54,6 +58,11 @@ define(function(require) {
options.which = options.which || 1;

this.trigger_event(selector, type, options);
},

set_value: function(selector, value) {
$(selector).prop("value", value);
this.trigger_event(selector, "change");
}

});
Expand Down
4 changes: 4 additions & 0 deletions test/acceptance/helper/user/settings-user-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ define(function(require) {
*/
select_open_last_used_on_startup: function() {
this.click(this.dom.settings.$load_last_opened);
},

change_font_family: function(font_family) {
this.set_value(this.dom.settings.$font_family, font_family);
}

});
Expand Down
21 changes: 19 additions & 2 deletions test/acceptance/spec/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@ define(function(require) {

var Env = require('acceptance/env');

describe('Preview', function() {
describe('Preview', function () {

var env;

beforeEach(function() {
beforeEach(function () {
env = Env.create();
env.scenarios.create_new_script('test');

env.user.theme.open_plugin("settings");
env.user.settings.change_font_family("Courier");
});

afterEach(function() {
Expand Down Expand Up @@ -115,6 +118,20 @@ define(function(require) {
env.dropbox.enable();
});

it('GIVEN embedded font is selected THEN the font is loaded dyamically', function (done) {

// GIVEN
env.user.theme.open_plugin('settings');
env.user.settings.change_font_family('CourierPrime');
env.user.theme.open_plugin('preview');

env.browser.wait(function() {
// THEN
env.assert.preview.preview_is_in_mode('embedded');
done();
}, 1000);
});

});

});

0 comments on commit 50c5a2b

Please sign in to comment.