1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
describe('Pad modal', function() {
context('when modal is a "force reconnect" message', function() {
var MODAL_SELECTOR = '#connectivity .slowcommit';
beforeEach(function(done) {
helper.newPad(function() {
// force a "slowcommit" error
helper.padChrome$.window.pad.handleChannelStateChange('DISCONNECTED', 'slowcommit');
// wait for modal to be displayed
var $modal = helper.padChrome$(MODAL_SELECTOR);
helper.waitFor(function() {
return $modal.is(':visible');
}, 50000).done(done);
});
this.timeout(60000);
});
it('disables editor', function(done) {
expect(isEditorDisabled()).to.be(true);
done();
});
context('and user clicks on editor', function() {
beforeEach(function() {
clickOnPadInner();
});
it('does not close the modal', function(done) {
var $modal = helper.padChrome$(MODAL_SELECTOR);
var modalIsVisible = $modal.is(':visible');
expect(modalIsVisible).to.be(true);
done();
});
});
context('and user clicks on pad outer', function() {
beforeEach(function() {
clickOnPadOuter();
});
it('does not close the modal', function(done) {
var $modal = helper.padChrome$(MODAL_SELECTOR);
var modalIsVisible = $modal.is(':visible');
expect(modalIsVisible).to.be(true);
done();
});
});
});
// we use "settings" here, but other modals have the same behaviour
context('when modal is not an error message', function() {
var MODAL_SELECTOR = '#settings';
beforeEach(function(done) {
helper.newPad(function() {
openSettingsAndWaitForModalToBeVisible(done);
});
this.timeout(60000);
});
it('does not disable editor', function(done) {
expect(isEditorDisabled()).to.be(false);
done();
});
context('and user clicks on editor', function() {
beforeEach(function() {
clickOnPadInner();
});
it('closes the modal', function(done) {
expect(isModalOpened(MODAL_SELECTOR)).to.be(false);
done();
});
});
context('and user clicks on pad outer', function() {
beforeEach(function() {
clickOnPadOuter();
});
it('closes the modal', function(done) {
expect(isModalOpened(MODAL_SELECTOR)).to.be(false);
done();
});
});
});
var clickOnPadInner = function() {
var $editor = helper.padInner$('#innerdocbody');
$editor.click();
}
var clickOnPadOuter = function() {
var $lineNumbersColumn = helper.padOuter$('#sidedivinner');
$lineNumbersColumn.click();
}
var openSettingsAndWaitForModalToBeVisible = function(done) {
helper.padChrome$('.buttonicon-settings').click();
// wait for modal to be displayed
var modalSelector = '#settings';
helper.waitFor(function() {
return isModalOpened(modalSelector);
}, 10000).done(done);
}
var isEditorDisabled = function() {
var editorDocument = helper.padOuter$("iframe[name='ace_inner']").get(0).contentDocument;
var editorBody = editorDocument.getElementById('innerdocbody');
var editorIsDisabled = editorBody.contentEditable === 'false' // IE/Safari
|| editorDocument.designMode === 'off'; // other browsers
return editorIsDisabled;
}
var isModalOpened = function(modalSelector) {
var $modal = helper.padChrome$(modalSelector);
return $modal.is(':visible');
}
});
|