' || kb.test(f)
+ ? 0
+ : h
+ : h.firstChild),
+ (e = f && f.childNodes.length)
+ while (e--)
+ m.nodeName((j = f.childNodes[e]), 'tbody') &&
+ !j.childNodes.length &&
+ f.removeChild(j)
+ }
+ m.merge(p, h.childNodes), (h.textContent = '')
+ while (h.firstChild) h.removeChild(h.firstChild)
+ h = o.lastChild
+ } else p.push(b.createTextNode(f))
+ h && o.removeChild(h),
+ k.appendChecked || m.grep(ub(p, 'input'), vb),
+ (q = 0)
+ while ((f = p[q++]))
+ if (
+ (!d || m.inArray(f, d) === -1) &&
+ ((g = m.contains(f.ownerDocument, f)),
+ (h = ub(o.appendChild(f), 'script')),
+ g && zb(h),
+ c)
+ ) {
+ e = 0
+ while ((f = h[e++])) ob.test(f.type || '') && c.push(f)
+ }
+ return (h = null), o
+ },
+ cleanData: function(a, b) {
+ for (
+ var d,
+ e,
+ f,
+ g,
+ h = 0,
+ i = m.expando,
+ j = m.cache,
+ l = k.deleteExpando,
+ n = m.event.special;
+ (d = a[h]) != null;
+ h++
+ )
+ if ((b || m.acceptData(d)) && ((f = d[i]), (g = f && j[f]))) {
+ if (g.events)
+ for (e in g.events)
+ n[e] ? m.event.remove(d, e) : m.removeEvent(d, e, g.handle)
+ j[f] &&
+ (delete j[f],
+ l
+ ? delete d[i]
+ : typeof d.removeAttribute !== K
+ ? d.removeAttribute(i)
+ : (d[i] = null),
+ c.push(f))
+ }
+ }
+ }),
+ m.fn.extend({
+ text: function(a) {
+ return V(
+ this,
+ function(a) {
+ return void 0 === a
+ ? m.text(this)
+ : this.empty().append(
+ ((this[0] && this[0].ownerDocument) || y).createTextNode(a)
+ )
+ },
+ null,
+ a,
+ arguments.length
+ )
+ },
+ append: function() {
+ return this.domManip(arguments, function(a) {
+ if (
+ this.nodeType === 1 ||
+ this.nodeType === 11 ||
+ this.nodeType === 9
+ ) {
+ const b = wb(this, a)
+ b.appendChild(a)
+ }
+ })
+ },
+ prepend: function() {
+ return this.domManip(arguments, function(a) {
+ if (
+ this.nodeType === 1 ||
+ this.nodeType === 11 ||
+ this.nodeType === 9
+ ) {
+ const b = wb(this, a)
+ b.insertBefore(a, b.firstChild)
+ }
+ })
+ },
+ before: function() {
+ return this.domManip(arguments, function(a) {
+ this.parentNode && this.parentNode.insertBefore(a, this)
+ })
+ },
+ after: function() {
+ return this.domManip(arguments, function(a) {
+ this.parentNode && this.parentNode.insertBefore(a, this.nextSibling)
+ })
+ },
+ remove: function(a, b) {
+ for (
+ var c, d = a ? m.filter(a, this) : this, e = 0;
+ (c = d[e]) != null;
+ e++
+ )
+ b || c.nodeType !== 1 || m.cleanData(ub(c)),
+ c.parentNode &&
+ (b && m.contains(c.ownerDocument, c) && zb(ub(c, 'script')),
+ c.parentNode.removeChild(c))
+ return this
+ },
+ empty: function() {
+ for (var a, b = 0; (a = this[b]) != null; b++) {
+ a.nodeType === 1 && m.cleanData(ub(a, !1))
+ while (a.firstChild) a.removeChild(a.firstChild)
+ a.options && m.nodeName(a, 'select') && (a.options.length = 0)
+ }
+ return this
+ },
+ clone: function(a, b) {
+ return (
+ (a = a == null ? !1 : a),
+ (b = b == null ? a : b),
+ this.map(function() {
+ return m.clone(this, a, b)
+ })
+ )
+ },
+ html: function(a) {
+ return V(
+ this,
+ function(a) {
+ let b = this[0] || {};
+ let c = 0;
+ const d = this.length
+ if (void 0 === a)
+ return b.nodeType === 1 ? b.innerHTML.replace(fb, '') : void 0
+ if (
+ !(
+ typeof a !== 'string' ||
+ mb.test(a) ||
+ (!k.htmlSerialize && gb.test(a)) ||
+ (!k.leadingWhitespace && hb.test(a)) ||
+ rb[(jb.exec(a) || ['', ''])[1].toLowerCase()]
+ )
+ ) {
+ a = a.replace(ib, '<$1>$2>')
+ try {
+ for (; d > c; c++)
+ (b = this[c] || {}),
+ b.nodeType === 1 &&
+ (m.cleanData(ub(b, !1)), (b.innerHTML = a))
+ b = 0
+ } catch (e) {}
+ }
+ b && this.empty().append(a)
+ },
+ null,
+ a,
+ arguments.length
+ )
+ },
+ replaceWith: function() {
+ let a = arguments[0]
+ return (
+ this.domManip(arguments, function(b) {
+ ;(a = this.parentNode),
+ m.cleanData(ub(this)),
+ a && a.replaceChild(b, this)
+ }),
+ a && (a.length || a.nodeType) ? this : this.remove()
+ )
+ },
+ detach: function(a) {
+ return this.remove(a, !0)
+ },
+ domManip: function(a, b) {
+ a = e.apply([], a)
+ let c;
+ let d;
+ let f;
+ let g;
+ let h;
+ let i;
+ let j = 0;
+ const l = this.length;
+ const n = this;
+ const o = l - 1;
+ const p = a[0];
+ const q = m.isFunction(p)
+ if (q || (l > 1 && typeof p === 'string' && !k.checkClone && nb.test(p)))
+ return this.each(function(c) {
+ const d = n.eq(c)
+ q && (a[0] = p.call(this, c, d.html())), d.domManip(a, b)
+ })
+ if (
+ l &&
+ ((i = m.buildFragment(a, this[0].ownerDocument, !1, this)),
+ (c = i.firstChild),
+ i.childNodes.length === 1 && (i = c),
+ c)
+ ) {
+ for (g = m.map(ub(i, 'script'), xb), f = g.length; l > j; j++)
+ (d = i),
+ j !== o &&
+ ((d = m.clone(d, !0, !0)), f && m.merge(g, ub(d, 'script'))),
+ b.call(this[j], d, j)
+ if (f)
+ for (
+ h = g[g.length - 1].ownerDocument, m.map(g, yb), j = 0;
+ f > j;
+ j++
+ )
+ (d = g[j]),
+ ob.test(d.type || '') &&
+ !m._data(d, 'globalEval') &&
+ m.contains(h, d) &&
+ (d.src
+ ? m._evalUrl && m._evalUrl(d.src)
+ : m.globalEval(
+ (d.text || d.textContent || d.innerHTML || '').replace(
+ qb,
+ ''
+ )
+ ))
+ i = c = null
+ }
+ return this
+ }
+ }),
+ m.each(
+ {
+ appendTo: 'append',
+ prependTo: 'prepend',
+ insertBefore: 'before',
+ insertAfter: 'after',
+ replaceAll: 'replaceWith'
+ },
+ function(a, b) {
+ m.fn[a] = function(a) {
+ for (var c, d = 0, e = [], g = m(a), h = g.length - 1; h >= d; d++)
+ (c = d === h ? this : this.clone(!0)),
+ m(g[d])[b](c),
+ f.apply(e, c.get())
+ return this.pushStack(e)
+ }
+ }
+ )
+ let Cb;
+ const Db = {}
+ function Eb(b, c) {
+ let d;
+ const e = m(c.createElement(b)).appendTo(c.body);
+ const f =
+ a.getDefaultComputedStyle && (d = a.getDefaultComputedStyle(e[0]))
+ ? d.display
+ : m.css(e[0], 'display')
+ return e.detach(), f
+ }
+ function Fb(a) {
+ let b = y;
+ let c = Db[a]
+ return (
+ c ||
+ ((c = Eb(a, b)),
+ (c !== 'none' && c) ||
+ ((Cb = (
+ Cb || m("")
+ ).appendTo(b.documentElement)),
+ (b = (Cb[0].contentWindow || Cb[0].contentDocument).document),
+ b.write(),
+ b.close(),
+ (c = Eb(a, b)),
+ Cb.detach()),
+ (Db[a] = c)),
+ c
+ )
+ }
+ !(function() {
+ let a
+ k.shrinkWrapBlocks = function() {
+ if (a != null) return a
+ a = !1
+ let b, c, d
+ return (
+ (c = y.getElementsByTagName('body')[0]),
+ c && c.style
+ ? ((b = y.createElement('div')),
+ (d = y.createElement('div')),
+ (d.style.cssText =
+ 'position:absolute;border:0;width:0;height:0;top:0;left:-9999px'),
+ c.appendChild(d).appendChild(b),
+ typeof b.style.zoom !== K &&
+ ((b.style.cssText =
+ '-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:1px;width:1px;zoom:1'),
+ (b.appendChild(y.createElement('div')).style.width = '5px'),
+ (a = b.offsetWidth !== 3)),
+ c.removeChild(d),
+ a)
+ : void 0
+ )
+ }
+ })()
+ const Gb = /^margin/;
+ const Hb = new RegExp('^(' + S + ')(?!px)[a-z%]+$', 'i');
+ let Ib;
+ let Jb;
+ const Kb = /^(top|right|bottom|left)$/
+ a.getComputedStyle
+ ? ((Ib = function(b) {
+ return b.ownerDocument.defaultView.opener
+ ? b.ownerDocument.defaultView.getComputedStyle(b, null)
+ : a.getComputedStyle(b, null)
+ }),
+ (Jb = function(a, b, c) {
+ let d;
+ let e;
+ let f;
+ let g;
+ const h = a.style
+ return (
+ (c = c || Ib(a)),
+ (g = c ? c.getPropertyValue(b) || c[b] : void 0),
+ c &&
+ (g !== '' || m.contains(a.ownerDocument, a) || (g = m.style(a, b)),
+ Hb.test(g) &&
+ Gb.test(b) &&
+ ((d = h.width),
+ (e = h.minWidth),
+ (f = h.maxWidth),
+ (h.minWidth = h.maxWidth = h.width = g),
+ (g = c.width),
+ (h.width = d),
+ (h.minWidth = e),
+ (h.maxWidth = f))),
+ void 0 === g ? g : g + ''
+ )
+ }))
+ : y.documentElement.currentStyle &&
+ ((Ib = function(a) {
+ return a.currentStyle
+ }),
+ (Jb = function(a, b, c) {
+ let d;
+ let e;
+ let f;
+ let g;
+ const h = a.style
+ return (
+ (c = c || Ib(a)),
+ (g = c ? c[b] : void 0),
+ g == null && h && h[b] && (g = h[b]),
+ Hb.test(g) &&
+ !Kb.test(b) &&
+ ((d = h.left),
+ (e = a.runtimeStyle),
+ (f = e && e.left),
+ f && (e.left = a.currentStyle.left),
+ (h.left = b === 'fontSize' ? '1em' : g),
+ (g = h.pixelLeft + 'px'),
+ (h.left = d),
+ f && (e.left = f)),
+ void 0 === g ? g : g + '' || 'auto'
+ )
+ }))
+ function Lb(a, b) {
+ return {
+ get: function() {
+ const c = a()
+ if (c != null)
+ return c
+ ? void delete this.get
+ : (this.get = b).apply(this, arguments)
+ }
+ }
+ }
+ !(function() {
+ let b, c, d, e, f, g, h
+ if (
+ ((b = y.createElement('div')),
+ (b.innerHTML =
+ " a "),
+ (d = b.getElementsByTagName('a')[0]),
+ (c = d && d.style))
+ ) {
+ ;(c.cssText = 'float:left;opacity:.5'),
+ (k.opacity = c.opacity === '0.5'),
+ (k.cssFloat = !!c.cssFloat),
+ (b.style.backgroundClip = 'content-box'),
+ (b.cloneNode(!0).style.backgroundClip = ''),
+ (k.clearCloneStyle = b.style.backgroundClip === 'content-box'),
+ (k.boxSizing =
+ c.boxSizing === '' ||
+ c.MozBoxSizing === '' ||
+ c.WebkitBoxSizing === ''),
+ m.extend(k, {
+ reliableHiddenOffsets: function() {
+ return g == null && i(), g
+ },
+ boxSizingReliable: function() {
+ return f == null && i(), f
+ },
+ pixelPosition: function() {
+ return e == null && i(), e
+ },
+ reliableMarginRight: function() {
+ return h == null && i(), h
+ }
+ })
+ function i() {
+ let b, c, d, i
+ ;(c = y.getElementsByTagName('body')[0]),
+ c &&
+ c.style &&
+ ((b = y.createElement('div')),
+ (d = y.createElement('div')),
+ (d.style.cssText =
+ 'position:absolute;border:0;width:0;height:0;top:0;left:-9999px'),
+ c.appendChild(d).appendChild(b),
+ (b.style.cssText =
+ '-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;display:block;margin-top:1%;top:1%;border:1px;padding:1px;width:4px;position:absolute'),
+ (e = f = !1),
+ (h = !0),
+ a.getComputedStyle &&
+ ((e = (a.getComputedStyle(b, null) || {}).top !== '1%'),
+ (f =
+ (a.getComputedStyle(b, null) || { width: '4px' }).width ===
+ '4px'),
+ (i = b.appendChild(y.createElement('div'))),
+ (i.style.cssText = b.style.cssText =
+ '-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;display:block;margin:0;border:0;padding:0'),
+ (i.style.marginRight = i.style.width = '0'),
+ (b.style.width = '1px'),
+ (h = !parseFloat(
+ (a.getComputedStyle(i, null) || {}).marginRight
+ )),
+ b.removeChild(i)),
+ (b.innerHTML = ''),
+ (i = b.getElementsByTagName('td')),
+ (i[0].style.cssText = 'margin:0;border:0;padding:0;display:none'),
+ (g = i[0].offsetHeight === 0),
+ g &&
+ ((i[0].style.display = ''),
+ (i[1].style.display = 'none'),
+ (g = i[0].offsetHeight === 0)),
+ c.removeChild(d))
+ }
+ }
+ })(),
+ (m.swap = function(a, b, c, d) {
+ let e;
+ let f;
+ const g = {}
+ for (f in b) (g[f] = a.style[f]), (a.style[f] = b[f])
+ e = c.apply(a, d || [])
+ for (f in b) a.style[f] = g[f]
+ return e
+ })
+ const Mb = /alpha\([^)]*\)/i;
+ const Nb = /opacity\s*=\s*([^)]*)/;
+ const Ob = /^(none|table(?!-c[ea]).+)/;
+ const Pb = new RegExp('^(' + S + ')(.*)$', 'i');
+ const Qb = new RegExp('^([+-])=(' + S + ')', 'i');
+ const Rb = { position: 'absolute', visibility: 'hidden', display: 'block' };
+ const Sb = { letterSpacing: '0', fontWeight: '400' };
+ const Tb = ['Webkit', 'O', 'Moz', 'ms']
+ function Ub(a, b) {
+ if (b in a) return b
+ const c = b.charAt(0).toUpperCase() + b.slice(1);
+ const d = b;
+ let e = Tb.length
+ while (e--) if (((b = Tb[e] + c), b in a)) return b
+ return d
+ }
+ function Vb(a, b) {
+ for (var c, d, e, f = [], g = 0, h = a.length; h > g; g++)
+ (d = a[g]),
+ d.style &&
+ ((f[g] = m._data(d, 'olddisplay')),
+ (c = d.style.display),
+ b
+ ? (f[g] || c !== 'none' || (d.style.display = ''),
+ d.style.display === '' &&
+ U(d) &&
+ (f[g] = m._data(d, 'olddisplay', Fb(d.nodeName))))
+ : ((e = U(d)),
+ ((c && c !== 'none') || !e) &&
+ m._data(d, 'olddisplay', e ? c : m.css(d, 'display'))))
+ for (g = 0; h > g; g++)
+ (d = a[g]),
+ d.style &&
+ ((b && d.style.display !== 'none' && d.style.display !== '') ||
+ (d.style.display = b ? f[g] || '' : 'none'))
+ return a
+ }
+ function Wb(a, b, c) {
+ const d = Pb.exec(b)
+ return d ? Math.max(0, d[1] - (c || 0)) + (d[2] || 'px') : b
+ }
+ function Xb(a, b, c, d, e) {
+ for (
+ var f = c === (d ? 'border' : 'content') ? 4 : b === 'width' ? 1 : 0,
+ g = 0;
+ f < 4;
+ f += 2
+ )
+ c === 'margin' && (g += m.css(a, c + T[f], !0, e)),
+ d
+ ? (c === 'content' && (g -= m.css(a, 'padding' + T[f], !0, e)),
+ c !== 'margin' && (g -= m.css(a, 'border' + T[f] + 'Width', !0, e)))
+ : ((g += m.css(a, 'padding' + T[f], !0, e)),
+ c !== 'padding' &&
+ (g += m.css(a, 'border' + T[f] + 'Width', !0, e)))
+ return g
+ }
+ function Yb(a, b, c) {
+ let d = !0;
+ let e = b === 'width' ? a.offsetWidth : a.offsetHeight;
+ const f = Ib(a);
+ const g = k.boxSizing && m.css(a, 'boxSizing', !1, f) === 'border-box'
+ if (e <= 0 || e == null) {
+ if (
+ ((e = Jb(a, b, f)),
+ (e < 0 || e == null) && (e = a.style[b]),
+ Hb.test(e))
+ )
+ return e
+ ;(d = g && (k.boxSizingReliable() || e === a.style[b])),
+ (e = parseFloat(e) || 0)
+ }
+ return e + Xb(a, b, c || (g ? 'border' : 'content'), d, f) + 'px'
+ }
+ m.extend({
+ cssHooks: {
+ opacity: {
+ get: function(a, b) {
+ if (b) {
+ const c = Jb(a, 'opacity')
+ return c === '' ? '1' : c
+ }
+ }
+ }
+ },
+ cssNumber: {
+ columnCount: !0,
+ fillOpacity: !0,
+ flexGrow: !0,
+ flexShrink: !0,
+ fontWeight: !0,
+ lineHeight: !0,
+ opacity: !0,
+ order: !0,
+ orphans: !0,
+ widows: !0,
+ zIndex: !0,
+ zoom: !0
+ },
+ cssProps: { float: k.cssFloat ? 'cssFloat' : 'styleFloat' },
+ style: function(a, b, c, d) {
+ if (a && a.nodeType !== 3 && a.nodeType !== 8 && a.style) {
+ let e;
+ let f;
+ let g;
+ const h = m.camelCase(b);
+ const i = a.style
+ if (
+ ((b = m.cssProps[h] || (m.cssProps[h] = Ub(i, h))),
+ (g = m.cssHooks[b] || m.cssHooks[h]),
+ void 0 === c)
+ )
+ return g && 'get' in g && void 0 !== (e = g.get(a, !1, d)) ? e : i[b]
+ if (
+ ((f = typeof c),
+ f === 'string' &&
+ (e = Qb.exec(c)) &&
+ ((c = (e[1] + 1) * e[2] + parseFloat(m.css(a, b))), (f = 'number')),
+ c != null &&
+ c === c &&
+ (f !== 'number' || m.cssNumber[h] || (c += 'px'),
+ k.clearCloneStyle ||
+ c !== '' ||
+ b.indexOf('background') !== 0 ||
+ (i[b] = 'inherit'),
+ !(g && 'set' in g && void 0 === (c = g.set(a, c, d)))))
+ )
+ try {
+ i[b] = c
+ } catch (j) {}
+ }
+ },
+ css: function(a, b, c, d) {
+ let e;
+ let f;
+ let g;
+ const h = m.camelCase(b)
+ return (
+ (b = m.cssProps[h] || (m.cssProps[h] = Ub(a.style, h))),
+ (g = m.cssHooks[b] || m.cssHooks[h]),
+ g && 'get' in g && (f = g.get(a, !0, c)),
+ void 0 === f && (f = Jb(a, b, d)),
+ f === 'normal' && b in Sb && (f = Sb[b]),
+ c === '' || c
+ ? ((e = parseFloat(f)), c === !0 || m.isNumeric(e) ? e || 0 : f)
+ : f
+ )
+ }
+ }),
+ m.each(['height', 'width'], function(a, b) {
+ m.cssHooks[b] = {
+ get: function(a, c, d) {
+ return c
+ ? Ob.test(m.css(a, 'display')) && a.offsetWidth === 0
+ ? m.swap(a, Rb, function() {
+ return Yb(a, b, d)
+ })
+ : Yb(a, b, d)
+ : void 0
+ },
+ set: function(a, c, d) {
+ const e = d && Ib(a)
+ return Wb(
+ a,
+ c,
+ d
+ ? Xb(
+ a,
+ b,
+ d,
+ k.boxSizing && m.css(a, 'boxSizing', !1, e) === 'border-box',
+ e
+ )
+ : 0
+ )
+ }
+ }
+ }),
+ k.opacity ||
+ (m.cssHooks.opacity = {
+ get: function(a, b) {
+ return Nb.test(
+ (b && a.currentStyle ? a.currentStyle.filter : a.style.filter) || ''
+ )
+ ? 0.01 * parseFloat(RegExp.$1) + ''
+ : b
+ ? '1'
+ : ''
+ },
+ set: function(a, b) {
+ const c = a.style;
+ const d = a.currentStyle;
+ const e = m.isNumeric(b) ? 'alpha(opacity=' + 100 * b + ')' : '';
+ const f = (d && d.filter) || c.filter || ''
+ ;(c.zoom = 1),
+ ((b >= 1 || b === '') &&
+ m.trim(f.replace(Mb, '')) === '' &&
+ c.removeAttribute &&
+ (c.removeAttribute('filter'), b === '' || (d && !d.filter))) ||
+ (c.filter = Mb.test(f) ? f.replace(Mb, e) : f + ' ' + e)
+ }
+ }),
+ (m.cssHooks.marginRight = Lb(k.reliableMarginRight, function(a, b) {
+ return b
+ ? m.swap(a, { display: 'inline-block' }, Jb, [a, 'marginRight'])
+ : void 0
+ })),
+ m.each({ margin: '', padding: '', border: 'Width' }, function(a, b) {
+ ;(m.cssHooks[a + b] = {
+ expand: function(c) {
+ for (
+ var d = 0, e = {}, f = typeof c === 'string' ? c.split(' ') : [c];
+ d < 4;
+ d++
+ )
+ e[a + T[d] + b] = f[d] || f[d - 2] || f[0]
+ return e
+ }
+ }),
+ Gb.test(a) || (m.cssHooks[a + b].set = Wb)
+ }),
+ m.fn.extend({
+ css: function(a, b) {
+ return V(
+ this,
+ function(a, b, c) {
+ let d;
+ let e;
+ const f = {};
+ let g = 0
+ if (m.isArray(b)) {
+ for (d = Ib(a), e = b.length; e > g; g++)
+ f[b[g]] = m.css(a, b[g], !1, d)
+ return f
+ }
+ return void 0 !== c ? m.style(a, b, c) : m.css(a, b)
+ },
+ a,
+ b,
+ arguments.length > 1
+ )
+ },
+ show: function() {
+ return Vb(this, !0)
+ },
+ hide: function() {
+ return Vb(this)
+ },
+ toggle: function(a) {
+ return typeof a === 'boolean'
+ ? a
+ ? this.show()
+ : this.hide()
+ : this.each(function() {
+ U(this) ? m(this).show() : m(this).hide()
+ })
+ }
+ })
+ function Zb(a, b, c, d, e) {
+ return new Zb.prototype.init(a, b, c, d, e)
+ }
+ ;(m.Tween = Zb),
+ (Zb.prototype = {
+ constructor: Zb,
+ init: function(a, b, c, d, e, f) {
+ ;(this.elem = a),
+ (this.prop = c),
+ (this.easing = e || 'swing'),
+ (this.options = b),
+ (this.start = this.now = this.cur()),
+ (this.end = d),
+ (this.unit = f || (m.cssNumber[c] ? '' : 'px'))
+ },
+ cur: function() {
+ const a = Zb.propHooks[this.prop]
+ return a && a.get ? a.get(this) : Zb.propHooks._default.get(this)
+ },
+ run: function(a) {
+ let b;
+ const c = Zb.propHooks[this.prop]
+ return (
+ (this.pos = b = this.options.duration
+ ? m.easing[this.easing](
+ a,
+ this.options.duration * a,
+ 0,
+ 1,
+ this.options.duration
+ )
+ : a),
+ (this.now = (this.end - this.start) * b + this.start),
+ this.options.step &&
+ this.options.step.call(this.elem, this.now, this),
+ c && c.set ? c.set(this) : Zb.propHooks._default.set(this),
+ this
+ )
+ }
+ }),
+ (Zb.prototype.init.prototype = Zb.prototype),
+ (Zb.propHooks = {
+ _default: {
+ get: function(a) {
+ let b
+ return a.elem[a.prop] == null ||
+ (a.elem.style && a.elem.style[a.prop] != null)
+ ? ((b = m.css(a.elem, a.prop, '')), b && b !== 'auto' ? b : 0)
+ : a.elem[a.prop]
+ },
+ set: function(a) {
+ m.fx.step[a.prop]
+ ? m.fx.step[a.prop](a)
+ : a.elem.style &&
+ (a.elem.style[m.cssProps[a.prop]] != null || m.cssHooks[a.prop])
+ ? m.style(a.elem, a.prop, a.now + a.unit)
+ : (a.elem[a.prop] = a.now)
+ }
+ }
+ }),
+ (Zb.propHooks.scrollTop = Zb.propHooks.scrollLeft = {
+ set: function(a) {
+ a.elem.nodeType && a.elem.parentNode && (a.elem[a.prop] = a.now)
+ }
+ }),
+ (m.easing = {
+ linear: function(a) {
+ return a
+ },
+ swing: function(a) {
+ return 0.5 - Math.cos(a * Math.PI) / 2
+ }
+ }),
+ (m.fx = Zb.prototype.init),
+ (m.fx.step = {})
+ let $b;
+ let _b;
+ const ac = /^(?:toggle|show|hide)$/;
+ const bc = new RegExp('^(?:([+-])=|)(' + S + ')([a-z%]*)$', 'i');
+ const cc = /queueHooks$/;
+ const dc = [ic];
+ const ec = {
+ '*': [
+ function(a, b) {
+ const c = this.createTween(a, b);
+ const d = c.cur();
+ let e = bc.exec(b);
+ let f = (e && e[3]) || (m.cssNumber[a] ? '' : 'px');
+ let g =
+ (m.cssNumber[a] || (f !== 'px' && +d)) &&
+ bc.exec(m.css(c.elem, a));
+ let h = 1;
+ let i = 20
+ if (g && g[3] !== f) {
+ ;(f = f || g[3]), (e = e || []), (g = +d || 1)
+ do (h = h || '.5'), (g /= h), m.style(c.elem, a, g + f)
+ while (h !== (h = c.cur() / d) && h !== 1 && --i)
+ }
+ return (
+ e &&
+ ((g = c.start = +g || +d || 0),
+ (c.unit = f),
+ (c.end = e[1] ? g + (e[1] + 1) * e[2] : +e[2])),
+ c
+ )
+ }
+ ]
+ }
+ function fc() {
+ return (
+ setTimeout(function() {
+ $b = void 0
+ }),
+ ($b = m.now())
+ )
+ }
+ function gc(a, b) {
+ let c;
+ const d = { height: a };
+ let e = 0
+ for (b = b ? 1 : 0; e < 4; e += 2 - b)
+ (c = T[e]), (d['margin' + c] = d['padding' + c] = a)
+ return b && (d.opacity = d.width = a), d
+ }
+ function hc(a, b, c) {
+ for (
+ var d, e = (ec[b] || []).concat(ec['*']), f = 0, g = e.length;
+ g > f;
+ f++
+ )
+ if ((d = e[f].call(c, b, a))) return d
+ }
+ function ic(a, b, c) {
+ let d;
+ let e;
+ let f;
+ let g;
+ let h;
+ let i;
+ let j;
+ let l;
+ const n = this;
+ const o = {};
+ const p = a.style;
+ let q = a.nodeType && U(a);
+ let r = m._data(a, 'fxshow')
+ c.queue ||
+ ((h = m._queueHooks(a, 'fx')),
+ h.unqueued == null &&
+ ((h.unqueued = 0),
+ (i = h.empty.fire),
+ (h.empty.fire = function() {
+ h.unqueued || i()
+ })),
+ h.unqueued++,
+ n.always(function() {
+ n.always(function() {
+ h.unqueued--, m.queue(a, 'fx').length || h.empty.fire()
+ })
+ })),
+ a.nodeType === 1 &&
+ ('height' in b || 'width' in b) &&
+ ((c.overflow = [p.overflow, p.overflowX, p.overflowY]),
+ (j = m.css(a, 'display')),
+ (l = j === 'none' ? m._data(a, 'olddisplay') || Fb(a.nodeName) : j),
+ l === 'inline' &&
+ m.css(a, 'float') === 'none' &&
+ (k.inlineBlockNeedsLayout && Fb(a.nodeName) !== 'inline'
+ ? (p.zoom = 1)
+ : (p.display = 'inline-block'))),
+ c.overflow &&
+ ((p.overflow = 'hidden'),
+ k.shrinkWrapBlocks() ||
+ n.always(function() {
+ ;(p.overflow = c.overflow[0]),
+ (p.overflowX = c.overflow[1]),
+ (p.overflowY = c.overflow[2])
+ }))
+ for (d in b)
+ if (((e = b[d]), ac.exec(e))) {
+ if (
+ (delete b[d], (f = f || e === 'toggle'), e === (q ? 'hide' : 'show'))
+ ) {
+ if (e !== 'show' || !r || void 0 === r[d]) continue
+ q = !0
+ }
+ o[d] = (r && r[d]) || m.style(a, d)
+ } else j = void 0
+ if (m.isEmptyObject(o))
+ (j === 'none' ? Fb(a.nodeName) : j) === 'inline' && (p.display = j)
+ else {
+ r ? 'hidden' in r && (q = r.hidden) : (r = m._data(a, 'fxshow', {})),
+ f && (r.hidden = !q),
+ q
+ ? m(a).show()
+ : n.done(function() {
+ m(a).hide()
+ }),
+ n.done(function() {
+ let b
+ m._removeData(a, 'fxshow')
+ for (b in o) m.style(a, b, o[b])
+ })
+ for (d in o)
+ (g = hc(q ? r[d] : 0, d, n)),
+ d in r ||
+ ((r[d] = g.start),
+ q &&
+ ((g.end = g.start),
+ (g.start = d === 'width' || d === 'height' ? 1 : 0)))
+ }
+ }
+ function jc(a, b) {
+ let c, d, e, f, g
+ for (c in a)
+ if (
+ ((d = m.camelCase(c)),
+ (e = b[d]),
+ (f = a[c]),
+ m.isArray(f) && ((e = f[1]), (f = a[c] = f[0])),
+ c !== d && ((a[d] = f), delete a[c]),
+ (g = m.cssHooks[d]),
+ g && 'expand' in g)
+ ) {
+ ;(f = g.expand(f)), delete a[d]
+ for (c in f) c in a || ((a[c] = f[c]), (b[c] = e))
+ } else b[d] = e
+ }
+ function kc(a, b, c) {
+ let d;
+ let e;
+ let f = 0;
+ const g = dc.length;
+ const h = m.Deferred().always(function() {
+ delete i.elem
+ });
+ var i = function() {
+ if (e) return !1
+ for (
+ var b = $b || fc(),
+ c = Math.max(0, j.startTime + j.duration - b),
+ d = c / j.duration || 0,
+ f = 1 - d,
+ g = 0,
+ i = j.tweens.length;
+ i > g;
+ g++
+ )
+ j.tweens[g].run(f)
+ return (
+ h.notifyWith(a, [j, f, c]),
+ f < 1 && i ? c : (h.resolveWith(a, [j]), !1)
+ )
+ };
+ var j = h.promise({
+ elem: a,
+ props: m.extend({}, b),
+ opts: m.extend(!0, { specialEasing: {} }, c),
+ originalProperties: b,
+ originalOptions: c,
+ startTime: $b || fc(),
+ duration: c.duration,
+ tweens: [],
+ createTween: function(b, c) {
+ const d = m.Tween(
+ a,
+ j.opts,
+ b,
+ c,
+ j.opts.specialEasing[b] || j.opts.easing
+ )
+ return j.tweens.push(d), d
+ },
+ stop: function(b) {
+ let c = 0;
+ const d = b ? j.tweens.length : 0
+ if (e) return this
+ for (e = !0; d > c; c++) j.tweens[c].run(1)
+ return b ? h.resolveWith(a, [j, b]) : h.rejectWith(a, [j, b]), this
+ }
+ });
+ const k = j.props
+ for (jc(k, j.opts.specialEasing); g > f; f++)
+ if ((d = dc[f].call(j, a, k, j.opts))) return d
+ return (
+ m.map(k, hc, j),
+ m.isFunction(j.opts.start) && j.opts.start.call(a, j),
+ m.fx.timer(m.extend(i, { elem: a, anim: j, queue: j.opts.queue })),
+ j
+ .progress(j.opts.progress)
+ .done(j.opts.done, j.opts.complete)
+ .fail(j.opts.fail)
+ .always(j.opts.always)
+ )
+ }
+ ;(m.Animation = m.extend(kc, {
+ tweener: function(a, b) {
+ m.isFunction(a) ? ((b = a), (a = ['*'])) : (a = a.split(' '))
+ for (var c, d = 0, e = a.length; e > d; d++)
+ (c = a[d]), (ec[c] = ec[c] || []), ec[c].unshift(b)
+ },
+ prefilter: function(a, b) {
+ b ? dc.unshift(a) : dc.push(a)
+ }
+ })),
+ (m.speed = function(a, b, c) {
+ const d =
+ a && typeof a === 'object'
+ ? m.extend({}, a)
+ : {
+ complete: c || (!c && b) || (m.isFunction(a) && a),
+ duration: a,
+ easing: (c && b) || (b && !m.isFunction(b) && b)
+ }
+ return (
+ (d.duration = m.fx.off
+ ? 0
+ : typeof d.duration === 'number'
+ ? d.duration
+ : d.duration in m.fx.speeds
+ ? m.fx.speeds[d.duration]
+ : m.fx.speeds._default),
+ (d.queue == null || d.queue === !0) && (d.queue = 'fx'),
+ (d.old = d.complete),
+ (d.complete = function() {
+ m.isFunction(d.old) && d.old.call(this),
+ d.queue && m.dequeue(this, d.queue)
+ }),
+ d
+ )
+ }),
+ m.fn.extend({
+ fadeTo: function(a, b, c, d) {
+ return this.filter(U)
+ .css('opacity', 0)
+ .show()
+ .end()
+ .animate({ opacity: b }, a, c, d)
+ },
+ animate: function(a, b, c, d) {
+ const e = m.isEmptyObject(a);
+ const f = m.speed(b, c, d);
+ const g = function() {
+ const b = kc(this, m.extend({}, a), f)
+ ;(e || m._data(this, 'finish')) && b.stop(!0)
+ }
+ return (
+ (g.finish = g),
+ e || f.queue === !1 ? this.each(g) : this.queue(f.queue, g)
+ )
+ },
+ stop: function(a, b, c) {
+ const d = function(a) {
+ const b = a.stop
+ delete a.stop, b(c)
+ }
+ return (
+ typeof a !== 'string' && ((c = b), (b = a), (a = void 0)),
+ b && a !== !1 && this.queue(a || 'fx', []),
+ this.each(function() {
+ let b = !0;
+ let e = a != null && a + 'queueHooks';
+ const f = m.timers;
+ const g = m._data(this)
+ if (e) g[e] && g[e].stop && d(g[e])
+ else for (e in g) g[e] && g[e].stop && cc.test(e) && d(g[e])
+ for (e = f.length; e--; )
+ f[e].elem !== this ||
+ (a != null && f[e].queue !== a) ||
+ (f[e].anim.stop(c), (b = !1), f.splice(e, 1))
+ ;(b || !c) && m.dequeue(this, a)
+ })
+ )
+ },
+ finish: function(a) {
+ return (
+ a !== !1 && (a = a || 'fx'),
+ this.each(function() {
+ let b;
+ const c = m._data(this);
+ const d = c[a + 'queue'];
+ const e = c[a + 'queueHooks'];
+ const f = m.timers;
+ const g = d ? d.length : 0
+ for (
+ c.finish = !0,
+ m.queue(this, a, []),
+ e && e.stop && e.stop.call(this, !0),
+ b = f.length;
+ b--;
+
+ )
+ f[b].elem === this &&
+ f[b].queue === a &&
+ (f[b].anim.stop(!0), f.splice(b, 1))
+ for (b = 0; g > b; b++)
+ d[b] && d[b].finish && d[b].finish.call(this)
+ delete c.finish
+ })
+ )
+ }
+ }),
+ m.each(['toggle', 'show', 'hide'], function(a, b) {
+ const c = m.fn[b]
+ m.fn[b] = function(a, d, e) {
+ return a == null || typeof a === 'boolean'
+ ? c.apply(this, arguments)
+ : this.animate(gc(b, !0), a, d, e)
+ }
+ }),
+ m.each(
+ {
+ slideDown: gc('show'),
+ slideUp: gc('hide'),
+ slideToggle: gc('toggle'),
+ fadeIn: { opacity: 'show' },
+ fadeOut: { opacity: 'hide' },
+ fadeToggle: { opacity: 'toggle' }
+ },
+ function(a, b) {
+ m.fn[a] = function(a, c, d) {
+ return this.animate(b, a, c, d)
+ }
+ }
+ ),
+ (m.timers = []),
+ (m.fx.tick = function() {
+ let a;
+ const b = m.timers;
+ let c = 0
+ for ($b = m.now(); c < b.length; c++)
+ (a = b[c]), a() || b[c] !== a || b.splice(c--, 1)
+ b.length || m.fx.stop(), ($b = void 0)
+ }),
+ (m.fx.timer = function(a) {
+ m.timers.push(a), a() ? m.fx.start() : m.timers.pop()
+ }),
+ (m.fx.interval = 13),
+ (m.fx.start = function() {
+ _b || (_b = setInterval(m.fx.tick, m.fx.interval))
+ }),
+ (m.fx.stop = function() {
+ clearInterval(_b), (_b = null)
+ }),
+ (m.fx.speeds = { slow: 600, fast: 200, _default: 400 }),
+ (m.fn.delay = function(a, b) {
+ return (
+ (a = m.fx ? m.fx.speeds[a] || a : a),
+ (b = b || 'fx'),
+ this.queue(b, function(b, c) {
+ const d = setTimeout(b, a)
+ c.stop = function() {
+ clearTimeout(d)
+ }
+ })
+ )
+ }),
+ (function() {
+ let a, b, c, d, e
+ ;(b = y.createElement('div')),
+ b.setAttribute('className', 't'),
+ (b.innerHTML =
+ " a "),
+ (d = b.getElementsByTagName('a')[0]),
+ (c = y.createElement('select')),
+ (e = c.appendChild(y.createElement('option'))),
+ (a = b.getElementsByTagName('input')[0]),
+ (d.style.cssText = 'top:1px'),
+ (k.getSetAttribute = b.className !== 't'),
+ (k.style = /top/.test(d.getAttribute('style'))),
+ (k.hrefNormalized = d.getAttribute('href') === '/a'),
+ (k.checkOn = !!a.value),
+ (k.optSelected = e.selected),
+ (k.enctype = !!y.createElement('form').enctype),
+ (c.disabled = !0),
+ (k.optDisabled = !e.disabled),
+ (a = y.createElement('input')),
+ a.setAttribute('value', ''),
+ (k.input = a.getAttribute('value') === ''),
+ (a.value = 't'),
+ a.setAttribute('type', 'radio'),
+ (k.radioValue = a.value === 't')
+ })()
+ const lc = /\r/g
+ m.fn.extend({
+ val: function(a) {
+ let b;
+ let c;
+ let d;
+ const e = this[0]
+ {
+ if (arguments.length)
+ return (
+ (d = m.isFunction(a)),
+ this.each(function(c) {
+ let e
+ this.nodeType === 1 &&
+ ((e = d ? a.call(this, c, m(this).val()) : a),
+ e == null
+ ? (e = '')
+ : typeof e === 'number'
+ ? (e += '')
+ : m.isArray(e) &&
+ (e = m.map(e, function(a) {
+ return a == null ? '' : a + ''
+ })),
+ (b =
+ m.valHooks[this.type] ||
+ m.valHooks[this.nodeName.toLowerCase()]),
+ (b && 'set' in b && void 0 !== b.set(this, e, 'value')) ||
+ (this.value = e))
+ })
+ )
+ if (e)
+ return (
+ (b = m.valHooks[e.type] || m.valHooks[e.nodeName.toLowerCase()]),
+ b && 'get' in b && void 0 !== (c = b.get(e, 'value'))
+ ? c
+ : ((c = e.value),
+ typeof c === 'string' ? c.replace(lc, '') : c == null ? '' : c)
+ )
+ }
+ }
+ }),
+ m.extend({
+ valHooks: {
+ option: {
+ get: function(a) {
+ const b = m.find.attr(a, 'value')
+ return b != null ? b : m.trim(m.text(a))
+ }
+ },
+ select: {
+ get: function(a) {
+ for (
+ var b,
+ c,
+ d = a.options,
+ e = a.selectedIndex,
+ f = a.type === 'select-one' || e < 0,
+ g = f ? null : [],
+ h = f ? e + 1 : d.length,
+ i = e < 0 ? h : f ? e : 0;
+ h > i;
+ i++
+ )
+ if (
+ ((c = d[i]),
+ !(
+ (!c.selected && i !== e) ||
+ (k.optDisabled
+ ? c.disabled
+ : c.getAttribute('disabled') !== null) ||
+ (c.parentNode.disabled &&
+ m.nodeName(c.parentNode, 'optgroup'))
+ ))
+ ) {
+ if (((b = m(c).val()), f)) return b
+ g.push(b)
+ }
+ return g
+ },
+ set: function(a, b) {
+ let c;
+ let d;
+ const e = a.options;
+ const f = m.makeArray(b);
+ let g = e.length
+ while (g--)
+ if (((d = e[g]), m.inArray(m.valHooks.option.get(d), f) >= 0))
+ try {
+ d.selected = c = !0
+ } catch (h) {
+ d.scrollHeight
+ }
+ else d.selected = !1
+ return c || (a.selectedIndex = -1), e
+ }
+ }
+ }
+ }),
+ m.each(['radio', 'checkbox'], function() {
+ ;(m.valHooks[this] = {
+ set: function(a, b) {
+ return m.isArray(b)
+ ? (a.checked = m.inArray(m(a).val(), b) >= 0)
+ : void 0
+ }
+ }),
+ k.checkOn ||
+ (m.valHooks[this].get = function(a) {
+ return a.getAttribute('value') === null ? 'on' : a.value
+ })
+ })
+ let mc;
+ let nc;
+ const oc = m.expr.attrHandle;
+ const pc = /^(?:checked|selected)$/i;
+ const qc = k.getSetAttribute;
+ const rc = k.input
+ m.fn.extend({
+ attr: function(a, b) {
+ return V(this, m.attr, a, b, arguments.length > 1)
+ },
+ removeAttr: function(a) {
+ return this.each(function() {
+ m.removeAttr(this, a)
+ })
+ }
+ }),
+ m.extend({
+ attr: function(a, b, c) {
+ let d;
+ let e;
+ const f = a.nodeType
+ if (a && f !== 3 && f !== 8 && f !== 2)
+ return typeof a.getAttribute === K
+ ? m.prop(a, b, c)
+ : ((f === 1 && m.isXMLDoc(a)) ||
+ ((b = b.toLowerCase()),
+ (d = m.attrHooks[b] || (m.expr.match.bool.test(b) ? nc : mc))),
+ void 0 === c
+ ? d && 'get' in d && (e = d.get(a, b)) !== null
+ ? e
+ : ((e = m.find.attr(a, b)), e == null ? void 0 : e)
+ : c !== null
+ ? d && 'set' in d && void 0 !== (e = d.set(a, c, b))
+ ? e
+ : (a.setAttribute(b, c + ''), c)
+ : void m.removeAttr(a, b))
+ },
+ removeAttr: function(a, b) {
+ let c;
+ let d;
+ let e = 0;
+ const f = b && b.match(E)
+ if (f && a.nodeType === 1)
+ while ((c = f[e++]))
+ (d = m.propFix[c] || c),
+ m.expr.match.bool.test(c)
+ ? (rc && qc) || !pc.test(c)
+ ? (a[d] = !1)
+ : (a[m.camelCase('default-' + c)] = a[d] = !1)
+ : m.attr(a, c, ''),
+ a.removeAttribute(qc ? c : d)
+ },
+ attrHooks: {
+ type: {
+ set: function(a, b) {
+ if (!k.radioValue && b === 'radio' && m.nodeName(a, 'input')) {
+ const c = a.value
+ return a.setAttribute('type', b), c && (a.value = c), b
+ }
+ }
+ }
+ }
+ }),
+ (nc = {
+ set: function(a, b, c) {
+ return (
+ b === !1
+ ? m.removeAttr(a, c)
+ : (rc && qc) || !pc.test(c)
+ ? a.setAttribute((!qc && m.propFix[c]) || c, c)
+ : (a[m.camelCase('default-' + c)] = a[c] = !0),
+ c
+ )
+ }
+ }),
+ m.each(m.expr.match.bool.source.match(/\w+/g), function(a, b) {
+ const c = oc[b] || m.find.attr
+ oc[b] =
+ (rc && qc) || !pc.test(b)
+ ? function(a, b, d) {
+ let e, f
+ return (
+ d ||
+ ((f = oc[b]),
+ (oc[b] = e),
+ (e = c(a, b, d) != null ? b.toLowerCase() : null),
+ (oc[b] = f)),
+ e
+ )
+ }
+ : function(a, b, c) {
+ return c
+ ? void 0
+ : a[m.camelCase('default-' + b)]
+ ? b.toLowerCase()
+ : null
+ }
+ }),
+ (rc && qc) ||
+ (m.attrHooks.value = {
+ set: function(a, b, c) {
+ return m.nodeName(a, 'input')
+ ? void (a.defaultValue = b)
+ : mc && mc.set(a, b, c)
+ }
+ }),
+ qc ||
+ ((mc = {
+ set: function(a, b, c) {
+ let d = a.getAttributeNode(c)
+ return (
+ d || a.setAttributeNode((d = a.ownerDocument.createAttribute(c))),
+ (d.value = b += ''),
+ c === 'value' || b === a.getAttribute(c) ? b : void 0
+ )
+ }
+ }),
+ (oc.id = oc.name = oc.coords = function(a, b, c) {
+ let d
+ return c
+ ? void 0
+ : (d = a.getAttributeNode(b)) && d.value !== ''
+ ? d.value
+ : null
+ }),
+ (m.valHooks.button = {
+ get: function(a, b) {
+ const c = a.getAttributeNode(b)
+ return c && c.specified ? c.value : void 0
+ },
+ set: mc.set
+ }),
+ (m.attrHooks.contenteditable = {
+ set: function(a, b, c) {
+ mc.set(a, b === '' ? !1 : b, c)
+ }
+ }),
+ m.each(['width', 'height'], function(a, b) {
+ m.attrHooks[b] = {
+ set: function(a, c) {
+ return c === '' ? (a.setAttribute(b, 'auto'), c) : void 0
+ }
+ }
+ })),
+ k.style ||
+ (m.attrHooks.style = {
+ get: function(a) {
+ return a.style.cssText || void 0
+ },
+ set: function(a, b) {
+ return (a.style.cssText = b + '')
+ }
+ })
+ const sc = /^(?:input|select|textarea|button|object)$/i;
+ const tc = /^(?:a|area)$/i
+ m.fn.extend({
+ prop: function(a, b) {
+ return V(this, m.prop, a, b, arguments.length > 1)
+ },
+ removeProp: function(a) {
+ return (
+ (a = m.propFix[a] || a),
+ this.each(function() {
+ try {
+ ;(this[a] = void 0), delete this[a]
+ } catch (b) {}
+ })
+ )
+ }
+ }),
+ m.extend({
+ propFix: { for: 'htmlFor', class: 'className' },
+ prop: function(a, b, c) {
+ let d;
+ let e;
+ let f;
+ const g = a.nodeType
+ if (a && g !== 3 && g !== 8 && g !== 2)
+ return (
+ (f = g !== 1 || !m.isXMLDoc(a)),
+ f && ((b = m.propFix[b] || b), (e = m.propHooks[b])),
+ void 0 !== c
+ ? e && 'set' in e && void 0 !== (d = e.set(a, c, b))
+ ? d
+ : (a[b] = c)
+ : e && 'get' in e && (d = e.get(a, b)) !== null
+ ? d
+ : a[b]
+ )
+ },
+ propHooks: {
+ tabIndex: {
+ get: function(a) {
+ const b = m.find.attr(a, 'tabindex')
+ return b
+ ? parseInt(b, 10)
+ : sc.test(a.nodeName) || (tc.test(a.nodeName) && a.href)
+ ? 0
+ : -1
+ }
+ }
+ }
+ }),
+ k.hrefNormalized ||
+ m.each(['href', 'src'], function(a, b) {
+ m.propHooks[b] = {
+ get: function(a) {
+ return a.getAttribute(b, 4)
+ }
+ }
+ }),
+ k.optSelected ||
+ (m.propHooks.selected = {
+ get: function(a) {
+ const b = a.parentNode
+ return (
+ b && (b.selectedIndex, b.parentNode && b.parentNode.selectedIndex),
+ null
+ )
+ }
+ }),
+ m.each(
+ [
+ 'tabIndex',
+ 'readOnly',
+ 'maxLength',
+ 'cellSpacing',
+ 'cellPadding',
+ 'rowSpan',
+ 'colSpan',
+ 'useMap',
+ 'frameBorder',
+ 'contentEditable'
+ ],
+ function() {
+ m.propFix[this.toLowerCase()] = this
+ }
+ ),
+ k.enctype || (m.propFix.enctype = 'encoding')
+ const uc = /[\t\r\n\f]/g
+ m.fn.extend({
+ addClass: function(a) {
+ let b;
+ let c;
+ let d;
+ let e;
+ let f;
+ let g;
+ let h = 0;
+ const i = this.length;
+ const j = typeof a === 'string' && a
+ if (m.isFunction(a))
+ return this.each(function(b) {
+ m(this).addClass(a.call(this, b, this.className))
+ })
+ if (j)
+ for (b = (a || '').match(E) || []; i > h; h++)
+ if (
+ ((c = this[h]),
+ (d =
+ c.nodeType === 1 &&
+ (c.className ? (' ' + c.className + ' ').replace(uc, ' ') : ' ')))
+ ) {
+ f = 0
+ while ((e = b[f++])) d.indexOf(' ' + e + ' ') < 0 && (d += e + ' ')
+ ;(g = m.trim(d)), c.className !== g && (c.className = g)
+ }
+ return this
+ },
+ removeClass: function(a) {
+ let b;
+ let c;
+ let d;
+ let e;
+ let f;
+ let g;
+ let h = 0;
+ const i = this.length;
+ const j = arguments.length === 0 || (typeof a === 'string' && a)
+ if (m.isFunction(a))
+ return this.each(function(b) {
+ m(this).removeClass(a.call(this, b, this.className))
+ })
+ if (j)
+ for (b = (a || '').match(E) || []; i > h; h++)
+ if (
+ ((c = this[h]),
+ (d =
+ c.nodeType === 1 &&
+ (c.className ? (' ' + c.className + ' ').replace(uc, ' ') : '')))
+ ) {
+ f = 0
+ while ((e = b[f++]))
+ while (d.indexOf(' ' + e + ' ') >= 0)
+ d = d.replace(' ' + e + ' ', ' ')
+ ;(g = a ? m.trim(d) : ''), c.className !== g && (c.className = g)
+ }
+ return this
+ },
+ toggleClass: function(a, b) {
+ const c = typeof a
+ return typeof b === 'boolean' && c === 'string'
+ ? b
+ ? this.addClass(a)
+ : this.removeClass(a)
+ : this.each(
+ m.isFunction(a)
+ ? function(c) {
+ m(this).toggleClass(a.call(this, c, this.className, b), b)
+ }
+ : function() {
+ if (c === 'string') {
+ let b;
+ let d = 0;
+ const e = m(this);
+ const f = a.match(E) || []
+ while ((b = f[d++]))
+ e.hasClass(b) ? e.removeClass(b) : e.addClass(b)
+ } else
+ (c === K || c === 'boolean') &&
+ (this.className &&
+ m._data(this, '__className__', this.className),
+ (this.className =
+ this.className || a === !1
+ ? ''
+ : m._data(this, '__className__') || ''))
+ }
+ )
+ },
+ hasClass: function(a) {
+ for (let b = ' ' + a + ' ', c = 0, d = this.length; d > c; c++)
+ if (
+ this[c].nodeType === 1 &&
+ (' ' + this[c].className + ' ').replace(uc, ' ').indexOf(b) >= 0
+ )
+ return !0
+ return !1
+ }
+ }),
+ m.each(
+ 'blur focus focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup error contextmenu'.split(
+ ' '
+ ),
+ function(a, b) {
+ m.fn[b] = function(a, c) {
+ return arguments.length > 0 ? this.on(b, null, a, c) : this.trigger(b)
+ }
+ }
+ ),
+ m.fn.extend({
+ hover: function(a, b) {
+ return this.mouseenter(a).mouseleave(b || a)
+ },
+ bind: function(a, b, c) {
+ return this.on(a, null, b, c)
+ },
+ unbind: function(a, b) {
+ return this.off(a, null, b)
+ },
+ delegate: function(a, b, c, d) {
+ return this.on(b, a, c, d)
+ },
+ undelegate: function(a, b, c) {
+ return arguments.length === 1
+ ? this.off(a, '**')
+ : this.off(b, a || '**', c)
+ }
+ })
+ let vc = m.now();
+ const wc = /\?/;
+ const xc = /(,)|(\[|{)|(}|])|"(?:[^"\\\r\n]|\\["\\\/bfnrt]|\\u[\da-fA-F]{4})*"\s*:?|true|false|null|-?(?!0\d)\d+(?:\.\d+|)(?:[eE][+-]?\d+|)/g
+ ;(m.parseJSON = function(b) {
+ if (a.JSON && a.JSON.parse) return a.JSON.parse(b + '')
+ let c;
+ let d = null;
+ const e = m.trim(b + '')
+ return e &&
+ !m.trim(
+ e.replace(xc, function(a, b, e, f) {
+ return (
+ c && b && (d = 0), d === 0 ? a : ((c = e || b), (d += !f - !e), '')
+ )
+ })
+ )
+ ? Function('return ' + e)()
+ : m.error('Invalid JSON: ' + b)
+ }),
+ (m.parseXML = function(b) {
+ let c, d
+ if (!b || typeof b !== 'string') return null
+ try {
+ a.DOMParser
+ ? ((d = new DOMParser()), (c = d.parseFromString(b, 'text/xml')))
+ : ((c = new ActiveXObject('Microsoft.XMLDOM')),
+ (c.async = 'false'),
+ c.loadXML(b))
+ } catch (e) {
+ c = void 0
+ }
+ return (
+ (c &&
+ c.documentElement &&
+ !c.getElementsByTagName('parsererror').length) ||
+ m.error('Invalid XML: ' + b),
+ c
+ )
+ })
+ let yc;
+ let zc;
+ const Ac = /#.*$/;
+ const Bc = /([?&])_=[^&]*/;
+ const Cc = /^(.*?):[ \t]*([^\r\n]*)\r?$/gm;
+ const Dc = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/;
+ const Ec = /^(?:GET|HEAD)$/;
+ const Fc = /^\/\//;
+ const Gc = /^([\w.+-]+:)(?:\/\/(?:[^\/?#]*@|)([^\/?#:]*)(?::(\d+)|)|)/;
+ const Hc = {};
+ const Ic = {};
+ const Jc = '*/'.concat('*')
+ try {
+ zc = location.href
+ } catch (Kc) {
+ ;(zc = y.createElement('a')), (zc.href = ''), (zc = zc.href)
+ }
+ yc = Gc.exec(zc.toLowerCase()) || []
+ function Lc(a) {
+ return function(b, c) {
+ typeof b !== 'string' && ((c = b), (b = '*'))
+ let d;
+ let e = 0;
+ const f = b.toLowerCase().match(E) || []
+ if (m.isFunction(c))
+ while ((d = f[e++]))
+ d.charAt(0) === '+'
+ ? ((d = d.slice(1) || '*'), (a[d] = a[d] || []).unshift(c))
+ : (a[d] = a[d] || []).push(c)
+ }
+ }
+ function Mc(a, b, c, d) {
+ const e = {};
+ const f = a === Ic
+ function g(h) {
+ let i
+ return (
+ (e[h] = !0),
+ m.each(a[h] || [], function(a, h) {
+ const j = h(b, c, d)
+ return typeof j !== 'string' || f || e[j]
+ ? f
+ ? !(i = j)
+ : void 0
+ : (b.dataTypes.unshift(j), g(j), !1)
+ }),
+ i
+ )
+ }
+ return g(b.dataTypes[0]) || (!e['*'] && g('*'))
+ }
+ function Nc(a, b) {
+ let c;
+ let d;
+ const e = m.ajaxSettings.flatOptions || {}
+ for (d in b) void 0 !== b[d] && ((e[d] ? a : c || (c = {}))[d] = b[d])
+ return c && m.extend(!0, a, c), a
+ }
+ function Oc(a, b, c) {
+ let d;
+ let e;
+ let f;
+ let g;
+ const h = a.contents;
+ const i = a.dataTypes
+ while (i[0] === '*')
+ i.shift(),
+ void 0 === e && (e = a.mimeType || b.getResponseHeader('Content-Type'))
+ if (e)
+ for (g in h)
+ if (h[g] && h[g].test(e)) {
+ i.unshift(g)
+ break
+ }
+ if (i[0] in c) f = i[0]
+ else {
+ for (g in c) {
+ if (!i[0] || a.converters[g + ' ' + i[0]]) {
+ f = g
+ break
+ }
+ d || (d = g)
+ }
+ f = f || d
+ }
+ return f ? (f !== i[0] && i.unshift(f), c[f]) : void 0
+ }
+ function Pc(a, b, c, d) {
+ let e;
+ let f;
+ let g;
+ let h;
+ let i;
+ const j = {};
+ const k = a.dataTypes.slice()
+ if (k[1]) for (g in a.converters) j[g.toLowerCase()] = a.converters[g]
+ f = k.shift()
+ while (f)
+ if (
+ (a.responseFields[f] && (c[a.responseFields[f]] = b),
+ !i && d && a.dataFilter && (b = a.dataFilter(b, a.dataType)),
+ (i = f),
+ (f = k.shift()))
+ )
+ if (f === '*') f = i
+ else if (i !== '*' && i !== f) {
+ if (((g = j[i + ' ' + f] || j['* ' + f]), !g))
+ for (e in j)
+ if (
+ ((h = e.split(' ')),
+ h[1] === f && (g = j[i + ' ' + h[0]] || j['* ' + h[0]]))
+ ) {
+ g === !0
+ ? (g = j[e])
+ : j[e] !== !0 && ((f = h[0]), k.unshift(h[1]))
+ break
+ }
+ if (g !== !0)
+ if (g && a.throws) b = g(b)
+ else
+ try {
+ b = g(b)
+ } catch (l) {
+ return {
+ state: 'parsererror',
+ error: g ? l : 'No conversion from ' + i + ' to ' + f
+ }
+ }
+ }
+ return { state: 'success', data: b }
+ }
+ m.extend({
+ active: 0,
+ lastModified: {},
+ etag: {},
+ ajaxSettings: {
+ url: zc,
+ type: 'GET',
+ isLocal: Dc.test(yc[1]),
+ global: !0,
+ processData: !0,
+ async: !0,
+ contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
+ accepts: {
+ '*': Jc,
+ text: 'text/plain',
+ html: 'text/html',
+ xml: 'application/xml, text/xml',
+ json: 'application/json, text/javascript'
+ },
+ contents: { xml: /xml/, html: /html/, json: /json/ },
+ responseFields: {
+ xml: 'responseXML',
+ text: 'responseText',
+ json: 'responseJSON'
+ },
+ converters: {
+ '* text': String,
+ 'text html': !0,
+ 'text json': m.parseJSON,
+ 'text xml': m.parseXML
+ },
+ flatOptions: { url: !0, context: !0 }
+ },
+ ajaxSetup: function(a, b) {
+ return b ? Nc(Nc(a, m.ajaxSettings), b) : Nc(m.ajaxSettings, a)
+ },
+ ajaxPrefilter: Lc(Hc),
+ ajaxTransport: Lc(Ic),
+ ajax: function(a, b) {
+ typeof a === 'object' && ((b = a), (a = void 0)), (b = b || {})
+ let c;
+ let d;
+ let e;
+ let f;
+ let g;
+ let h;
+ let i;
+ let j;
+ const k = m.ajaxSetup({}, b);
+ const l = k.context || k;
+ const n = k.context && (l.nodeType || l.jquery) ? m(l) : m.event;
+ const o = m.Deferred();
+ const p = m.Callbacks('once memory');
+ let q = k.statusCode || {};
+ const r = {};
+ const s = {};
+ let t = 0;
+ let u = 'canceled';
+ var v = {
+ readyState: 0,
+ getResponseHeader: function(a) {
+ let b
+ if (t === 2) {
+ if (!j) {
+ j = {}
+ while ((b = Cc.exec(f))) j[b[1].toLowerCase()] = b[2]
+ }
+ b = j[a.toLowerCase()]
+ }
+ return b == null ? null : b
+ },
+ getAllResponseHeaders: function() {
+ return t === 2 ? f : null
+ },
+ setRequestHeader: function(a, b) {
+ const c = a.toLowerCase()
+ return t || ((a = s[c] = s[c] || a), (r[a] = b)), this
+ },
+ overrideMimeType: function(a) {
+ return t || (k.mimeType = a), this
+ },
+ statusCode: function(a) {
+ let b
+ if (a)
+ if (t < 2) for (b in a) q[b] = [q[b], a[b]]
+ else v.always(a[v.status])
+ return this
+ },
+ abort: function(a) {
+ const b = a || u
+ return i && i.abort(b), x(0, b), this
+ }
+ }
+ if (
+ ((o.promise(v).complete = p.add),
+ (v.success = v.done),
+ (v.error = v.fail),
+ (k.url = ((a || k.url || zc) + '')
+ .replace(Ac, '')
+ .replace(Fc, yc[1] + '//')),
+ (k.type = b.method || b.type || k.method || k.type),
+ (k.dataTypes = m
+ .trim(k.dataType || '*')
+ .toLowerCase()
+ .match(E) || ['']),
+ k.crossDomain == null &&
+ ((c = Gc.exec(k.url.toLowerCase())),
+ (k.crossDomain = !(
+ !c ||
+ (c[1] === yc[1] &&
+ c[2] === yc[2] &&
+ (c[3] || (c[1] === 'http:' ? '80' : '443')) ===
+ (yc[3] || (yc[1] === 'http:' ? '80' : '443')))
+ ))),
+ k.data &&
+ k.processData &&
+ typeof k.data !== 'string' &&
+ (k.data = m.param(k.data, k.traditional)),
+ Mc(Hc, k, b, v),
+ t === 2)
+ )
+ return v
+ ;(h = m.event && k.global),
+ h && m.active++ === 0 && m.event.trigger('ajaxStart'),
+ (k.type = k.type.toUpperCase()),
+ (k.hasContent = !Ec.test(k.type)),
+ (e = k.url),
+ k.hasContent ||
+ (k.data &&
+ ((e = k.url += (wc.test(e) ? '&' : '?') + k.data), delete k.data),
+ k.cache === !1 &&
+ (k.url = Bc.test(e)
+ ? e.replace(Bc, '$1_=' + vc++)
+ : e + (wc.test(e) ? '&' : '?') + '_=' + vc++)),
+ k.ifModified &&
+ (m.lastModified[e] &&
+ v.setRequestHeader('If-Modified-Since', m.lastModified[e]),
+ m.etag[e] && v.setRequestHeader('If-None-Match', m.etag[e])),
+ ((k.data && k.hasContent && k.contentType !== !1) || b.contentType) &&
+ v.setRequestHeader('Content-Type', k.contentType),
+ v.setRequestHeader(
+ 'Accept',
+ k.dataTypes[0] && k.accepts[k.dataTypes[0]]
+ ? k.accepts[k.dataTypes[0]] +
+ (k.dataTypes[0] !== '*' ? ', ' + Jc + '; q=0.01' : '')
+ : k.accepts['*']
+ )
+ for (d in k.headers) v.setRequestHeader(d, k.headers[d])
+ if (k.beforeSend && (k.beforeSend.call(l, v, k) === !1 || t === 2))
+ return v.abort()
+ u = 'abort'
+ for (d in { success: 1, error: 1, complete: 1 }) v[d](k[d])
+ if ((i = Mc(Ic, k, b, v))) {
+ ;(v.readyState = 1),
+ h && n.trigger('ajaxSend', [v, k]),
+ k.async &&
+ k.timeout > 0 &&
+ (g = setTimeout(function() {
+ v.abort('timeout')
+ }, k.timeout))
+ try {
+ ;(t = 1), i.send(r, x)
+ } catch (w) {
+ if (!(t < 2)) throw w
+ x(-1, w)
+ }
+ } else x(-1, 'No Transport')
+ function x(a, b, c, d) {
+ let j;
+ let r;
+ let s;
+ let u;
+ let w;
+ let x = b
+ t !== 2 &&
+ ((t = 2),
+ g && clearTimeout(g),
+ (i = void 0),
+ (f = d || ''),
+ (v.readyState = a > 0 ? 4 : 0),
+ (j = (a >= 200 && a < 300) || a === 304),
+ c && (u = Oc(k, v, c)),
+ (u = Pc(k, u, v, j)),
+ j
+ ? (k.ifModified &&
+ ((w = v.getResponseHeader('Last-Modified')),
+ w && (m.lastModified[e] = w),
+ (w = v.getResponseHeader('etag')),
+ w && (m.etag[e] = w)),
+ a === 204 || k.type === 'HEAD'
+ ? (x = 'nocontent')
+ : a === 304
+ ? (x = 'notmodified')
+ : ((x = u.state), (r = u.data), (s = u.error), (j = !s)))
+ : ((s = x), (a || !x) && ((x = 'error'), a < 0 && (a = 0))),
+ (v.status = a),
+ (v.statusText = (b || x) + ''),
+ j ? o.resolveWith(l, [r, x, v]) : o.rejectWith(l, [v, x, s]),
+ v.statusCode(q),
+ (q = void 0),
+ h && n.trigger(j ? 'ajaxSuccess' : 'ajaxError', [v, k, j ? r : s]),
+ p.fireWith(l, [v, x]),
+ h &&
+ (n.trigger('ajaxComplete', [v, k]),
+ --m.active || m.event.trigger('ajaxStop')))
+ }
+ return v
+ },
+ getJSON: function(a, b, c) {
+ return m.get(a, b, c, 'json')
+ },
+ getScript: function(a, b) {
+ return m.get(a, void 0, b, 'script')
+ }
+ }),
+ m.each(['get', 'post'], function(a, b) {
+ m[b] = function(a, c, d, e) {
+ return (
+ m.isFunction(c) && ((e = e || d), (d = c), (c = void 0)),
+ m.ajax({ url: a, type: b, dataType: e, data: c, success: d })
+ )
+ }
+ }),
+ (m._evalUrl = function(a) {
+ return m.ajax({
+ url: a,
+ type: 'GET',
+ dataType: 'script',
+ async: !1,
+ global: !1,
+ throws: !0
+ })
+ }),
+ m.fn.extend({
+ wrapAll: function(a) {
+ if (m.isFunction(a))
+ return this.each(function(b) {
+ m(this).wrapAll(a.call(this, b))
+ })
+ if (this[0]) {
+ const b = m(a, this[0].ownerDocument)
+ .eq(0)
+ .clone(!0)
+ this[0].parentNode && b.insertBefore(this[0]),
+ b
+ .map(function() {
+ let a = this
+ while (a.firstChild && a.firstChild.nodeType === 1)
+ a = a.firstChild
+ return a
+ })
+ .append(this)
+ }
+ return this
+ },
+ wrapInner: function(a) {
+ return this.each(
+ m.isFunction(a)
+ ? function(b) {
+ m(this).wrapInner(a.call(this, b))
+ }
+ : function() {
+ const b = m(this);
+ const c = b.contents()
+ c.length ? c.wrapAll(a) : b.append(a)
+ }
+ )
+ },
+ wrap: function(a) {
+ const b = m.isFunction(a)
+ return this.each(function(c) {
+ m(this).wrapAll(b ? a.call(this, c) : a)
+ })
+ },
+ unwrap: function() {
+ return this.parent()
+ .each(function() {
+ m.nodeName(this, 'body') || m(this).replaceWith(this.childNodes)
+ })
+ .end()
+ }
+ }),
+ (m.expr.filters.hidden = function(a) {
+ return (
+ (a.offsetWidth <= 0 && a.offsetHeight <= 0) ||
+ (!k.reliableHiddenOffsets() &&
+ ((a.style && a.style.display) || m.css(a, 'display')) === 'none')
+ )
+ }),
+ (m.expr.filters.visible = function(a) {
+ return !m.expr.filters.hidden(a)
+ })
+ const Qc = /%20/g;
+ const Rc = /\[\]$/;
+ const Sc = /\r?\n/g;
+ const Tc = /^(?:submit|button|image|reset|file)$/i;
+ const Uc = /^(?:input|select|textarea|keygen)/i
+ function Vc(a, b, c, d) {
+ let e
+ if (m.isArray(b))
+ m.each(b, function(b, e) {
+ c || Rc.test(a)
+ ? d(a, e)
+ : Vc(a + '[' + (typeof e === 'object' ? b : '') + ']', e, c, d)
+ })
+ else if (c || m.type(b) !== 'object') d(a, b)
+ else for (e in b) Vc(a + '[' + e + ']', b[e], c, d)
+ }
+ ;(m.param = function(a, b) {
+ let c;
+ const d = [];
+ const e = function(a, b) {
+ ;(b = m.isFunction(b) ? b() : b == null ? '' : b),
+ (d[d.length] = encodeURIComponent(a) + '=' + encodeURIComponent(b))
+ }
+ if (
+ (void 0 === b && (b = m.ajaxSettings && m.ajaxSettings.traditional),
+ m.isArray(a) || (a.jquery && !m.isPlainObject(a)))
+ )
+ m.each(a, function() {
+ e(this.name, this.value)
+ })
+ else for (c in a) Vc(c, a[c], b, e)
+ return d.join('&').replace(Qc, '+')
+ }),
+ m.fn.extend({
+ serialize: function() {
+ return m.param(this.serializeArray())
+ },
+ serializeArray: function() {
+ return this.map(function() {
+ const a = m.prop(this, 'elements')
+ return a ? m.makeArray(a) : this
+ })
+ .filter(function() {
+ const a = this.type
+ return (
+ this.name &&
+ !m(this).is(':disabled') &&
+ Uc.test(this.nodeName) &&
+ !Tc.test(a) &&
+ (this.checked || !W.test(a))
+ )
+ })
+ .map(function(a, b) {
+ const c = m(this).val()
+ return c == null
+ ? null
+ : m.isArray(c)
+ ? m.map(c, function(a) {
+ return { name: b.name, value: a.replace(Sc, '\r\n') }
+ })
+ : { name: b.name, value: c.replace(Sc, '\r\n') }
+ })
+ .get()
+ }
+ }),
+ (m.ajaxSettings.xhr =
+ void 0 !== a.ActiveXObject
+ ? function() {
+ return (
+ (!this.isLocal &&
+ /^(get|post|head|put|delete|options)$/i.test(this.type) &&
+ Zc()) ||
+ $c()
+ )
+ }
+ : Zc)
+ let Wc = 0;
+ const Xc = {};
+ let Yc = m.ajaxSettings.xhr()
+ a.attachEvent &&
+ a.attachEvent('onunload', function() {
+ for (const a in Xc) Xc[a](void 0, !0)
+ }),
+ (k.cors = !!Yc && 'withCredentials' in Yc),
+ (Yc = k.ajax = !!Yc),
+ Yc &&
+ m.ajaxTransport(function(a) {
+ if (!a.crossDomain || k.cors) {
+ let b
+ return {
+ send: function(c, d) {
+ let e;
+ const f = a.xhr();
+ const g = ++Wc
+ if (
+ (f.open(a.type, a.url, a.async, a.username, a.password),
+ a.xhrFields)
+ )
+ for (e in a.xhrFields) f[e] = a.xhrFields[e]
+ a.mimeType &&
+ f.overrideMimeType &&
+ f.overrideMimeType(a.mimeType),
+ a.crossDomain ||
+ c['X-Requested-With'] ||
+ (c['X-Requested-With'] = 'XMLHttpRequest')
+ for (e in c) void 0 !== c[e] && f.setRequestHeader(e, c[e] + '')
+ f.send((a.hasContent && a.data) || null),
+ (b = function(c, e) {
+ let h, i, j
+ if (b && (e || f.readyState === 4))
+ if (
+ (delete Xc[g],
+ (b = void 0),
+ (f.onreadystatechange = m.noop),
+ e)
+ )
+ f.readyState !== 4 && f.abort()
+ else {
+ ;(j = {}),
+ (h = f.status),
+ typeof f.responseText === 'string' &&
+ (j.text = f.responseText)
+ try {
+ i = f.statusText
+ } catch (k) {
+ i = ''
+ }
+ h || !a.isLocal || a.crossDomain
+ ? h === 1223 && (h = 204)
+ : (h = j.text ? 200 : 404)
+ }
+ j && d(h, i, j, f.getAllResponseHeaders())
+ }),
+ a.async
+ ? f.readyState === 4
+ ? setTimeout(b)
+ : (f.onreadystatechange = Xc[g] = b)
+ : b()
+ },
+ abort: function() {
+ b && b(void 0, !0)
+ }
+ }
+ }
+ })
+ function Zc() {
+ try {
+ return new a.XMLHttpRequest()
+ } catch (b) {}
+ }
+ function $c() {
+ try {
+ return new a.ActiveXObject('Microsoft.XMLHTTP')
+ } catch (b) {}
+ }
+ m.ajaxSetup({
+ accepts: {
+ script:
+ 'text/javascript, application/javascript, application/ecmascript, application/x-ecmascript'
+ },
+ contents: { script: /(?:java|ecma)script/ },
+ converters: {
+ 'text script': function(a) {
+ return m.globalEval(a), a
+ }
+ }
+ }),
+ m.ajaxPrefilter('script', function(a) {
+ void 0 === a.cache && (a.cache = !1),
+ a.crossDomain && ((a.type = 'GET'), (a.global = !1))
+ }),
+ m.ajaxTransport('script', function(a) {
+ if (a.crossDomain) {
+ let b;
+ const c = y.head || m('head')[0] || y.documentElement
+ return {
+ send: function(d, e) {
+ ;(b = y.createElement('script')),
+ (b.async = !0),
+ a.scriptCharset && (b.charset = a.scriptCharset),
+ (b.src = a.url),
+ (b.onload = b.onreadystatechange = function(a, c) {
+ ;(c || !b.readyState || /loaded|complete/.test(b.readyState)) &&
+ ((b.onload = b.onreadystatechange = null),
+ b.parentNode && b.parentNode.removeChild(b),
+ (b = null),
+ c || e(200, 'success'))
+ }),
+ c.insertBefore(b, c.firstChild)
+ },
+ abort: function() {
+ b && b.onload(void 0, !0)
+ }
+ }
+ }
+ })
+ const _c = [];
+ const ad = /(=)\?(?=&|$)|\?\?/
+ m.ajaxSetup({
+ jsonp: 'callback',
+ jsonpCallback: function() {
+ const a = _c.pop() || m.expando + '_' + vc++
+ return (this[a] = !0), a
+ }
+ }),
+ m.ajaxPrefilter('json jsonp', function(b, c, d) {
+ let e;
+ let f;
+ let g;
+ const h =
+ b.jsonp !== !1 &&
+ (ad.test(b.url)
+ ? 'url'
+ : typeof b.data === 'string' &&
+ !(b.contentType || '').indexOf(
+ 'application/x-www-form-urlencoded'
+ ) &&
+ ad.test(b.data) &&
+ 'data')
+ return h || b.dataTypes[0] === 'jsonp'
+ ? ((e = b.jsonpCallback = m.isFunction(b.jsonpCallback)
+ ? b.jsonpCallback()
+ : b.jsonpCallback),
+ h
+ ? (b[h] = b[h].replace(ad, '$1' + e))
+ : b.jsonp !== !1 &&
+ (b.url += (wc.test(b.url) ? '&' : '?') + b.jsonp + '=' + e),
+ (b.converters['script json'] = function() {
+ return g || m.error(e + ' was not called'), g[0]
+ }),
+ (b.dataTypes[0] = 'json'),
+ (f = a[e]),
+ (a[e] = function() {
+ g = arguments
+ }),
+ d.always(function() {
+ ;(a[e] = f),
+ b[e] && ((b.jsonpCallback = c.jsonpCallback), _c.push(e)),
+ g && m.isFunction(f) && f(g[0]),
+ (g = f = void 0)
+ }),
+ 'script')
+ : void 0
+ }),
+ (m.parseHTML = function(a, b, c) {
+ if (!a || typeof a !== 'string') return null
+ typeof b === 'boolean' && ((c = b), (b = !1)), (b = b || y)
+ let d = u.exec(a);
+ const e = !c && []
+ return d
+ ? [b.createElement(d[1])]
+ : ((d = m.buildFragment([a], b, e)),
+ e && e.length && m(e).remove(),
+ m.merge([], d.childNodes))
+ })
+ const bd = m.fn.load
+ ;(m.fn.load = function(a, b, c) {
+ if (typeof a !== 'string' && bd) return bd.apply(this, arguments)
+ let d;
+ let e;
+ let f;
+ const g = this;
+ const h = a.indexOf(' ')
+ return (
+ h >= 0 && ((d = m.trim(a.slice(h, a.length))), (a = a.slice(0, h))),
+ m.isFunction(b)
+ ? ((c = b), (b = void 0))
+ : b && typeof b === 'object' && (f = 'POST'),
+ g.length > 0 &&
+ m
+ .ajax({ url: a, type: f, dataType: 'html', data: b })
+ .done(function(a) {
+ ;(e = arguments),
+ g.html(
+ d
+ ? m('')
+ .append(m.parseHTML(a))
+ .find(d)
+ : a
+ )
+ })
+ .complete(
+ c &&
+ function(a, b) {
+ g.each(c, e || [a.responseText, b, a])
+ }
+ ),
+ this
+ )
+ }),
+ m.each(
+ [
+ 'ajaxStart',
+ 'ajaxStop',
+ 'ajaxComplete',
+ 'ajaxError',
+ 'ajaxSuccess',
+ 'ajaxSend'
+ ],
+ function(a, b) {
+ m.fn[b] = function(a) {
+ return this.on(b, a)
+ }
+ }
+ ),
+ (m.expr.filters.animated = function(a) {
+ return m.grep(m.timers, function(b) {
+ return a === b.elem
+ }).length
+ })
+ const cd = a.document.documentElement
+ function dd(a) {
+ return m.isWindow(a)
+ ? a
+ : a.nodeType === 9
+ ? a.defaultView || a.parentWindow
+ : !1
+ }
+ ;(m.offset = {
+ setOffset: function(a, b, c) {
+ let d;
+ let e;
+ let f;
+ let g;
+ let h;
+ let i;
+ let j;
+ const k = m.css(a, 'position');
+ const l = m(a);
+ const n = {}
+ k === 'static' && (a.style.position = 'relative'),
+ (h = l.offset()),
+ (f = m.css(a, 'top')),
+ (i = m.css(a, 'left')),
+ (j =
+ (k === 'absolute' || k === 'fixed') &&
+ m.inArray('auto', [f, i]) > -1),
+ j
+ ? ((d = l.position()), (g = d.top), (e = d.left))
+ : ((g = parseFloat(f) || 0), (e = parseFloat(i) || 0)),
+ m.isFunction(b) && (b = b.call(a, c, h)),
+ b.top != null && (n.top = b.top - h.top + g),
+ b.left != null && (n.left = b.left - h.left + e),
+ 'using' in b ? b.using.call(a, n) : l.css(n)
+ }
+ }),
+ m.fn.extend({
+ offset: function(a) {
+ if (arguments.length)
+ return void 0 === a
+ ? this
+ : this.each(function(b) {
+ m.offset.setOffset(this, a, b)
+ })
+ let b;
+ let c;
+ let d = { top: 0, left: 0 };
+ const e = this[0];
+ const f = e && e.ownerDocument
+ if (f)
+ return (
+ (b = f.documentElement),
+ m.contains(b, e)
+ ? (typeof e.getBoundingClientRect !== K &&
+ (d = e.getBoundingClientRect()),
+ (c = dd(f)),
+ {
+ top:
+ d.top + (c.pageYOffset || b.scrollTop) - (b.clientTop || 0),
+ left:
+ d.left +
+ (c.pageXOffset || b.scrollLeft) -
+ (b.clientLeft || 0)
+ })
+ : d
+ )
+ },
+ position: function() {
+ if (this[0]) {
+ let a;
+ let b;
+ let c = { top: 0, left: 0 };
+ const d = this[0]
+ return (
+ m.css(d, 'position') === 'fixed'
+ ? (b = d.getBoundingClientRect())
+ : ((a = this.offsetParent()),
+ (b = this.offset()),
+ m.nodeName(a[0], 'html') || (c = a.offset()),
+ (c.top += m.css(a[0], 'borderTopWidth', !0)),
+ (c.left += m.css(a[0], 'borderLeftWidth', !0))),
+ {
+ top: b.top - c.top - m.css(d, 'marginTop', !0),
+ left: b.left - c.left - m.css(d, 'marginLeft', !0)
+ }
+ )
+ }
+ },
+ offsetParent: function() {
+ return this.map(function() {
+ let a = this.offsetParent || cd
+ while (
+ a &&
+ !m.nodeName(a, 'html') &&
+ m.css(a, 'position') === 'static'
+ )
+ a = a.offsetParent
+ return a || cd
+ })
+ }
+ }),
+ m.each({ scrollLeft: 'pageXOffset', scrollTop: 'pageYOffset' }, function(
+ a,
+ b
+ ) {
+ const c = /Y/.test(b)
+ m.fn[a] = function(d) {
+ return V(
+ this,
+ function(a, d, e) {
+ const f = dd(a)
+ return void 0 === e
+ ? f
+ ? b in f
+ ? f[b]
+ : f.document.documentElement[d]
+ : a[d]
+ : void (f
+ ? f.scrollTo(
+ c ? m(f).scrollLeft() : e,
+ c ? e : m(f).scrollTop()
+ )
+ : (a[d] = e))
+ },
+ a,
+ d,
+ arguments.length,
+ null
+ )
+ }
+ }),
+ m.each(['top', 'left'], function(a, b) {
+ m.cssHooks[b] = Lb(k.pixelPosition, function(a, c) {
+ return c
+ ? ((c = Jb(a, b)), Hb.test(c) ? m(a).position()[b] + 'px' : c)
+ : void 0
+ })
+ }),
+ m.each({ Height: 'height', Width: 'width' }, function(a, b) {
+ m.each({ padding: 'inner' + a, content: b, '': 'outer' + a }, function(
+ c,
+ d
+ ) {
+ m.fn[d] = function(d, e) {
+ const f = arguments.length && (c || typeof d !== 'boolean');
+ const g = c || (d === !0 || e === !0 ? 'margin' : 'border')
+ return V(
+ this,
+ function(b, c, d) {
+ let e
+ return m.isWindow(b)
+ ? b.document.documentElement['client' + a]
+ : b.nodeType === 9
+ ? ((e = b.documentElement),
+ Math.max(
+ b.body['scroll' + a],
+ e['scroll' + a],
+ b.body['offset' + a],
+ e['offset' + a],
+ e['client' + a]
+ ))
+ : void 0 === d
+ ? m.css(b, c, g)
+ : m.style(b, c, d, g)
+ },
+ b,
+ f ? d : void 0,
+ f,
+ null
+ )
+ }
+ })
+ }),
+ (m.fn.size = function() {
+ return this.length
+ }),
+ (m.fn.andSelf = m.fn.addBack),
+ typeof define === 'function' &&
+ define.amd &&
+ define('jquery', [], function() {
+ return m
+ })
+ const ed = a.jQuery;
+ const fd = a.$
+ return (
+ (m.noConflict = function(b) {
+ return a.$ === m && (a.$ = fd), b && a.jQuery === m && (a.jQuery = ed), m
+ }),
+ typeof b === K && (a.jQuery = a.$ = m),
+ m
+ )
+})
diff --git a/public/js/settings_general.js b/public/js/settings_general.js
index be830a8d9..29cb5fc9b 100644
--- a/public/js/settings_general.js
+++ b/public/js/settings_general.js
@@ -1,14 +1,39 @@
+$(document).ready(function() {
+ $('button.bankholiday-remove-btn').on('click', function(e) {
+ e.stopPropagation()
-$(document).ready(function () {
- $('button.leavetype-remove-btn').on('click', function(e){
+ const delete_form = $('#delete_bankholiday_form')
+ delete_form.attr(
+ 'action',
+ delete_form.attr('action') + $(this).attr('value') + '/'
+ )
- e.stopPropagation();
+ delete_form.submit()
- var delete_form = $('#delete_leavetype_form');
- delete_form.attr('action', delete_form.attr('action') + $(this).attr('value') + '/');
+ return false
+ })
- delete_form.submit();
+ $('button#bankholiday-import-btn').on('click', function(e) {
+ e.stopPropagation()
- return false;
- });
-});
+ const import_form = $('#import_bankholiday_form')
+
+ import_form.submit()
+
+ return false
+ })
+
+ $('button.leavetype-remove-btn').on('click', function(e) {
+ e.stopPropagation()
+
+ const delete_form = $('#delete_leavetype_form')
+ delete_form.attr(
+ 'action',
+ delete_form.attr('action') + $(this).attr('value') + '/'
+ )
+
+ delete_form.submit()
+
+ return false
+ })
+})
diff --git a/scss/main.scss b/scss/main.scss
index 77e7e9025..52185ba08 100644
--- a/scss/main.scss
+++ b/scss/main.scss
@@ -4,16 +4,16 @@
sassc scss/main.scss public/css/style.css
*/
-$primary-font-color : #61686b;
-$border-color : #e5e5e5;
-$link-color : #5ba4e5;
+$primary-font-color: #61686b;
+$border-color: #e5e5e5;
+$link-color: #5ba4e5;
-$font-size-primary : 14px;
-$font-size-bigger : 16px;
+$font-size-primary: 14px;
+$font-size-bigger: 16px;
-$selected-item-background : #F5F7F8;
+$selected-item-background: #f5f7f8;
-$leave_cell_font_color : #61686b;
+$leave_cell_font_color: #61686b;
// 5E5E5E
@@ -86,7 +86,6 @@ label.label-plain {
padding-left: 0;
}
-
/* Make the masthead heading the same height as the navigation */
.header h3 {
padding-bottom: 19px;
@@ -98,17 +97,18 @@ label.label-plain {
/* Custom page footer */
.footer {
- margin-top : 20px;
- padding-top : 20px;
- border-top : 1px solid $border-color;
+ margin-top: 20px;
+ padding-top: 20px;
+ border-top: 1px solid $border-color;
}
-.header, .marketing, .footer {
- padding-right: 0;
- padding-left: 0;
+.header,
+.marketing,
+.footer {
+ padding-right: 0;
+ padding-left: 0;
}
-
/* Space out the masthead */
.header {
margin-bottom: 30px;
@@ -121,76 +121,74 @@ label.label-plain {
/* styling calendar*/
.calendar_month {
- width : 100%;
+ width: 100%;
}
.calendar_month td {
text-align: center;
- padding-top : 5px;
- padding-bottom : 5px;
+ padding-top: 5px;
+ padding-bottom: 5px;
}
.calendar_month thead {
- text-align: center;
- font-weight: bolder;
+ text-align: center;
+ font-weight: bolder;
}
-
div.month_container {
- height : 250px;
+ height: 250px;
}
.team-view-table {
- width : 100%;
+ width: 100%;
}
.team-view-table td {
- padding-top : 5px;
- padding-bottom : 5px;
+ padding-top: 5px;
+ padding-bottom: 5px;
}
td.team-view-header {
height: 43px;
text-align: center;
}
-
td.calendar_cell {
- width : 15px !important;
- min-width : 15px !important;
- max-width : 15px !important;
- position : relative;
- text-align : center;
- padding-top : 5px;
- padding-bottom : 5px;
+ width: 15px !important;
+ min-width: 15px !important;
+ max-width: 15px !important;
+ position: relative;
+ text-align: center;
+ padding-top: 5px;
+ padding-bottom: 5px;
}
td.calendar_cell span {
- position : relative;
- left : 9px;
- top : -1px;
- display : block;
- text-align : center;
- z-index : 10;
+ position: relative;
+ left: 9px;
+ top: -1px;
+ display: block;
+ text-align: center;
+ z-index: 10;
}
td.current_day_cell {
- background: #FFCDD2;
- color : #ffffff;
+ background: #ffcdd2;
+ color: #ffffff;
}
td.weekend_cell {
background: $selected-item-background;
}
td.bank_holiday_cell {
- background : #31B0D5;
- color : #ffffff;
+ background: #31b0d5;
+ color: #ffffff;
}
td.leave_cell {
- background : #9fbb58;
- color : $leave_cell_font_color;
+ background: #9fbb58;
+ color: $leave_cell_font_color;
font-weight: bolder;
}
td.leave_cell_pended {
- background: #FFCBA4;
+ background: #ffcba4;
color: $leave_cell_font_color;
font-weight: bolder;
}
.modal-dialog {
- max-width : 450px;
+ max-width: 450px;
}
.left-column-cell {
text-overflow: ellipsis;
@@ -201,7 +199,8 @@ td.leave_cell_pended {
display: inline-block;
}
-.main-row_header { /* TODO refactore */
+.main-row_header {
+ /* TODO refactore */
border: none;
font-weight: normal;
color: $link-color;
@@ -213,12 +212,10 @@ td.leave_cell_pended {
padding-bottom: 30px;
}
-
-
/* Feeds */
.feed-calendar-big {
font-size: 450px;
- color: #F8F8F8;
+ color: #f8f8f8;
}
.feed-calendar-big-picture-holder {
@@ -234,7 +231,6 @@ div.feeds-holder {
margin-top: 20px;
}
-
/* Calendars */
.top-leave-type-statistics {
text-align: center;
@@ -243,35 +239,32 @@ div.feeds-holder {
font-size: 75px;
color: $primary-font-color;
font-weight: 100;
- border-bottom : 1px solid $border-color;
- margin-bottom : 20px;
+ border-bottom: 1px solid $border-color;
+ margin-bottom: 20px;
}
.top-leave-type-statistics dd {
font-size: $font-size-bigger;
}
-
.secondary-leave-type-statistics {
- font-size : $font-size-bigger;
+ font-size: $font-size-bigger;
}
.secondary-leave-type-statistics dt {
text-align: center;
padding-bottom: 15px;
margin-bottom: 15px;
- border-bottom : 1px solid $border-color;
+ border-bottom: 1px solid $border-color;
}
.secondary-leave-type-statistics dd {
padding-left: 10px;
padding-right: 10px;
}
-
.calendar-section-caption {
text-align: center;
font-size: 1.2em;
}
-
.setting-general-2nd-column {
padding-left: 30px;
}
@@ -282,12 +275,14 @@ div.feeds-holder {
/* Fix for issue with modal scrollings on mobiles */
@media (max-width: 768px) {
- body.modal-open { position: fixed; }
+ body.modal-open {
+ position: fixed;
+ }
}
/* To be used for selected items in lists */
.selected-item {
- background : $selected-item-background;
+ background: $selected-item-background;
font-weight: bolder;
}
@@ -296,17 +291,17 @@ div.feeds-holder {
}
.leave_type_color_2 {
- background: #40C4FF !important;
+ background: #40c4ff !important;
}
.leave_type_color_3 {
- background: #FF5722 !important;
+ background: #ff5722 !important;
}
.leave_type_color_4 {
- background: #FF80AB !important;
+ background: #ff80ab !important;
}
.leave_type_color_5 {
- background: #00BCD4 !important;
+ background: #00bcd4 !important;
}
diff --git a/t/integration/add_new_user_with_existing_email.js b/t/integration/add_new_user_with_existing_email.js
index 52ec8fc85..9d7767d00 100644
--- a/t/integration/add_new_user_with_existing_email.js
+++ b/t/integration/add_new_user_with_existing_email.js
@@ -1,12 +1,11 @@
+'use strict'
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- add_new_user_func = require('../lib/add_new_user'),
- config = require('../lib/config'),
- application_host = config.get_application_host();
+const test = require('selenium-webdriver/testing');
+ const register_new_user_func = require('../lib/register_new_user');
+ const login_user_func = require('../lib/login_with_user');
+ const add_new_user_func = require('../lib/add_new_user');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host()
/*
* Scenario to check in this test:
@@ -16,34 +15,35 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Admin tries to add user with email used for other one', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Admin tries to add user with email used for other one', function() {
+ this.timeout(config.get_execution_timeout())
- var new_user_email, driver;
+ let new_user_email, driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ new_user_email = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- new_user_email = data.email;
- done();
- });
- });
+ })
- it("Create new non-admin user", function(done){
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
- email : new_user_email,
- error_message : 'Email is already in use',
+ application_host,
+ driver,
+ email: new_user_email,
+ error_message: 'Email is already in use'
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/bank_holidays/crud_bank_holiday.js b/t/integration/bank_holidays/crud_bank_holiday.js
index f9166ee69..9d0a8384b 100644
--- a/t/integration/bank_holidays/crud_bank_holiday.js
+++ b/t/integration/bank_holidays/crud_bank_holiday.js
@@ -1,230 +1,255 @@
+'use strict'
+
+const register_new_user_func = require('../../lib/register_new_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const check_elements_func = require('../../lib/check_elements')
+const moment = require('moment')
+const By = require('selenium-webdriver').By
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const bankholiday_form_id = '#update_bankholiday_form'
+const new_bankholiday_form_id = '#add_new_bank_holiday_form'
+
+describe('CRUD for bank holidays', function() {
+ let driver
+
+ this.timeout(config.get_execution_timeout())
+
+ it('Performing registration process', function(done) {
+ register_new_user_func({ application_host }).then(data => {
+ driver = data.driver
+ done()
+ })
+ })
-'use strict';
-
-const
- register_new_user_func = require('../../lib/register_new_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- moment = require('moment'),
- By = require('selenium-webdriver').By,
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- bankholiday_form_id = '#update_bankholiday_form',
- new_bankholiday_form_id= '#add_new_bank_holiday_form';
-
-
-describe('CRUD for bank holidays', function(){
- let driver;
-
- this.timeout( config.get_execution_timeout() );
-
- it('Performing registration process', function(done){
- register_new_user_func({ application_host })
- .then((data) => {
- driver = data.driver;
- done();
- });
- });
-
- it("Open page with bank holidays", (done) => {
+ it('Open page with bank holidays', function(done) {
open_page_func({
driver,
- url: application_host + 'settings/bankholidays/?year=2015',
- })
- .then(() => done());
- });
+ url: application_host + 'settings/bankholidays/?year=2015'
+ }).then(() => done())
+ })
- it("Check if there are default bank holidays", function(done){
+ it('Check if there are default bank holidays', function(done) {
check_elements_func({
driver,
- elements_to_check : [{
- selector : bankholiday_form_id+' input[tom-test-hook="name__0"]',
- value : 'Early May bank holiday',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__0"]',
- value : '2015-05-04',
- }],
- })
- .then(() => done());
- });
-
- it("Try to submit form with incorrect date", function(done){
+ elements_to_check: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__0"]',
+ value: 'Early May bank holiday'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__0"]',
+ value: '2015-05-04'
+ }
+ ]
+ }).then(() => done())
+ })
+
+ it('Try to submit form with incorrect date', function(done) {
submit_form_func({
driver,
- form_params : [{
- selector : bankholiday_form_id+' input[tom-test-hook="date__0"]',
- value : 'crap',
- }],
- submit_button_selector : bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
- })
- .then(() => done());
- });
-
- it("Go back to current year page of bank holidays", (done) => {
+ form_params: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__0"]',
+ value: 'crap'
+ }
+ ],
+ submit_button_selector: bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(() => done())
+ })
+
+ it('Go back to current year page of bank holidays', function(done) {
open_page_func({
driver,
- url: `${application_host}settings/bankholidays/?year=${moment().year()}`,
- })
- .then(() => done());
- });
+ url: `${application_host}settings/bankholidays/?year=${moment().year()}`
+ }).then(() => done())
+ })
- it("Check that after some crappy input was provided into the date, it falls back to the current date", function(done){
+ it('Check that after some crappy input was provided into the date, it falls back to the current date', function(done) {
check_elements_func({
driver,
- elements_to_check : [{
- selector : bankholiday_form_id+' input[tom-test-hook="name__0"]',
- value : 'Early May bank holiday',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__0"]',
- value : moment().format('YYYY-MM-DD'),
- }],
- })
- .then(() => done());
- });
-
- it("Update Early spring holiday to be 4th of May", function(done){
+ elements_to_check: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__0"]',
+ value: 'Early May bank holiday'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__0"]',
+ value: moment().format('YYYY-MM-DD')
+ }
+ ]
+ }).then(() => done())
+ })
+
+ it('Update Early spring holiday to be 4th of May', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : bankholiday_form_id+' input[tom-test-hook="date__0"]',
- value : '2015-05-04',
- }],
- submit_button_selector : bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
- })
- .then(() => done());
- });
-
- it("Go back to 2015", (done) => {
+ driver,
+ form_params: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__0"]',
+ value: '2015-05-04'
+ }
+ ],
+ submit_button_selector: bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(() => done())
+ })
+
+ it('Go back to 2015', function(done) {
open_page_func({
driver,
- url: application_host + 'settings/bankholidays/?year=2015',
- })
- .then(() => done());
- });
-
- it("Add new bank holiday to be in the beginning of the list", function(done){
- driver.findElement(By.css('#add_new_bank_holiday_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ url: application_host + 'settings/bankholidays/?year=2015'
+ }).then(() => done())
+ })
+
+ it('Add new bank holiday to be in the beginning of the list', function(done) {
+ driver
+ .findElement(By.css('#add_new_bank_holiday_btn'))
+ .then(el => el.click())
+ .then(() => {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_bankholiday_form_id+' input[name="name__new"]',
- value : 'Z New Year',
- },{
- selector : new_bankholiday_form_id+' input[name="date__new"]',
- value : '2015-01-01',
- }],
- submit_button_selector: new_bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_bankholiday_form_id + ' input[name="name__new"]',
+ value: 'Z New Year'
+ },
+ {
+ selector: new_bankholiday_form_id + ' input[name="date__new"]',
+ value: '2015-01-01'
+ }
+ ],
+ submit_button_selector:
+ new_bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(() => {
+ done()
})
- .then(function(){done()});
- });
- });
-
- it("Add new bank holiday to be in the end of the list", function(done){
- driver.findElement(By.css('#add_new_bank_holiday_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ })
+ })
+
+ it('Add new bank holiday to be in the end of the list', function(done) {
+ driver
+ .findElement(By.css('#add_new_bank_holiday_btn'))
+ .then(el => el.click())
+ .then(() => {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_bankholiday_form_id+' input[name="name__new"]',
- value : 'Xmas',
- },{
- selector : new_bankholiday_form_id+' input[name="date__new"]',
- value : '2015-12-25',
- }],
- submit_button_selector: new_bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
- })
- .then(function(){done()});
- });
- });
-
- it("Check that the order of all three holidays is based on dates rather than names", function(done){
- check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : bankholiday_form_id+' input[tom-test-hook="name__0"]',
- value : 'Z New Year',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__0"]',
- value : '2015-01-01',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="name__1"]',
- value : 'Early May bank holiday',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__1"]',
- value : '2015-05-04',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="name__2"]',
- value : 'Xmas',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__2"]',
- value : '2015-12-25',
- }],
- })
- .then(() => done());
- });
+ driver,
+ form_params: [
+ {
+ selector: new_bankholiday_form_id + ' input[name="name__new"]',
+ value: 'Xmas'
+ },
+ {
+ selector: new_bankholiday_form_id + ' input[name="date__new"]',
+ value: '2015-12-25'
+ }
+ ],
+ submit_button_selector:
+ new_bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(() => {
+ done()
+ })
+ })
+ })
- it("Rename Christmas to have proper name", function(done){
+ it('Check that the order of all three holidays is based on dates rather than names', function(done) {
+ check_elements_func({
+ driver,
+ elements_to_check: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__0"]',
+ value: 'Z New Year'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__0"]',
+ value: '2015-01-01'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__1"]',
+ value: 'Early May bank holiday'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__1"]',
+ value: '2015-05-04'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__2"]',
+ value: 'Xmas'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__2"]',
+ value: '2015-12-25'
+ }
+ ]
+ }).then(() => done())
+ })
+
+ it('Rename Christmas to have proper name', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : bankholiday_form_id+' input[tom-test-hook="name__2"]',
- value : 'Christmas',
- }],
- elements_to_check : [{
- selector : bankholiday_form_id+' input[tom-test-hook="name__2"]',
- value : 'Christmas',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__2"]',
- value : '2015-12-25',
- }],
+ driver,
+ form_params: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__2"]',
+ value: 'Christmas'
+ }
+ ],
+ elements_to_check: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__2"]',
+ value: 'Christmas'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__2"]',
+ value: '2015-12-25'
+ }
+ ],
should_be_successful: true,
- submit_button_selector : bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
- })
- .then(() => done());
- });
+ submit_button_selector: bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(() => done())
+ })
- it("Remove Spring bank holiday", function(done){
+ it('Remove Spring bank holiday', function(done) {
submit_form_func({
driver,
- submit_button_selector : bankholiday_form_id+' button[tom-test-hook="remove__1"]',
- message : /Bank holiday was successfully removed/,
+ submit_button_selector:
+ bankholiday_form_id + ' button[tom-test-hook="remove__1"]',
+ message: /Bank holiday was successfully removed/,
should_be_successful: true,
- elements_to_check: [{
- selector : bankholiday_form_id+' input[tom-test-hook="name__0"]',
- value : 'Z New Year',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__0"]',
- value : '2015-01-01',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="name__1"]',
- value : 'Christmas',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__1"]',
- value : '2015-12-25',
- }],
+ elements_to_check: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__0"]',
+ value: 'Z New Year'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__0"]',
+ value: '2015-01-01'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__1"]',
+ value: 'Christmas'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__1"]',
+ value: '2015-12-25'
+ }
+ ]
+ }).then(() => done())
+ })
+
+ after(function(done) {
+ driver.quit().then(() => {
+ done()
})
- .then(() => done());
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ })
+})
diff --git a/t/integration/bank_holidays/non_default_date_format.js b/t/integration/bank_holidays/non_default_date_format.js
index 4793ba919..ee48590a9 100644
--- a/t/integration/bank_holidays/non_default_date_format.js
+++ b/t/integration/bank_holidays/non_default_date_format.js
@@ -1,17 +1,15 @@
-
-"use strict";
-
-const
- register_new_user_func = require('../../lib/register_new_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- expect = require('chai').expect,
- By = require('selenium-webdriver').By,
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- bankholiday_form_id = '#update_bankholiday_form',
- new_bankholiday_form_id = '#add_new_bank_holiday_form',
- company_edit_form_id = '#company_edit_form';
+'use strict'
+
+const register_new_user_func = require('../../lib/register_new_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const expect = require('chai').expect
+const By = require('selenium-webdriver').By
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const bankholiday_form_id = '#update_bankholiday_form'
+const new_bankholiday_form_id = '#add_new_bank_holiday_form'
+const company_edit_form_id = '#company_edit_form'
/*
* This is a regressiopn for https://github.com/timeoff-management/application/issues/103
@@ -26,211 +24,249 @@ const
*
* */
-describe('Try to manage Bank holidays with non-default date format', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Try to manage Bank holidays with non-default date format', function() {
+ this.timeout(config.get_execution_timeout())
- var driver;
+ let driver
- it('Register new company and ensure it has non-default date format', function(done){
+ it('Register new company and ensure it has non-default date format', function(done) {
register_new_user_func({
- application_host : application_host,
- default_date_format : 'DD/MM/YYYY',
+ application_host,
+ default_date_format: 'DD/MM/YYYY'
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ .then(function(data) {
+ driver = data.driver
+ done()
+ })
+ .catch(err => {
+ console.error('ER', err)
+ })
+ })
- it("Open page with bank holidays", function(done){
+ it('Open page with bank holidays', function(done) {
open_page_func({
driver,
- url: application_host + 'settings/bankholidays/?year=2015',
- })
- .then(() => done());
- });
+ url: application_host + 'settings/bankholidays/?year=2015'
+ }).then(() => done())
+ })
- it("Remove default predefined bank holidays", function(done){
+ it('Remove default predefined bank holidays', function(done) {
submit_form_func({
driver,
- message : /Bank holiday was successfully removed/,
- submit_button_selector : bankholiday_form_id+' button[tom-test-hook="remove__0"]',
- })
- .then(() => done());
- });
-
- it("And make sure that no bank holidays are shown", function(done){
- driver.findElement(By.css('div.tst-no-bank-holidays'))
- .then(function(el){ return el.getText(); })
- .then(function(txt){ expect(txt).to.exist; done() });
- });
+ message: /Bank holiday was successfully removed/,
+ submit_button_selector:
+ bankholiday_form_id + ' button[tom-test-hook="remove__0"]'
+ }).then(() => done())
+ })
- it("Add New year", function(done){
- driver.findElement(By.css('#add_new_bank_holiday_btn'))
- .then(function(el){ return el.click(); })
- .then(function(){
+ it('And make sure that no bank holidays are shown', function(done) {
+ driver
+ .findElement(By.css('div.tst-no-bank-holidays'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(txt) {
+ expect(txt).to.exist
+ done()
+ })
+ })
+ it('Add New year', function(done) {
+ driver
+ .findElement(By.css('#add_new_bank_holiday_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_bankholiday_form_id+' input[name="name__new"]',
- value : 'New Year',
- },{
- selector : new_bankholiday_form_id+' input[name="date__new"]',
- value : '01/01/2015',
- }],
- submit_button_selector: new_bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_bankholiday_form_id + ' input[name="name__new"]',
+ value: 'New Year'
+ },
+ {
+ selector: new_bankholiday_form_id + ' input[name="date__new"]',
+ value: '01/01/2015'
+ }
+ ],
+ submit_button_selector:
+ new_bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
-
- it("Add Second day of New year", function(done){
- driver.findElement(By.css('#add_new_bank_holiday_btn'))
- .then(function(el){ return el.click(); })
- .then(function(){
+ })
+ })
+ it('Add Second day of New year', function(done) {
+ driver
+ .findElement(By.css('#add_new_bank_holiday_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_bankholiday_form_id+' input[name="name__new"]',
- value : 'Second day of New Year',
- },{
- selector : new_bankholiday_form_id+' input[name="date__new"]',
- value : '02/01/2015',
- }],
- submit_button_selector: new_bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_bankholiday_form_id + ' input[name="name__new"]',
+ value: 'Second day of New Year'
+ },
+ {
+ selector: new_bankholiday_form_id + ' input[name="date__new"]',
+ value: '02/01/2015'
+ }
+ ],
+ submit_button_selector:
+ new_bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
- });
+ })
+ })
- it("Add Add Labour day", function(done){
+ it('Add Add Labour day', function(done) {
driver
.findElement(By.css('#add_new_bank_holiday_btn'))
- .then(function(el){ return el.click(); })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_bankholiday_form_id+' input[name="name__new"]',
- value : 'Labour day',
- },{
- selector : new_bankholiday_form_id+' input[name="date__new"]',
- value : '01/05/2015',
- }],
- submit_button_selector: new_bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_bankholiday_form_id + ' input[name="name__new"]',
+ value: 'Labour day'
+ },
+ {
+ selector: new_bankholiday_form_id + ' input[name="date__new"]',
+ value: '01/05/2015'
+ }
+ ],
+ submit_button_selector:
+ new_bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
- });
+ })
+ })
- it("Rename Christmas to have proper name", function(done){
+ it('Rename Christmas to have proper name', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : bankholiday_form_id+' input[tom-test-hook="name__0"]',
- value : 'NOTHING',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="name__1"]',
- value : 'NOTHING',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="name__2"]',
- value : 'NOTHING',
- }],
- elements_to_check : [{
- selector : bankholiday_form_id+' input[tom-test-hook="date__0"]',
- value : '01/01/2015',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__1"]',
- value : '02/01/2015',
- },{
- selector : bankholiday_form_id+' input[tom-test-hook="date__2"]',
- value : '01/05/2015',
- }],
- submit_button_selector : bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
- should_be_successful : true,
+ driver,
+ form_params: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__0"]',
+ value: 'NOTHING'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__1"]',
+ value: 'NOTHING'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="name__2"]',
+ value: 'NOTHING'
+ }
+ ],
+ elements_to_check: [
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__0"]',
+ value: '01/01/2015'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__1"]',
+ value: '02/01/2015'
+ },
+ {
+ selector: bankholiday_form_id + ' input[tom-test-hook="date__2"]',
+ value: '01/05/2015'
+ }
+ ],
+ submit_button_selector: bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/,
+ should_be_successful: true
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
-
- after(function(done){
- driver.quit().then(function(){ done() });
- });
+ })
-});
-
-
-describe("Try to use DD/MM/YY and some missleading date", function(){
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
- this.timeout( config.get_execution_timeout() );
+describe('Try to use DD/MM/YY and some missleading date', function() {
+ this.timeout(config.get_execution_timeout())
- var driver;
+ let driver
- it("Register new company with default date to be DD/MM/YY", function(done){
+ it('Register new company with default date to be DD/MM/YY', function(done) {
register_new_user_func({
- application_host : application_host,
- default_date_format : 'DD/MM/YY',
+ application_host,
+ default_date_format: 'DD/MM/YY'
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open page with bank holidays", function(done){
+ it('Open page with bank holidays', function(done) {
open_page_func({
driver,
- url: application_host + 'settings/bankholidays/',
- })
- .then(() => done());
- });
-
- it("Try to add new bank holiday with date that was reported to be problematic", function(done){
-
- driver.findElement(By.css('#add_new_bank_holiday_btn'))
- .then(function(el){ return el.click(); })
- .then(function(){
+ url: application_host + 'settings/bankholidays/'
+ }).then(() => done())
+ })
+ it('Try to add new bank holiday with date that was reported to be problematic', function(done) {
+ driver
+ .findElement(By.css('#add_new_bank_holiday_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
return submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_bankholiday_form_id+' input[name="name__new"]',
- value : 'Problematic date',
- },{
- selector : new_bankholiday_form_id+' input[name="date__new"]',
- value : '22/08/17',
- }],
- submit_button_selector : new_bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
- });
+ driver,
+ form_params: [
+ {
+ selector: new_bankholiday_form_id + ' input[name="name__new"]',
+ value: 'Problematic date'
+ },
+ {
+ selector: new_bankholiday_form_id + ' input[name="date__new"]',
+ value: '22/08/17'
+ }
+ ],
+ submit_button_selector:
+ new_bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ })
})
- .then(function(){
- done();
- });
-
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ .then(function() {
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/carryOver/justAddedUsers.js b/t/integration/carryOver/justAddedUsers.js
index 374b990b7..232b77615 100644
--- a/t/integration/carryOver/justAddedUsers.js
+++ b/t/integration/carryOver/justAddedUsers.js
@@ -1,20 +1,18 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- until = require('selenium-webdriver').until,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- registerNewUserFunc = require('../../lib/register_new_user'),
- config = require('../../lib/config'),
- openPageFunc = require('../../lib/open_page'),
- submitFormFunc = require('../../lib/submit_form'),
- userInfoFunc = require('../../lib/user_info'),
- applicationHost = config.get_application_host(),
- companyEditFormId = '#company_edit_form',
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const until = require('selenium-webdriver').until
+const Promise = require('bluebird')
+const expect = require('chai').expect
+const registerNewUserFunc = require('../../lib/register_new_user')
+const config = require('../../lib/config')
+const openPageFunc = require('../../lib/open_page')
+const submitFormFunc = require('../../lib/submit_form')
+const userInfoFunc = require('../../lib/user_info')
+const applicationHost = config.get_application_host()
+const companyEditFormId = '#company_edit_form'
+const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario:
@@ -28,95 +26,93 @@ const
*
* */
-describe('Carry over issue for users started in current year', function(){
+describe('Carry over issue for users started in current year', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let driver, email, user_id
- let driver, email, userId;
-
- it("Register new company", done => {
- registerNewUserFunc({ applicationHost })
- .then(data => {
- ({driver, email} = data);
- done();
- });
- });
+ it('Register new company', function(done) {
+ registerNewUserFunc({ applicationHost }).then(data => {
+ ;({ driver, email } = data)
+ done()
+ })
+ })
- it("Obtain information about admin user", done => {
- userInfoFunc({ driver, email })
- .then(data => {
- userId = data.user.id;
- done();
- });
- });
+ it('Obtain information about admin user', function(done) {
+ userInfoFunc({ driver, email }).then(data => {
+ user_id = data.user.id
+ done()
+ })
+ })
- it("Update admin details to have start date at very beginig of this year", done =>{
- userStartsAtTheBeginingOfYear({driver, email})
- .then(() => done())
- });
+ it('Update admin details to have start date at very beginig of this year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email }).then(() => done())
+ })
- it('Open user details page (abcenses section)', function(done){
+ it('Open user details page (abcenses section)', function(done) {
openPageFunc({
driver,
- url : `${applicationHost}users/edit/${userId}/absences/`,
- })
- .then(() => done());
- });
+ url: `${applicationHost}users/edit/${user_id}/absences/`
+ }).then(() => done())
+ })
- it('Ensure user does not have anything carried over from previous year', done => {
+ it('Ensure user does not have anything carried over from previous year', function(done) {
driver
- .findElement( By.css('#allowanceCarriedOverPart') )
+ .findElement(By.css('#allowanceCarriedOverPart'))
.then(span => span.getText())
.then(text => {
- expect( text ).to.be.eq('0');
- done();
- });
- });
+ expect(text).to.be.eq('0')
+ done()
+ })
+ })
- it('Update copany configuration to carry over all unused allowance from previous year', done => {
+ it('Update copany configuration to carry over all unused allowance from previous year', function(done) {
openPageFunc({
driver,
- url : `${applicationHost}settings/general/`,
+ url: `${applicationHost}settings/general/`
})
- .then(() => submitFormFunc({
- driver,
- form_params: [{
- selector: `${companyEditFormId} select[name="carry_over"]`,
- option_selector: 'option[value="1000"]',
- value: '1000',
- }],
- submit_button_selector : `${companyEditFormId} button[type="submit"]`,
- message : /successfully/i,
- should_be_successful : true,
- }))
- .then(() => done())
- });
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: `${companyEditFormId} select[name="carry_over"]`,
+ option_selector: 'option[value="1000"]',
+ value: '1000'
+ }
+ ],
+ submit_button_selector: `${companyEditFormId} button[type="submit"]`,
+ message: /successfully/i,
+ should_be_successful: true
+ })
+ )
+ .then(() => done())
+ })
- it('Recalculate carried over allowance for the company', done => {
+ it('Recalculate carried over allowance for the company', function(done) {
submitFormFunc({
driver,
- submit_button_selector: '#calculate_carry_over_form button[type="submit"]',
+ submit_button_selector:
+ '#calculate_carry_over_form button[type="submit"]',
message: /allowance was successfully carried over/i,
- should_be_successful: true,
- })
- .then(() => done());
- });
+ should_be_successful: true
+ }).then(() => done())
+ })
- it("Ensure that newly created user's carried over still remains 0", done => {
+ it("Ensure that newly created user's carried over still remains 0", function(done) {
openPageFunc({
driver,
- url : `${applicationHost}users/edit/${userId}/absences/`,
+ url: `${applicationHost}users/edit/${user_id}/absences/`
})
- .then(() => driver.findElement( By.css('#allowanceCarriedOverPart') ))
- .then(span => span.getText())
- .then(text => {
- expect( text ).to.be.eq('0');
- done();
- });
- });
-
- after(done => {
- driver.quit().then(() => done());
- });
-
-});
+ .then(() => driver.findElement(By.css('#allowanceCarriedOverPart')))
+ .then(span => span.getText())
+ .then(text => {
+ expect(text).to.be.eq('0')
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/carryOver/negativeWhenSwitchedOff.js b/t/integration/carryOver/negativeWhenSwitchedOff.js
index 0542492c6..fb5fe39a3 100644
--- a/t/integration/carryOver/negativeWhenSwitchedOff.js
+++ b/t/integration/carryOver/negativeWhenSwitchedOff.js
@@ -1,179 +1,195 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- until = require('selenium-webdriver').until,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- moment = require('moment'),
- registerNewUserFunc = require('../../lib/register_new_user'),
- checkElementsFunc = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- openPageFunc = require('../../lib/open_page'),
- submitFormFunc = require('../../lib/submit_form'),
- userInfoFunc = require('../../lib/user_info'),
- applicationHost = config.get_application_host(),
- companyEditFormId = '#company_edit_form',
- departmentEditFormId= '#department_edit_form',
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+'use strict'
+
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const moment = require('moment')
+const registerNewUserFunc = require('../../lib/register_new_user')
+const checkElementsFunc = require('../../lib/check_elements')
+const config = require('../../lib/config')
+const openPageFunc = require('../../lib/open_page')
+const submitFormFunc = require('../../lib/submit_form')
+const userInfoFunc = require('../../lib/user_info')
+const applicationHost = config.get_application_host()
+const companyEditFormId = '#company_edit_form'
+const departmentEditFormId = '#department_edit_form'
+const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario:
* * Create new company
* * Amend its user to started at the very begining of last year
* * Add and approve week long leave in last year
- * * Adjust user's deparment's allpwance to be 1 day
+ * * Adjust user's deparment's allowance to be 1 day
* * Ensure that company has Carry Over set to be 'None'
* * Calculate carry over
* * Ensure that newly created user's carried over still remains 0
*
* */
-describe('No negative allowanca is carried overs', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('No negative allowance is carried overs', function() {
+ this.timeout(config.get_execution_timeout())
- let driver, email, userId;
+ let driver, email, user_id
- it("Register new company", done => {
- registerNewUserFunc({ applicationHost })
- .then(data => {
- ({driver, email} = data);
- done();
- });
- });
+ it('Register new company', function(done) {
+ registerNewUserFunc({ applicationHost }).then(data => {
+ ;({ driver, email } = data)
+ done()
+ })
+ })
- it("Obtain information about admin user", done => {
- userInfoFunc({ driver, email })
- .then(data => {
- userId = data.user.id;
- done();
- });
- });
+ it('Obtain information about admin user', function(done) {
+ userInfoFunc({ driver, email }).then(data => {
+ user_id = data.user.id
+ done()
+ })
+ })
- it("Amend its user to started at the very begining of last year", done =>{
+ it('Amend its user to started at the very begining of last year', function(done) {
userStartsAtTheBeginingOfYear({
driver,
email,
- overwriteDate:moment.utc().add(-1,'y').startOf('year'),
- })
- .then(() => done())
- });
-
- it('Update user to have her leaves be auto apporved', done => {
+ overwriteDate: moment
+ .utc()
+ .add(-1, 'y')
+ .startOf('year')
+ }).then(() => done())
+ })
+
+ it('Update user to have her leaves be auto approved', function(done) {
openPageFunc({
driver,
- url: `${applicationHost}users/edit/${userId}/`,
+ url: `${applicationHost}users/edit/${user_id}/`
})
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector : 'input[name="auto_approve"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
- }))
- .then(() => done());
- });
-
- it("Add and approve week long leave in last year", done => {
- const lastYear = moment.utc().add(-1,'y').year();
-
- openPageFunc({driver, url: applicationHost})
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="auto_approve"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Add and approve week long leave in last year', function(done) {
+ const lastYear = moment
+ .utc()
+ .add(-1, 'y')
+ .year()
+
+ openPageFunc({ driver, url: applicationHost })
.then(() => driver.findElement(By.css('#book_time_off_btn')))
.then(el => el.click())
.then(el => driver.sleep(1000))
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector : 'input#from',
- value : `${lastYear}-06-01`,
- },{
- selector : 'input#to',
- value : `${lastYear}-06-08`,
- }],
- message : /New leave request was added/,
- }))
- .then(() => done());
- });
-
- it("Adjust user's deparment's allpwance to be 1 day", done => {
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: `${lastYear}-06-01`
+ },
+ {
+ selector: 'input#to',
+ value: `${lastYear}-06-08`
+ }
+ ],
+ message: /New leave request was added/
+ })
+ )
+ .then(() => done())
+ })
+
+ it("Adjust user's deparment's allowance to be 1 day", function(done) {
openPageFunc({
driver,
- url: `${applicationHost}settings/departments/`,
+ url: `${applicationHost}settings/departments/`
})
- .then(() => driver.findElements(By.css('a[href*="/settings/departments/edit/"]')))
- .then(links => links[0].click())
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector: `${departmentEditFormId} select[name="allowance"]`,
- option_selector: 'option[value="1"]',
- value: '1',
- }],
- submit_button_selector : `${departmentEditFormId} button[type="submit"]`,
- message : /Department .* was updated/,
- should_be_successful : true,
- }))
- .then(() => done());
- });
-
- it('Ensure that nominal allowance was reduced to 1', done => {
+ .then(() =>
+ driver.findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ )
+ .then(links => links[0].click())
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: `${departmentEditFormId} select[name="allowance"]`,
+ option_selector: 'option[value="1"]',
+ value: '1'
+ }
+ ],
+ submit_button_selector: `${departmentEditFormId} button[type="submit"]`,
+ message: /Department .* was updated/,
+ should_be_successful: true
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Ensure that nominal allowance was reduced to 1', function(done) {
openPageFunc({
driver,
- url: `${applicationHost}users/edit/${userId}/absences/`,
- })
- .then(() => driver.findElement(By.css('#nominalAllowancePart')))
- .then(el => el.getText())
- .then(text => {
- expect(text).to.be.eq('1');
- done();
+ url: `${applicationHost}users/edit/${user_id}/absences/`
})
- });
-
- it('Ensure that company has Carry Over set to be "None"', done => {
+ .then(() => driver.findElement(By.css('#nominalAllowancePart')))
+ .then(el => el.getText())
+ .then(text => {
+ expect(text).to.be.eq('1')
+ done()
+ })
+ })
+
+ it('Ensure that company has Carry Over set to be "None"', function(done) {
openPageFunc({
driver,
- url : `${applicationHost}settings/general/`,
+ url: `${applicationHost}settings/general/`
})
- .then(() => checkElementsFunc({
- driver,
- elements_to_check : [{
- selector: `${companyEditFormId} select[name="carry_over"]`,
- value: '0',
- }],
- }))
- .then(() => done());
- });
-
- it('Calculate carry over', done => {
+ .then(() =>
+ checkElementsFunc({
+ driver,
+ elements_to_check: [
+ {
+ selector: `${companyEditFormId} select[name="carry_over"]`,
+ value: '0'
+ }
+ ]
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Calculate carry over', function(done) {
submitFormFunc({
driver,
- submit_button_selector: '#calculate_carry_over_form button[type="submit"]',
+ submit_button_selector:
+ '#calculate_carry_over_form button[type="submit"]',
message: /allowance was successfully carried over/i,
- should_be_successful: true,
- })
- .then(() => done());
- });
+ should_be_successful: true
+ }).then(() => done())
+ })
- it("Ensure that newly created user's carried over still remains 0", done => {
+ it("Ensure that newly created user's carried over still remains 0", function(done) {
openPageFunc({
driver,
- url : `${applicationHost}users/edit/${userId}/absences/`,
+ url: `${applicationHost}users/edit/${user_id}/absences/`
})
- .then(() => driver.findElement( By.css('#allowanceCarriedOverPart') ))
- .then(span => span.getText())
- .then(text => {
- expect( text ).to.be.eq('0');
- done();
- });
- });
-
- after(done => {
- driver.quit().then(() => done());
- });
-});
+ .then(() => driver.findElement(By.css('#allowanceCarriedOverPart')))
+ .then(span => span.getText())
+ .then(text => {
+ expect(text).to.be.eq('0')
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/company/delete_account.js b/t/integration/company/delete_account.js
index 861868e99..2e48c0180 100644
--- a/t/integration/company/delete_account.js
+++ b/t/integration/company/delete_account.js
@@ -1,21 +1,16 @@
+'use strict'
-"use strict";
-
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require('bluebird'),
- register_new_user_func = require('../../lib/register_new_user'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- company_edit_form_id ='#company_edit_form',
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const Promise = require('bluebird')
+const register_new_user_func = require('../../lib/register_new_user')
+const login_user_func = require('../../lib/login_with_user')
+const logout_user_func = require('../../lib/logout_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario to test:
@@ -33,215 +28,258 @@ const
*
* */
-describe("Remove company account", function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Remove company account', function() {
+ this.timeout(config.get_execution_timeout())
- let driver, emailCompanyA, emailCompanyB;
+ let driver, emailCompanyA, emailCompanyB
- it('Create Company A', done => {
+ it('Create Company A', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(data => {
+ emailCompanyA = data.email
+ driver = data.driver
+ done()
})
- .then(data => {
- emailCompanyA = data.email;
- driver = data.driver;
- done();
- });
- });
-
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email:emailCompanyA, year: 2018})
- .then(() => done())
- });
+ })
+
+ it('Ensure user A starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({
+ driver,
+ email: emailCompanyA,
+ year: 2018
+ }).then(() => done())
+ })
- it("Book a leave by user from company A", done => {
- driver.findElement(By.css('#book_time_off_btn'))
+ it('Book a leave by user from company A', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(el => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2018-06-06',
- },{
- selector : 'input#to',
- value : '2018-06-06',
- }],
- message : /New leave request was added/,
- }))
- .then(() => done());
- });
-
- it("Close down current session", done =>{
- driver.quit().then(() => done());
- });
-
- it('Create Company B', done => {
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2018-06-06'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-06-06'
+ }
+ ],
+ message: /New leave request was added/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Close down current session', function(done) {
+ driver.quit().then(() => done())
+ })
+
+ it('Create Company B', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(data => {
+ emailCompanyB = data.email
+ driver = data.driver
+ done()
})
- .then(data => {
- emailCompanyB = data.email;
- driver = data.driver;
- done();
- });
- });
-
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email:emailCompanyB, year: 2018})
- .then(() => open_page_func({ url:application_host,driver}))
+ })
+
+ it('Ensure user B starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email: emailCompanyB, year: 2018 })
+ .then(() => open_page_func({ url: application_host, driver }))
.then(() => done())
- });
+ })
- it("Book a leave by user from company B", done => {
- driver.findElement(By.css('#book_time_off_btn'))
+ it('Book a leave by user from company B', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(el => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2018-06-07',
- },{
- selector : 'input#to',
- value : '2018-06-07',
- }],
- message : /New leave request was added/,
- }))
- .then(() => done());
- });
-
- it("Logout from Company B", done => {
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2018-06-07'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-06-07'
+ }
+ ],
+ message: /New leave request was added/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Logout from Company B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as Admin from company A and remove company's account", done => {
- let companyName;
+ it("Login as Admin from company A and remove company's account", function(done) {
+ let companyName
login_user_func({
- application_host : application_host,
- user_email : emailCompanyA,
- driver : driver,
+ application_host,
+ user_email: emailCompanyA,
+ driver
})
- .then(() => open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
- }))
-
- // Try to ignore company name confirmation
- .then(() => driver.findElement(By.css('button[data-target="#remove_company_modal"]')))
- .then(btn => btn.click())
- .then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="confirm_name"]',
- value : "blahblahblah",
- }],
- submit_button_selector : '#remove_company_form button[type="submit"]',
- message : /Failed to remove company. Reason: Provided name confirmation does not match company one/,
- }))
-
- // Fetch company name
- .then(() => driver.findElement(By.css('#input_company_name')))
- .then(el => el.getAttribute('value'))
- .then(val => Promise.resolve(companyName = val))
-
- .then(() => driver.findElement(By.css('button[data-target="#remove_company_modal"]')))
- .then(btn => btn.click())
- .then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="confirm_name"]',
- value : companyName,
- }],
- submit_button_selector : '#remove_company_form button[type="submit"]',
- message : new RegExp(`Company ${ companyName } and related data were successfully removed`),
- }))
-
- .then(() => done());
- });
-
- it("Ensure that user is logout (by trying to poen general setting page)", done => {
+ .then(() =>
+ open_page_func({
+ url: application_host + 'settings/general/',
+ driver
+ })
+ )
+
+ // Try to ignore company name confirmation
+ .then(() =>
+ driver.findElement(
+ By.css('button[data-target="#remove_company_modal"]')
+ )
+ )
+ .then(btn => btn.click())
+ .then(() => driver.sleep(1000))
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="confirm_name"]',
+ value: 'blahblahblah'
+ }
+ ],
+ submit_button_selector: '#remove_company_form button[type="submit"]',
+ message: /Failed to remove company. Reason: Provided name confirmation does not match company one/
+ })
+ )
+
+ // Fetch company name
+ .then(() => driver.findElement(By.css('#input_company_name')))
+ .then(el => el.getAttribute('value'))
+ .then(val => Promise.resolve((companyName = val)))
+
+ .then(() =>
+ driver.findElement(
+ By.css('button[data-target="#remove_company_modal"]')
+ )
+ )
+ .then(btn => btn.click())
+ .then(() => driver.sleep(1000))
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="confirm_name"]',
+ value: companyName
+ }
+ ],
+ submit_button_selector: '#remove_company_form button[type="submit"]',
+ message: new RegExp(
+ `Company ${companyName} and related data were successfully removed`
+ )
+ })
+ )
+
+ .then(() => done())
+ })
+
+ it('Ensure that user is logout (by trying to poen general setting page)', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
})
- .then(() => driver.getCurrentUrl())
- .then(url => {
- expect(url).to.include('/login/', "URL point to Login page");
- done();
- })
- });
+ .then(() => driver.getCurrentUrl())
+ .then(url => {
+ expect(url).to.include('/login/', 'URL point to Login page')
+ done()
+ })
+ })
- it("Ensure it is not possible to login back", done => {
+ it('Ensure it is not possible to login back', function(done) {
login_user_func({
- application_host : application_host,
- user_email : emailCompanyA,
- driver : driver,
- should_fail : true,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: emailCompanyA,
+ driver,
+ should_fail: true
+ }).then(() => done())
+ })
- it("Login as admin of company B", done => {
+ it('Login as admin of company B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : emailCompanyB,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: emailCompanyB,
+ driver
+ }).then(() => done())
+ })
- it("Ensure that admin still has a leave registered", done => {
+ it('Ensure that admin still has a leave registered', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
})
- .then(() => driver.findElements(By.css('table.user-requests-table td[data-tom-leave-dates="1"]')))
+ .then(() =>
+ driver.findElements(
+ By.css('table.user-requests-table td[data-tom-leave-dates="1"]')
+ )
+ )
- .then(els => {
- expect(els.length, 'Ensure two elements with leave dates were found').to.be.equal(1);
- return Promise.map(els, (el => el.getText()));
- })
- .then(dates_str => {
- expect(dates_str.sort(), 'Ensure that date ranges values are as expected')
- .to.be.deep.equal([
- '2018-06-07 (morning) 2018-06-07'
- ]);
- done();
- });
- });
-
- it("Ensure that there are still records in Email audit page", done => {
+ .then(els => {
+ expect(
+ els.length,
+ 'Ensure two elements with leave dates were found'
+ ).to.be.equal(1)
+ return Promise.map(els, el => el.getText())
+ })
+ .then(dates_str => {
+ expect(
+ dates_str.sort(),
+ 'Ensure that date ranges values are as expected'
+ ).to.be.deep.equal(['2018-06-07 (morning) 2018-06-07'])
+ done()
+ })
+ })
+
+ it('Ensure that there are still records in Email audit page', function(done) {
open_page_func({
- url : application_host + 'audit/email/',
- driver : driver,
- })
- .then(() => driver.findElements(By.css('tr.vpp-email-audit-entry-header')))
- .then(els => {
- expect(els.length, "Emsure that we have three email records").to.be.equal(3);
- done();
+ url: application_host + 'audit/email/',
+ driver
})
- });
+ .then(() =>
+ driver.findElements(By.css('tr.vpp-email-audit-entry-header'))
+ )
+ .then(els => {
+ expect(
+ els.length,
+ 'Emsure that we have three email records'
+ ).to.be.equal(3)
+ done()
+ })
+ })
- after(done => {
- driver.quit().then(() => done());
- });
-});
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/company/edit_company_details.js b/t/integration/company/edit_company_details.js
index 06f5e1e61..4ffc174be 100644
--- a/t/integration/company/edit_company_details.js
+++ b/t/integration/company/edit_company_details.js
@@ -1,60 +1,62 @@
+'use strict'
-'use strict';
+const test = require('selenium-webdriver/testing');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const login_user_func = require('../../lib/login_with_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host();
+ const company_edit_form_id = '#company_edit_form'
-const
- test = require('selenium-webdriver/testing'),
- register_new_user_func = require('../../lib/register_new_user'),
- login_user_func = require('../../lib/login_with_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- company_edit_form_id ='#company_edit_form';
+describe('Edit company details', function() {
+ let driver
+ this.timeout(config.get_execution_timeout())
-describe('Edit company details', function(){
- var driver;
-
- this.timeout( config.get_execution_timeout() );
-
- it("Performing registration process", function( done ){
+ it('Performing registration process', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open page for editing company details", function(done){
+ it('Open page for editing company details', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Check that company is been updated if valid values are submitted", function(done){
+ it('Check that company is been updated if valid values are submitted', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : company_edit_form_id+' input[name="name"]',
- value : 'Test companu ltd',
- },{
- selector : company_edit_form_id+' select[name="country"]',
- option_selector : 'option[value="US"]',
- value : 'US',
- }],
- submit_button_selector : company_edit_form_id+' button[type="submit"]',
- message : /successfully/i,
- should_be_successful : true,
+ driver,
+ form_params: [
+ {
+ selector: company_edit_form_id + ' input[name="name"]',
+ value: 'Test companu ltd'
+ },
+ {
+ selector: company_edit_form_id + ' select[name="country"]',
+ option_selector: 'option[value="US"]',
+ value: 'US'
+ }
+ ],
+ submit_button_selector: company_edit_form_id + ' button[type="submit"]',
+ message: /successfully/i,
+ should_be_successful: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/crud_users.js b/t/integration/crud_users.js
index 97fe2ea2a..b0daec17c 100644
--- a/t/integration/crud_users.js
+++ b/t/integration/crud_users.js
@@ -1,19 +1,18 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- add_new_user_func = require('../lib/add_new_user'),
- config = require('../lib/config'),
- application_host = config.get_application_host(),
- department_edit_form_id = '#department_edit_form';
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const Promise = require('bluebird')
+const register_new_user_func = require('../lib/register_new_user')
+const login_user_func = require('../lib/login_with_user')
+const open_page_func = require('../lib/open_page')
+const submit_form_func = require('../lib/submit_form')
+const add_new_user_func = require('../lib/add_new_user')
+const config = require('../lib/config')
+const application_host = config.get_application_host()
+const department_edit_form_id = '#department_edit_form'
/*
* Scenario to check:
@@ -37,417 +36,450 @@ var test = require('selenium-webdriver/testing'),
*
* */
+describe('CRUD for users', function() {
+ this.timeout(config.get_execution_timeout())
-describe('CRUD for users', function(){
-
- this.timeout( config.get_execution_timeout() );
-
- var email_admin , admin_user_id,
- email_manager , manager_user_id,
- email_employee, employee_user_id,
- driver;
+ let email_admin,
+ admin_user_id,
+ email_manager,
+ manager_user_id,
+ email_employee,
+ employee_user_id,
+ driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
-
+ })
- it("Create ADMIN-to-be user", function(done){
+ it('Create ADMIN-to-be user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_admin = data.new_user_email
+ done()
})
- .then(function(data){
- email_admin = data.new_user_email;
- done();
- });
- });
+ })
- it("Create MANAGER-to-be user", function(done){
+ it('Create MANAGER-to-be user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_manager = data.new_user_email
+ done()
})
- .then(function(data){
- email_manager = data.new_user_email;
- done();
- });
- });
+ })
- it("Create EMPLOYEE-to-be user", function(done){
+ it('Create EMPLOYEE-to-be user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_employee = data.new_user_email
+ done()
})
- .then(function(data){
- email_employee = data.new_user_email;
- done();
- });
- });
+ })
- it("Open department management page", function(done){
+ it('Open department management page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
- })
- .then(function(){ done() });
- });
-
- it("Get the Admin, Manager and Employee IDs", function(done){
- driver.findElement(
- By.css('select[name="boss_id__new"] option:nth-child(2)')
- )
- .then(function(el){
- return el.getAttribute('value');
- })
- .then(function(value){
- admin_user_id = value;
- return driver.findElement(
- By.css('select[name="boss_id__new"] option:nth-child(3)')
- );
- })
- .then(function(el){
- return el.getAttribute('value');
- })
- .then(function(value){
- manager_user_id = value;
- return driver.findElement(
- By.css('select[name="boss_id__new"] option:nth-child(4)')
- );
- })
- .then(function(el){
- return el.getAttribute('value');
- })
- .then(function(value){
- employee_user_id = value;
- [manager_user_id, admin_user_id, employee_user_id].forEach(
- function(id){ expect( id ).to.match(/^\d+$/); }
- );
- done();
- });
- });
-
- it("And update its boss to be MANAGER", function(done){
- open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
- })
- .then(() => driver
- .findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(links => links[0].click())
- )
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="name"]',
- // Just to make sure it is always first in the lists
- value : 'AAAAA',
- },{
- selector : 'select[name="allowance"]',
- option_selector : 'option[value="15"]',
- value : '15',
- },{
- selector : 'select[name="boss_id"]',
- option_selector : 'select[name="boss_id"] option:nth-child(3)',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Get the Admin, Manager and Employee IDs', function(done) {
+ driver
+ .findElement(By.css('select[name="manager_id__new"] option:nth-child(2)'))
+ .then(function(el) {
+ return el.getAttribute('value')
})
- )
- .then(() => done());
- });
+ .then(function(value) {
+ admin_user_id = value
+ return driver.findElement(
+ By.css('select[name="manager_id__new"] option:nth-child(3)')
+ )
+ })
+ .then(function(el) {
+ return el.getAttribute('value')
+ })
+ .then(function(value) {
+ manager_user_id = value
+ return driver.findElement(
+ By.css('select[name="manager_id__new"] option:nth-child(4)')
+ )
+ })
+ .then(function(el) {
+ return el.getAttribute('value')
+ })
+ .then(function(value) {
+ employee_user_id = value
+ ;[manager_user_id, admin_user_id, employee_user_id].forEach(function(
+ id
+ ) {
+ expect(id).to.match(/^\d+$/)
+ })
+ done()
+ })
+ })
- it("Open 'users' page", function(done){
+ it('And update its manager to be MANAGER', function(done) {
+ open_page_func({
+ url: application_host + 'settings/departments/',
+ driver
+ })
+ .then(() =>
+ driver
+ .findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ .then(links => links[0].click())
+ )
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="name"]',
+ // Just to make sure it is always first in the lists
+ value: 'AAAAA'
+ },
+ {
+ selector: 'select[name="allowance"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ },
+ {
+ selector: 'select[name="manager_id"]',
+ option_selector: 'select[name="manager_id"] option:nth-child(3)'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it("Open 'users' page", function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Check that system has 4 users (one currently logged in and 3 added)', function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(4);
- done();
- });
- });
-
- it("Open EMPLOYEE user details page", function(done){
+ it('Check that system has 4 users (one currently logged in and 3 added)', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(4)
+ done()
+ })
+ })
+
+ it('Open EMPLOYEE user details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+employee_user_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + employee_user_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And remove account", function(done){
+ it('And remove account', function(done) {
submit_form_func({
- submit_button_selector : 'button#remove_btn',
- driver : driver,
- message : /Employee records were removed from the system/,
- confirm_dialog : true,
+ submit_button_selector: 'button#remove_btn',
+ driver,
+ message: /Employee records were removed from the system/,
+ confirm_dialog: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Check that system has 3 users (one currently logged in and 2 added)", function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(3);
- done();
- });
- });
-
- it("Open MANAGER user details page", function(done){
+ it('Check that system has 3 users (one currently logged in and 2 added)', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(3)
+ done()
+ })
+ })
+
+ it('Open MANAGER user details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+manager_user_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + manager_user_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to remove account", function(done){
+ it('Try to remove account', function(done) {
submit_form_func({
- submit_button_selector : 'button#remove_btn',
- driver : driver,
- message : /Cannot remove supervisor/,
- confirm_dialog : true,
+ submit_button_selector: 'button#remove_btn',
+ driver,
+ message: /Cannot remove supervisor/,
+ confirm_dialog: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open 'users' page", function(done){
+ it("Open 'users' page", function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done() });
- });
+ })
- it('Check that system still has 3 users (one currently logged in and 2 added)', function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(3);
- done();
- });
- });
-
- it('Open departments', function(done){
+ it('Check that system still has 3 users (one currently logged in and 2 added)', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(3)
+ done()
+ })
+ })
+
+ it('Open departments', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('... and update the very first user is an supervisor', function(done){
+ it('... and update the very first user is an supervisor', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
- })
- .then(() => driver
- .findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(links => links[0].click())
- )
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="name"]',
- // just to make sure it is always first in the lists
- value : 'aaaaa',
- },{
- selector : 'select[name="allowance"]',
- option_selector : 'option[value="15"]',
- value : '15',
- },{
- selector : 'select[name="boss_id"]',
- option_selector : 'select[name="boss_id"] option:nth-child(1)',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
- }))
- .then(() => done());
- });
-
- it("Open ex-MANAGER user details page", function(done){
+ url: application_host + 'settings/departments/',
+ driver
+ })
+ .then(() =>
+ driver
+ .findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ .then(links => links[0].click())
+ )
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="name"]',
+ // just to make sure it is always first in the lists
+ value: 'aaaaa'
+ },
+ {
+ selector: 'select[name="allowance"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ },
+ {
+ selector: 'select[name="manager_id"]',
+ option_selector: 'select[name="manager_id"] option:nth-child(1)'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Open ex-MANAGER user details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+manager_user_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + manager_user_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Remove account", function(done){
+ it('Remove account', function(done) {
submit_form_func({
- submit_button_selector : 'button#remove_btn',
- driver : driver,
- message : /Employee records were removed from the system/,
- confirm_dialog : true,
+ submit_button_selector: 'button#remove_btn',
+ driver,
+ message: /Employee records were removed from the system/,
+ confirm_dialog: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Check that system does not have ex-MANAGER', function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- // 1 that registered company and other is ADMIN
- expect(elements.length).to.be.equal(2);
- done();
- });
- });
-
- it("Open ADMIN user details page", function(done){
+ it('Check that system does not have ex-MANAGER', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ // 1 that registered company and other is ADMIN
+ expect(elements.length).to.be.equal(2)
+ done()
+ })
+ })
+
+ it('Open ADMIN user details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+admin_user_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + admin_user_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make sure that ADMIN has admin privilegues', function(done){
+ it('Make sure that ADMIN has admin privilegues', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
- })
- .then(function(){ done() });
- });
-
- it('... and try to remove account', function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('... and try to remove account', function(done) {
submit_form_func({
- submit_button_selector : 'button#remove_btn',
- driver : driver,
- message : /Cannot remove administrator user/,
- confirm_dialog : true,
+ submit_button_selector: 'button#remove_btn',
+ driver,
+ message: /Cannot remove administrator user/,
+ confirm_dialog: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open 'users' page", function(done){
+ it("Open 'users' page", function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Check that system still has 2 users (one currently logged in and ADMIN)', function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(2);
- done();
- });
- });
-
- it("Open ADMIN user details page (absences)", function(done){
+ it('Check that system still has 2 users (one currently logged in and ADMIN)', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(2)
+ done()
+ })
+ })
+
+ it('Open ADMIN user details page (absences)', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+admin_user_id+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + admin_user_id + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure Adjustment works: check that system prevents from using non-halfs for adjustments', function(done){
+ it('Ensure Adjustment works: check that system prevents from using non-halfs for adjustments', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="adjustment"]',
- value : '1.2',
- change_step: true,
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /New allowance adjustment of user should be either whole integer number or with half/,
- })
- .then(function(){ done() });
- });
-
- it('If the adjustment is with half, it is OK', function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="adjustment"]',
+ value: '1.2',
+ change_step: true
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /New allowance adjustment of user should be either whole integer number or with half/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('If the adjustment is with half, it is OK', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="adjustment"]',
- value : '1.5',
- }],
- submit_button_selector : 'button#save_changes_btn',
- should_be_successful : true,
- message : /Details for .+ were updated/,
- })
- .then(function(){ done() });
- });
-
- it('If the adjustment is with half and is negative, it is OK', function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="adjustment"]',
+ value: '1.5'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ should_be_successful: true,
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('If the adjustment is with half and is negative, it is OK', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="adjustment"]',
- value : '-1.5',
- }],
- submit_button_selector : 'button#save_changes_btn',
- should_be_successful : true,
- message : /Details for .+ were updated/,
- })
- .then(function(){ done() });
- });
-
- it("Open ADMIN user details page (general)", function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="adjustment"]',
+ value: '-1.5'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ should_be_successful: true,
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open ADMIN user details page (general)', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+admin_user_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + admin_user_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Revoke admin rights', function(done){
+ it('Revoke admin rights', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'off',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
- })
- .then(function(){ done() });
- });
-
- it("Remove account", function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'off'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Remove account', function(done) {
submit_form_func({
- submit_button_selector : 'button#remove_btn',
- driver : driver,
- message : /Employee records were removed from the system/,
- confirm_dialog : true,
+ submit_button_selector: 'button#remove_btn',
+ driver,
+ message: /Employee records were removed from the system/,
+ confirm_dialog: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Check that system has only one - currently logged in user', function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(1);
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ it('Check that system has only one - currently logged in user', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(1)
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/deactivate_and_activate_user.js b/t/integration/deactivate_and_activate_user.js
index 78a14c082..09791e7af 100644
--- a/t/integration/deactivate_and_activate_user.js
+++ b/t/integration/deactivate_and_activate_user.js
@@ -1,19 +1,18 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- moment = require('moment'),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- add_new_user_func = require('../lib/add_new_user'),
- logout_user_func = require('../lib/logout_user'),
- user_info_func = require('../lib/user_info'),
- config = require('../lib/config'),
- application_host = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const moment = require('moment');
+ const register_new_user_func = require('../lib/register_new_user');
+ const login_user_func = require('../lib/login_with_user');
+ const open_page_func = require('../lib/open_page');
+ const submit_form_func = require('../lib/submit_form');
+ const add_new_user_func = require('../lib/add_new_user');
+ const logout_user_func = require('../lib/logout_user');
+ const user_info_func = require('../lib/user_info');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host()
/*
* Scenario to check:
@@ -28,170 +27,190 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Deactivate and activate user', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Deactivate and activate user', function() {
+ this.timeout(config.get_execution_timeout())
- var email_admin, email_employee, employee_id, driver;
+ let email_admin, email_employee, employee_id, driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ email_admin = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- email_admin = data.email;
- driver = data.driver;
- done();
- });
- });
-
- it("Create EMPLOYEE", function(done){
+ })
+
+ it('Create EMPLOYEE', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_employee = data.new_user_email
+ done()
})
- .then(function(data){
- email_employee = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about employee", function(done){
+ it('Obtain information about employee', function(done) {
user_info_func({
- driver : driver,
- email : email_employee,
+ driver,
+ email: email_employee
+ }).then(function(data) {
+ employee_id = data.user.id
+ done()
})
- .then(function(data){
- employee_id = data.user.id;
- done();
- });
- });
-
- it('Check that the deactivated badge is not displayed', function(done){
- driver.findElements(By.className('badge alert-warning'))
- .then(els => {
- if (els.length > 0){
+ })
+
+ it('Check that the deactivated badge is not displayed', function(done) {
+ driver.findElements(By.className('badge alert-warning')).then(els => {
+ if (els.length > 0) {
throw new Error('The badge was found')
} else {
- done();
+ done()
}
})
- });
+ })
- it('Mark EMPLOYEE as inactive by specifying end date to be in past', function(done){
+ it('Mark EMPLOYEE as inactive by specifying end date to be in past', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+employee_id+'/',
- driver : driver,
- })
- .then(function(){
+ url: application_host + 'users/edit/' + employee_id + '/',
+ driver
+ }).then(function() {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#end_date_inp',
- value : moment().subtract(1, 'days').format('YYYY-MM-DD'),
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
- should_be_successful : true,
+ driver,
+ form_params: [
+ {
+ selector: 'input#end_date_inp',
+ value: moment()
+ .subtract(1, 'days')
+ .format('YYYY-MM-DD')
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/,
+ should_be_successful: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
-
- it('Check that the deactivated badge is displayed', function(done){
- driver.findElements(By.className('badge alert-warning'))
- .then(els => {expect(els.length).to.be.eql(1, 'No badge visible');
- return els[0].getText();
})
- .then(val => {
- expect(val).to.be.eql('Deactivated', 'It is not the deactivated badge');
- done();
- });
- });
+ })
+
+ it('Check that the deactivated badge is displayed', function(done) {
+ driver
+ .findElements(By.className('badge alert-warning'))
+ .then(els => {
+ expect(els.length).to.be.eql(1, 'No badge visible')
+ return els[0].getText()
+ })
+ .then(val => {
+ expect(val).to.be.eql('Deactivated', 'It is not the deactivated badge')
+ done()
+ })
+ })
- it("Logout from ADMIN", function(done){
+ it('Logout from ADMIN', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Create another company for EMPLOYEE email', function(done){
+ it('Create another company for EMPLOYEE email', function(done) {
register_new_user_func({
- application_host : application_host,
- user_email : email_employee,
- driver : driver,
+ application_host,
+ user_email: email_employee,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from new company created by EMPLOYEE", function(done){
+ it('Logout from new company created by EMPLOYEE', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login back as ADMIN", function(done){
+ it('Login back as ADMIN', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_admin,
- driver : driver,
+ application_host,
+ user_email: email_admin,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to activate EMPLOYEE back. Open details page", function(done){
+ it('Try to activate EMPLOYEE back. Open details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+employee_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + employee_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('... use end_date in future', function(done){
+ it('... use end_date in future', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#end_date_inp',
- value : moment().add(1, 'days').format('YYYY-MM-DD'),
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /There is an active account with similar email somewhere within system/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#end_date_inp',
+ value: moment()
+ .add(1, 'days')
+ .format('YYYY-MM-DD')
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /There is an active account with similar email somewhere within system/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("... use empty end_date", function(done){
+ it('... use empty end_date', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#end_date_inp',
- value : '',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /There is an active account with similar email somewhere within system/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#end_date_inp',
+ value: ''
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /There is an active account with similar email somewhere within system/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Although setting end_date to some value in past still works', function(done){
+ it('Although setting end_date to some value in past still works', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#end_date_inp',
- value : moment().subtract(3, 'days').format('YYYY-MM-DD'),
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#end_date_inp',
+ value: moment()
+ .subtract(3, 'days')
+ .format('YYYY-MM-DD')
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/department/one_by_one_crud.js b/t/integration/department/one_by_one_crud.js
index 1fa7a3652..45db42fc0 100644
--- a/t/integration/department/one_by_one_crud.js
+++ b/t/integration/department/one_by_one_crud.js
@@ -1,21 +1,18 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- register_new_user_func = require('../../lib/register_new_user'),
- login_user_func = require('../../lib/login_with_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- By = require('selenium-webdriver').By,
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- expect = require('chai').expect,
- Bluebird = require('bluebird'),
- add_new_user_func = require('../../lib/add_new_user'),
- user_info_func = require('../../lib/user_info'),
- new_department_form_id = '#add_new_department_form',
- department_edit_form_id = '#department_edit_form';
+'use strict'
+
+const register_new_user_func = require('../../lib/register_new_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const check_elements_func = require('../../lib/check_elements')
+const By = require('selenium-webdriver').By
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const expect = require('chai').expect
+const Bluebird = require('bluebird')
+const add_new_user_func = require('../../lib/add_new_user')
+const user_info_func = require('../../lib/user_info')
+const new_department_form_id = '#add_new_department_form'
+const department_edit_form_id = '#department_edit_form'
/*
* Scenario:
@@ -33,142 +30,180 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Check departments list page', function(){
- var driver;
+describe('Check departments list page', function() {
+ let driver
- this.timeout( config.get_execution_timeout() );
+ this.timeout(config.get_execution_timeout())
- it("Register new account", function(done){
+ it('Register new account', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open page with department list and ensure it has read-only list", function(done){
+ it('Open page with department list and ensure it has read-only list', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
- })
- .then(function(){
- return driver.findElements(By.css('tr[data-vpp-department-list-mode="readonly"]'));
+ url: application_host + 'settings/departments/',
+ driver
})
- .then(function(inputs){
- expect(inputs.length).to.be.eql(1);
- done();
- });
- });
+ .then(function() {
+ return driver.findElements(
+ By.css('tr[data-vpp-department-list-mode="readonly"]')
+ )
+ })
+ .then(function(inputs) {
+ expect(inputs.length).to.be.eql(1)
+ done()
+ })
+ })
- it("Ensure list of departments has links for editing each individual one", function(done){
+ it('Ensure list of departments has links for editing each individual one', function(done) {
driver
.findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(function(links){
- expect(links.length).to.be.eql(2, "We expect to have two edit links per department");
- done();
+ .then(function(links) {
+ expect(links.length).to.be.eql(
+ 2,
+ 'We expect to have two edit links per department'
+ )
+ done()
})
- });
+ })
- it("Ensure department has a link to its Manager edit page", function(done){
+ it('Ensure department has a link to its Manager edit page', function(done) {
driver
.findElements(By.css('a[href*="/users/edit/"]'))
- .then(function(links){
- expect(links.length).to.be.eql(1, "There exist one link to manager per department");
- return links[0].getAttribute('href');
+ .then(function(links) {
+ expect(links.length).to.be.eql(
+ 1,
+ 'There exist one link to manager per department'
+ )
+ return links[0].getAttribute('href')
})
- .then(function(href){
- expect(href).to.match(/\/users\/edit\/\d+\/$/, "Link to manager indeed contains ID");
- done();
- });
- });
-
- it('Add new "AAA" department', function(done){
- driver.findElement(By.css('#add_new_department_btn'))
- .then(function(el){
- return el.click();
+ .then(function(href) {
+ expect(href).to.match(
+ /\/users\/edit\/\d+\/$/,
+ 'Link to manager indeed contains ID'
+ )
+ done()
})
- .then(function(){
+ })
+ it('Add new "AAA" department', function(done) {
+ driver
+ .findElement(By.css('#add_new_department_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_department_form_id+' input[name="name__new"]',
- value : 'AAA',
- },{
- selector : new_department_form_id+' select[name="allowance__new"]',
- option_selector : 'option[value="15"]',
- value : '15',
- }],
- submit_button_selector : new_department_form_id+' button[type="submit"]',
- message : /Changes to departments were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_department_form_id + ' input[name="name__new"]',
+ value: 'AAA'
+ },
+ {
+ selector:
+ new_department_form_id + ' select[name="allowance__new"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ }
+ ],
+ submit_button_selector:
+ new_department_form_id + ' button[type="submit"]',
+ message: /Changes to departments were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it('Ensure that user is landed on department read only list page', function(done){
- driver
- .getCurrentUrl()
- .then(function(url){
- expect(url).to.match(/\/settings\/departments\/$/, 'Ensure the landing page is department list');
- done();
- });
- });
-
- it('Ensure that newly added department AAA is on top of the list', function(done){
+ it('Ensure that user is landed on department read only list page', function(done) {
+ driver.getCurrentUrl().then(function(url) {
+ expect(url).to.match(
+ /\/settings\/departments\/$/,
+ 'Ensure the landing page is department list'
+ )
+ done()
+ })
+ })
+
+ it('Ensure that newly added department AAA is on top of the list', function(done) {
driver
.findElements(By.css('a[data-vpp-department-name="1"]'))
- .then(function(els){ return Bluebird.map(els, function(el){ return el.getText() }) })
- .then(function(texts){
- expect(texts).to.have.eql(['AAA', 'Sales'], 'Check the order of names');
- done();
- });
- });
-
- it('Add new "ZZZ" department', function(done){
- driver.findElement(By.css('#add_new_department_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
+ .then(function(els) {
+ return Bluebird.map(els, function(el) {
+ return el.getText()
+ })
+ })
+ .then(function(texts) {
+ expect(texts).to.have.eql(['AAA', 'Sales'], 'Check the order of names')
+ done()
+ })
+ })
+ it('Add new "ZZZ" department', function(done) {
+ driver
+ .findElement(By.css('#add_new_department_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_department_form_id+' input[name="name__new"]',
- value : 'ZZZ',
- },{
- selector : new_department_form_id+' select[name="allowance__new"]',
- option_selector : 'option[value="15"]',
- value : '15',
- }],
- submit_button_selector : new_department_form_id+' button[type="submit"]',
- message : /Changes to departments were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_department_form_id + ' input[name="name__new"]',
+ value: 'ZZZ'
+ },
+ {
+ selector:
+ new_department_form_id + ' select[name="allowance__new"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ }
+ ],
+ submit_button_selector:
+ new_department_form_id + ' button[type="submit"]',
+ message: /Changes to departments were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it('Ensure that departments respect alphabetical order', function(done){
+ it('Ensure that departments respect alphabetical order', function(done) {
driver
.findElements(By.css('a[data-vpp-department-name="1"]'))
- .then(function(els){ return Bluebird.map(els, function(el){ return el.getText() }) })
- .then(function(texts){
- expect(texts).to.have.eql(['AAA', 'Sales', 'ZZZ'], 'Check the order of names');
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ .then(function(els) {
+ return Bluebird.map(els, function(el) {
+ return el.getText()
+ })
+ })
+ .then(function(texts) {
+ expect(texts).to.have.eql(
+ ['AAA', 'Sales', 'ZZZ'],
+ 'Check the order of names'
+ )
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
/*
* Scenario:
@@ -186,299 +221,360 @@ describe('Check departments list page', function(){
*
* */
-describe("Edit individual department via department details page", function(){
- var driver, email_A, email_B, user_id_A, user_id_B, department_edit_page_url,
- new_department_id;
+describe('Edit individual department via department details page', function() {
+ let driver,
+ email_A,
+ email_B,
+ user_id_A,
+ user_id_B,
+ department_edit_page_url,
+ new_department_id
- this.timeout( config.get_execution_timeout() );
+ this.timeout(config.get_execution_timeout())
- it("Register new account", function(done){
+ it('Register new account', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ email_A = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- email_A = data.email;
- driver = data.driver;
- done();
- });
- });
+ })
- it("Create second user B", function(done){
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user A", function(done){
+ it('Obtain information about user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Open page with department list and click first department in the list", function(done){
+ it('Open page with department list and click first department in the list', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
- })
- .then(function(){
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
driver
.findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(function(links){ return links[0].click() })
- .then(function(){ done() });
- });
- });
+ .then(function(links) {
+ return links[0].click()
+ })
+ .then(function() {
+ done()
+ })
+ })
+ })
- it('... save edit page URL', function(done){
- driver
- .getCurrentUrl()
- .then(function(url){
- department_edit_page_url = url;
- done();
- });
- });
-
- it('Edit department', function(done){
+ it('... save edit page URL', function(done) {
+ driver.getCurrentUrl().then(function(url) {
+ department_edit_page_url = url
+ done()
+ })
+ })
+
+ it('Edit department', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : department_edit_form_id+' input[name="name"]',
- value : 'Fantastic name',
- },{
- selector : department_edit_form_id+' select[name="allowance"]',
- option_selector : 'option[value="5"]',
- value : '5',
- },{
- selector : department_edit_form_id+' select[name="boss_id"]',
- option_selector : 'option[value="'+user_id_B+'"]',
- value : user_id_B,
- },{
- selector : 'input[name="include_public_holidays"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
- })
- .then(function(){ done() });
- });
-
- it('Ensure that chnages were applied', function(done){
+ driver,
+ form_params: [
+ {
+ selector: department_edit_form_id + ' input[name="name"]',
+ value: 'Fantastic name'
+ },
+ {
+ selector: department_edit_form_id + ' select[name="allowance"]',
+ option_selector: 'option[value="5"]',
+ value: '5'
+ },
+ {
+ selector: department_edit_form_id + ' select[name="manager_id"]',
+ option_selector: 'option[value="' + user_id_B + '"]',
+ value: user_id_B
+ },
+ {
+ selector: 'input[name="include_public_holidays"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that changes were applied', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : department_edit_form_id+' input[name="name"]',
- value : 'Fantastic name',
- },{
- selector : department_edit_form_id+' select[name="allowance"]',
- option_selector : 'option[value="5"]',
- value : '5',
- },{
- selector : department_edit_form_id+' select[name="boss_id"]',
- option_selector : 'option[value="'+user_id_B+'"]',
- value : user_id_B+"",
- },{
- selector : 'input[name="include_public_holidays"]',
- tick : false,
- value : 'off',
- }],
- })
- .then(function(){ done() });
- });
-
- it('Ensure that user stays on the same page after updating department details', function(done){
- driver
- .getCurrentUrl()
- .then(function(url){
- expect(url).to.be.eql(department_edit_page_url);
- done()
- });
- });
+ driver,
+ elements_to_check: [
+ {
+ selector: department_edit_form_id + ' input[name="name"]',
+ value: 'Fantastic name'
+ },
+ {
+ selector: department_edit_form_id + ' select[name="allowance"]',
+ option_selector: 'option[value="5"]',
+ value: '5'
+ },
+ {
+ selector: department_edit_form_id + ' select[name="manager_id"]',
+ option_selector: 'option[value="' + user_id_B + '"]',
+ value: user_id_B + ''
+ },
+ {
+ selector: 'input[name="include_public_holidays"]',
+ tick: false,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
+ })
+ })
- it('Try to remove the department by pressing Delete button on current page', function(done){
+ it('Ensure that user stays on the same page after updating department details', function(done) {
+ driver.getCurrentUrl().then(function(url) {
+ expect(url).to.be.eql(department_edit_page_url)
+ done()
+ })
+ })
+
+ it('Try to remove the department by pressing Delete button on current page', function(done) {
driver
.findElement(By.css('button#remove_btn'))
- .then(function(btn){ return btn.click() })
- .then(function(){ done() });
- });
+ .then(function(btn) {
+ return btn.click()
+ })
+ .then(function() {
+ done()
+ })
+ })
- it('Ensure that system prevents deleting department', function(done){
+ it('Ensure that system prevents deleting department', function(done) {
driver
- .findElement( By.css('div.alert') )
- .then(function(el){ return el.getText() })
- .then(function(txt){
+ .findElement(By.css('div.alert'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(txt) {
expect(txt).to.match(
/Cannot remove department .+ as it still has 2 users/,
'App complains about non empty department'
- );
- done();
- });
- });
+ )
+ done()
+ })
+ })
- it('Go to departments list by clicking on corresponding link', function(done){
+ it('Go to departments list by clicking on corresponding link', function(done) {
driver
.findElement(By.css('a[data-vpp-all-departments-link="1"]'))
- .then(function(link){ return link.click() })
- .then(function(){ done() });
- });
+ .then(function(link) {
+ return link.click()
+ })
+ .then(function() {
+ done()
+ })
+ })
- it('Add new "AAA" department', function(done){
+ it('Add new "AAA" department', function(done) {
driver
.findElement(By.css('#add_new_department_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_department_form_id+' input[name="name__new"]',
- value : 'AAA',
- },{
- selector : new_department_form_id+' select[name="allowance__new"]',
- option_selector : 'option[value="15"]',
- value : '15',
- }],
- submit_button_selector : new_department_form_id+' button[type="submit"]',
- message : /Changes to departments were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_department_form_id + ' input[name="name__new"]',
+ value: 'AAA'
+ },
+ {
+ selector:
+ new_department_form_id + ' select[name="allowance__new"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ }
+ ],
+ submit_button_selector:
+ new_department_form_id + ' button[type="submit"]',
+ message: /Changes to departments were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it('Fetch newly added department ID', function(done){
+ it('Fetch newly added department ID', function(done) {
driver
.findElements(By.css('a[data-vpp-department-name="1"]'))
// We know that newly added attribute is in the top of the list as it starts with "A"
- .then(function(links){ return links[0].getAttribute('href')})
- .then(function(href){
- new_department_id = href.match(/settings\/departments\/edit\/(\d+)\//)[1];
- expect(new_department_id).to.match(/^\d+$/, 'The department ID is number');
- done();
- });
- });
-
- it("Open user A details page", function(done){
+ .then(function(links) {
+ return links[0].getAttribute('href')
+ })
+ .then(function(href) {
+ new_department_id = href.match(
+ /settings\/departments\/edit\/(\d+)\//
+ )[1]
+ expect(new_department_id).to.match(
+ /^\d+$/,
+ 'The department ID is number'
+ )
+ done()
+ })
+ })
+
+ it('Open user A details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_A+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_A + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('... and move her to newly added department', function(done){
+ it('... and move her to newly added department', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="department"]',
- option_selector : 'option[value="'+new_department_id+'"]',
- value : new_department_id,
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
- })
- .then(function(){ done() });
- });
-
- it('Ensure that chnages were applied', function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="department"]',
+ option_selector: 'option[value="' + new_department_id + '"]',
+ value: new_department_id
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that changes were applied', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'select[name="department"]',
- value : new_department_id,
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'select[name="department"]',
+ value: new_department_id
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open user B details page", function(done){
+ it('Open user B details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_B + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('... and move her to newly added department', function(done){
+ it('... and move her to newly added department', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="department"]',
- option_selector : 'option[value="'+new_department_id+'"]',
- value : new_department_id,
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
- })
- .then(function(){ done() });
- });
-
- it('Ensure that chnages were applied', function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="department"]',
+ option_selector: 'option[value="' + new_department_id + '"]',
+ value: new_department_id
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that changes were applied', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'select[name="department"]',
- value : new_department_id,
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'select[name="department"]',
+ value: new_department_id
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Go to the very first department details page', function(done){
+ it('Go to the very first department details page', function(done) {
open_page_func({
- url : department_edit_page_url,
- driver : driver,
+ url: department_edit_page_url,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Remove the department by pressing Delete button', function(done){
+ it('Remove the department by pressing Delete button', function(done) {
driver
.findElement(By.css('button#remove_btn'))
- .then(function(btn){ return btn.click() })
- .then(function() { return driver.findElement( By.css('div.alert') ) })
- .then(function(el){ return el.getText() })
- .then(function(txt){
- expect(txt).to.match(/Department was successfully removed/);
- done();
+ .then(function(btn) {
+ return btn.click()
+ })
+ .then(function() {
+ return driver.findElement(By.css('div.alert'))
+ })
+ .then(function(el) {
+ return el.getText()
})
- });
+ .then(function(txt) {
+ expect(txt).to.match(/Department was successfully removed/)
+ done()
+ })
+ })
- it('Ensure that we have landed on correct page', function(done){
- driver
- .getCurrentUrl()
- .then(function(url){
- expect(url).to.match(/\/settings\/departments\/$/, 'The URL points to departments page');
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ it('Ensure that we have landed on correct page', function(done) {
+ driver.getCurrentUrl().then(function(url) {
+ expect(url).to.match(
+ /\/settings\/departments\/$/,
+ 'The URL points to departments page'
+ )
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
/*
* Scenario (edditing secondary supervisers)
@@ -501,260 +597,308 @@ describe("Edit individual department via department details page", function(){
*
* */
-describe('CRUD for department secondary supervisers', function(){
+describe('CRUD for department secondary supervisers', function() {
+ let driver,
+ email_A,
+ email_B,
+ email_C,
+ user_id_A,
+ user_id_B,
+ user_id_C,
+ department_edit_page_url
- var driver, email_A, email_B, email_C, user_id_A, user_id_B, user_id_C,
- department_edit_page_url;
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
-
- it("Register new account", function(done){
+ it('Register new account', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ email_A = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- email_A = data.email;
- driver = data.driver;
- done();
- });
- });
+ })
- it("Obtain information about user A", function(done){
+ it('Obtain information about user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it('Go to departments details page', function(done){
+ it('Go to departments details page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
- })
- .then(function(){
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
driver
.findElements(By.css('a[href*="/settings/departments/edit/"]'))
// Click on the very first link as we have just one department
- .then(function(links){ return links[0].click() })
- .then(function(){ done() });
- });
- });
+ .then(function(links) {
+ return links[0].click()
+ })
+ .then(function() {
+ done()
+ })
+ })
+ })
- it('... save edit page URL', function(done){
- driver
- .getCurrentUrl()
- .then(function(url){
- department_edit_page_url = url;
- done();
- });
- });
-
- it('Invoke "Add secondary supervisers" pop-up window', function(done){
+ it('... save edit page URL', function(done) {
+ driver.getCurrentUrl().then(function(url) {
+ department_edit_page_url = url
+ done()
+ })
+ })
+
+ it('Invoke "Add secondary supervisers" pop-up window', function(done) {
driver
.findElement(By.css('a[data-vpp-add-new-secondary-supervisor="1"]'))
- .then(function(btn){ return btn.click() })
- .then(function(){
- driver.sleep(1000);
- return driver.findElement(By.css('a[data-vpp-add-supervisor-modal-add-new-user="1"]'))
- })
- .then(function(link){ return link.getText() })
- .then(function(text){
- expect(text).to.match(/Add new employee/);
- done();
- });
- });
-
- it("Create second user B", function(done){
+ .then(function(btn) {
+ return btn.click()
+ })
+ .then(function() {
+ driver.sleep(1000)
+ return driver.findElement(
+ By.css('a[data-vpp-add-supervisor-modal-add-new-user="1"]')
+ )
+ })
+ .then(function(link) {
+ return link.getText()
+ })
+ .then(function(text) {
+ expect(text).to.match(/Add new employee/)
+ done()
+ })
+ })
+
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
-
+ })
- it("Create second user C", function(done){
+ it('Create second user C', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_C = data.new_user_email
+ done()
})
- .then(function(data){
- email_C = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user C", function(done){
+ it('Obtain information about user C', function(done) {
user_info_func({
- driver : driver,
- email : email_C,
+ driver,
+ email: email_C
+ }).then(function(data) {
+ user_id_C = data.user.id
+ done()
})
- .then(function(data){
- user_id_C = data.user.id;
- done();
- });
- });
-
+ })
- it('Go to any department details page', function(done){
+ it('Go to any department details page', function(done) {
open_page_func({
- url : department_edit_page_url,
- driver : driver,
+ url: department_edit_page_url,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('... and ensure that user A is its manager', function(done){
+ it('... and ensure that user A is its manager', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'select#manager_id',
- value : String(user_id_A),
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'select#manager_id',
+ value: String(user_id_A)
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that "secondary supervisors" section is empty', function(done){
+ it('Ensure that "secondary supervisors" section is empty', function(done) {
driver
.findElements(By.css('button[name="remove_supervisor_id"]'))
- .then(function(els){
- expect(els.length).to.be.eql(0, 'No remove buttons for supervisers as there are not any');
- done();
- });
- });
+ .then(function(els) {
+ expect(els.length).to.be.eql(
+ 0,
+ 'No remove buttons for supervisers as there are not any'
+ )
+ done()
+ })
+ })
- it('click "add supervisers" button and ensure that popup witndow '+
- 'has only user B and C in the list',
- function(done){
+ it(
+ 'click "add supervisers" button and ensure that popup witndow ' +
+ 'has only user B and C in the list',
+ function(done) {
+ driver
+ .findElement(By.css('a[data-vpp-add-new-secondary-supervisor="1"]'))
+ .then(function(btn) {
+ return btn.click()
+ })
+ .then(function() {
+ driver.sleep(1000)
+ return driver.findElements(By.css('input[name="supervisor_id"]'))
+ })
+ .then(function(els) {
+ return Bluebird.map(els, function(el) {
+ return el.getAttribute('value')
+ })
+ })
+ .then(function(vals) {
+ expect(vals.sort()).to.be.eql(
+ [user_id_B, user_id_C]
+ .map(function(e) {
+ return String(e)
+ })
+ .sort(),
+ 'User list is expected'
+ )
+ done()
+ })
+ }
+ )
- driver
- .findElement(By.css('a[data-vpp-add-new-secondary-supervisor="1"]'))
- .then(function(btn){ return btn.click() })
- .then(function(){
- driver.sleep(1000);
- return driver.findElements(By.css('input[name="supervisor_id"]'))
- })
- .then(function(els){ return Bluebird.map(els, function(el){return el.getAttribute('value')})})
- .then(function(vals){
- expect(vals.sort()).to.be.eql([user_id_B, user_id_C].map(function(e){return String(e)}).sort(), 'User list is expected');
- done();
- });
- });
-
- it('tick user B and save changes', function(done){
+ it('tick user B and save changes', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="supervisor_id"][value="'+user_id_B+'"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : 'button[name="do_add_supervisors"]',
- message : /Supervisors were added to department/,
- })
- .then(function(){ done() });
- });
-
- it('Observe that user B appeares on the list of secondary supervisers', function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="supervisor_id"][value="' + user_id_B + '"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: 'button[name="do_add_supervisors"]',
+ message: /Supervisors were added to department/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Observe that user B appeares on the list of secondary supervisers', function(done) {
driver
.findElements(By.css('button[name="remove_supervisor_id"]'))
- .then(function(els){
- expect(els.length).to.be.eql(1, 'No remove buttons for supervisers as there are not any');
- return els[0].getAttribute('value');
+ .then(function(els) {
+ expect(els.length).to.be.eql(
+ 1,
+ 'No remove buttons for supervisers as there are not any'
+ )
+ return els[0].getAttribute('value')
+ })
+ .then(function(val) {
+ expect(val).to.be.eql(String(user_id_B), 'It is indeed user B')
+ done()
})
- .then(function(val){
- expect(val).to.be.eql(String(user_id_B), 'It is indeed user B');
- done();
- });
- });
+ })
- it('Open "add supervisors" pop up again and ensure that user B has tick next to it and user C does not have it', function(done){
+ it('Open "add supervisors" pop up again and ensure that user B has tick next to it and user C does not have it', function(done) {
driver
.findElement(By.css('a[data-vpp-add-new-secondary-supervisor="1"]'))
- .then( btn => btn.click() )
- .then( () => driver.sleep(1000) )
- .then( () => check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : `input[name="supervisor_id"][value="${ user_id_B }"]`,
- tick : true,
- value : 'on',
- }],
+ .then(btn => btn.click())
+ .then(() => driver.sleep(1000))
+ .then(() =>
+ check_elements_func({
+ driver,
+ elements_to_check: [
+ {
+ selector: `input[name="supervisor_id"][value="${user_id_B}"]`,
+ tick: true,
+ value: 'on'
+ }
+ ]
})
)
- .then( () => check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : `input[name="supervisor_id"][value="${ user_id_C }"]`,
- tick : true,
- value : 'off',
- }],
+ .then(() =>
+ check_elements_func({
+ driver,
+ elements_to_check: [
+ {
+ selector: `input[name="supervisor_id"][value="${user_id_C}"]`,
+ tick: true,
+ value: 'off'
+ }
+ ]
})
)
- .then(() => done());
- });
+ .then(() => done())
+ })
- it('Tick user C and un-tick user B and save changes', function(done){
+ it('Tick user C and un-tick user B and save changes', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="supervisor_id"][value="'+user_id_B+'"]',
- tick : true,
- },{
- selector : 'input[name="supervisor_id"][value="'+user_id_C+'"]',
- tick : true,
- }],
- submit_button_selector : 'button[name="do_add_supervisors"]',
- message : /Supervisors were added to department/,
- })
- .then(() => done());
- });
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="supervisor_id"][value="' + user_id_B + '"]',
+ tick: true
+ },
+ {
+ selector: 'input[name="supervisor_id"][value="' + user_id_C + '"]',
+ tick: true
+ }
+ ],
+ submit_button_selector: 'button[name="do_add_supervisors"]',
+ message: /Supervisors were added to department/
+ }).then(() => done())
+ })
it('Observe that "secondary spervisors" section now contains only user C', function(done) {
driver
.findElements(By.css('button[name="remove_supervisor_id"]'))
.then(els => {
- expect(els.length).to.be.eql(1, 'No remove buttons for supervisers as there are not any');
- return els[0].getAttribute('value');
+ expect(els.length).to.be.eql(
+ 1,
+ 'No remove buttons for supervisers as there are not any'
+ )
+ return els[0].getAttribute('value')
})
.then(val => {
- expect(val).to.be.eql(String(user_id_C), 'It is indeed user C');
- done();
- });
- });
+ expect(val).to.be.eql(String(user_id_C), 'It is indeed user C')
+ done()
+ })
+ })
- it('Click on "Remove" button next to user C and observe that it disappears from "secondary supervisors" section after page is reloaded', function(done){
+ it('Click on "Remove" button next to user C and observe that it disappears from "secondary supervisors" section after page is reloaded', function(done) {
driver
- .findElement(By.css(`button[name="remove_supervisor_id"][value="${ user_id_C }"]`))
+ .findElement(
+ By.css(`button[name="remove_supervisor_id"][value="${user_id_C}"]`)
+ )
.then(el => el.click())
- .then(() => driver.findElements(By.css('button[name="remove_supervisor_id"]')))
+ .then(() =>
+ driver.findElements(By.css('button[name="remove_supervisor_id"]'))
+ )
.then(els => {
- expect(els.length, 'There is no users in secondary supervisers section').to.be.eql(0);
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(() => done());
- });
+ expect(
+ els.length,
+ 'There is no users in secondary supervisers section'
+ ).to.be.eql(0)
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/edit_user_to_have_duplicated_email.js b/t/integration/edit_user_to_have_duplicated_email.js
index b709dc7be..5c9d4e7d1 100644
--- a/t/integration/edit_user_to_have_duplicated_email.js
+++ b/t/integration/edit_user_to_have_duplicated_email.js
@@ -1,18 +1,17 @@
+'use strict'
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- add_new_user_func = require('../lib/add_new_user'),
- config = require('../lib/config'),
- application_host = config.get_application_host();
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const register_new_user_func = require('../lib/register_new_user');
+ const login_user_func = require('../lib/login_with_user');
+ const open_page_func = require('../lib/open_page');
+ const submit_form_func = require('../lib/submit_form');
+ const add_new_user_func = require('../lib/add_new_user');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host()
/*
* Scenario to check:
@@ -24,80 +23,92 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Edit user to have duplicated email', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Edit user to have duplicated email', function() {
+ this.timeout(config.get_execution_timeout())
- var email_admin, driver;
+ let email_admin, driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_admin = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_admin = data.email;
- done();
- });
- });
+ })
- it("Create second user", function(done){
+ it('Create second user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open 'users' page", function(done){
+ it("Open 'users' page", function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure that both users are shown " +
- "and click on latest user (assuming users are sorted alphabetichally and " +
- "test user names are derived from epoch)", function(done){
- driver
- .findElements(By.css( 'td.user-link-cell a' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(2);
- // click on second user link
- return elements[1].click()
- })
- .then(function(){ done() });
- });
+ it(
+ 'Make sure that both users are shown ' +
+ 'and click on latest user (assuming users are sorted alphabetichally and ' +
+ 'test user names are derived from epoch)',
+ function(done) {
+ driver
+ .findElements(By.css('td.user-link-cell a'))
+ .then(function(elements) {
+ expect(elements.length).to.be.equal(2)
+ // click on second user link
+ return elements[1].click()
+ })
+ .then(function() {
+ done()
+ })
+ }
+ )
- it("Try to assign to second user the same email as ADMIN has", function(done){
+ it('Try to assign to second user the same email as ADMIN has', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="email_address"]',
- value : email_admin,
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Email is already in use/,
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="email_address"]',
+ value: email_admin
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Email is already in use/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Update email user with unique email address", function(done){
+ it('Update email user with unique email address', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="email_address"]',
- value : 'foobar'+email_admin,
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .* were updated/,
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="email_address"]',
+ value: 'foobar' + email_admin
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/employee_details_section/admin_view_of_user_calendar.js b/t/integration/employee_details_section/admin_view_of_user_calendar.js
index 2ed197888..5dfad27cb 100644
--- a/t/integration/employee_details_section/admin_view_of_user_calendar.js
+++ b/t/integration/employee_details_section/admin_view_of_user_calendar.js
@@ -1,19 +1,24 @@
-
-'use strict';
-
-const By = require('selenium-webdriver').By,
- moment = require('moment'),
- addNewUserFunc = require('../../lib/add_new_user'),
- config = require('../../lib/config'),
- loginUserFunc = require('../../lib/login_with_user'),
- logoutUserFunc = require('../../lib/logout_user'),
- openPageFunc = require('../../lib/open_page'),
- registerNewUserFunc = require('../../lib/register_new_user'),
- submitFormFunc = require('../../lib/submit_form'),
- userInfoFunc = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- checkBookingFunc = require('../../lib/check_booking_on_calendar'),
- someWeekdayDate = moment().utc().startOf('year').add(1, 'week').startOf('isoWeek').add(2, 'day').format('YYYY-MM-DD');
+'use strict'
+
+const By = require('selenium-webdriver').By;
+ const moment = require('moment');
+ const addNewUserFunc = require('../../lib/add_new_user');
+ const config = require('../../lib/config');
+ const loginUserFunc = require('../../lib/login_with_user');
+ const logoutUserFunc = require('../../lib/logout_user');
+ const openPageFunc = require('../../lib/open_page');
+ const registerNewUserFunc = require('../../lib/register_new_user');
+ const submitFormFunc = require('../../lib/submit_form');
+ const userInfoFunc = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const checkBookingFunc = require('../../lib/check_booking_on_calendar');
+ const someWeekdayDate = moment()
+ .utc()
+ .startOf('year')
+ .add(1, 'week')
+ .startOf('isoWeek')
+ .add(2, 'day')
+ .format('YYYY-MM-DD')
/*
* Aim:
@@ -26,77 +31,85 @@ const By = require('selenium-webdriver').By,
* * Login as admin user A
* * Go to user B details, ensure new request is shown on the Calendar section
* */
-describe('Ensure employee calendar from admin section shows bookings', function(){
-
- this.timeout( config.get_execution_timeout() );
-
- let driver, emailA, emailB, userIdB;
-
- it("Register new company", async () => {
- ({driver: driver, email: emailA} = await registerNewUserFunc({ application_host }));
- });
-
- it("Create second user B", async () => {
- ({new_user_email: emailB} = await addNewUserFunc({ application_host, driver }));
- });
-
- it("Obtain information about user B", async () => {
- ({user: {id: userIdB}} = await userInfoFunc({ driver, email: emailB }));
- });
-
- it("Logout from user A (admin)", async () => {
- await logoutUserFunc({ application_host, driver });
- });
-
- it("Login as user B", async () => {
- await loginUserFunc({ application_host, driver, user_email: emailB });
- });
-
- it("Open Book leave popup window", async () => {
- const el = await driver.findElement(By.css('#book_time_off_btn'));
- await el.click();
+describe('Ensure employee calendar from admin section shows bookings', function() {
+ this.timeout(config.get_execution_timeout())
+
+ let driver, emailA, emailB, userIdB
+
+ it('Register new company', async function() {
+ ;({ driver, email: emailA } = await registerNewUserFunc({
+ application_host
+ }))
+ })
+
+ it('Create second user B', async function() {
+ ;({ new_user_email: emailB } = await addNewUserFunc({
+ application_host,
+ driver
+ }))
+ })
+
+ it('Obtain information about user B', async function() {
+ ;({
+ user: { id: userIdB }
+ } = await userInfoFunc({ driver, email: emailB }))
+ })
+
+ it('Logout from user A (admin)', async function() {
+ await logoutUserFunc({ application_host, driver })
+ })
+
+ it('Login as user B', async function() {
+ await loginUserFunc({ application_host, driver, user_email: emailB })
+ })
+
+ it('Open Book leave popup window', async function() {
+ const el = await driver.findElement(By.css('#book_time_off_btn'))
+ await el.click()
// This is very important line when working with Bootstrap modals!
- await driver.sleep(1000);
- });
+ await driver.sleep(1000)
+ })
- it("Submit new leave request from user B", async () => {
+ it('Submit new leave request from user B', async function() {
await submitFormFunc({
driver,
- form_params : [{
- selector : 'input#from',
- value : someWeekdayDate,
- },{
- selector : 'input#to',
- value : someWeekdayDate,
- }],
- message : /New leave request was added/,
- });
- });
-
- it("Logout from user B", async () => {
- await logoutUserFunc({ application_host, driver });
- });
-
- it("Login as admin user A", async () => {
- await loginUserFunc({ driver, application_host, user_email: emailA });
- });
-
- it('Open user B calendar section and ensure the newly added booking is there', async () => {
+ form_params: [
+ {
+ selector: 'input#from',
+ value: someWeekdayDate
+ },
+ {
+ selector: 'input#to',
+ value: someWeekdayDate
+ }
+ ],
+ message: /New leave request was added/
+ })
+ })
+
+ it('Logout from user B', async function() {
+ await logoutUserFunc({ application_host, driver })
+ })
+
+ it('Login as admin user A', async function() {
+ await loginUserFunc({ driver, application_host, user_email: emailA })
+ })
+
+ it('Open user B calendar section and ensure the newly added booking is there', async function() {
await openPageFunc({
driver,
- url: `${application_host}users/edit/${userIdB}/calendar/`,
- });
+ url: `${application_host}users/edit/${userIdB}/calendar/`
+ })
await checkBookingFunc({
driver,
full_days: [moment(someWeekdayDate)],
- type: 'pended',
+ type: 'pended'
})
- });
-
- after(async () => {
- await driver.quit();
- });
+ })
-});
+ after(async function() {
+ await driver.quit()
+ })
+})
diff --git a/t/integration/employees_page/filter_users_by_departments.js b/t/integration/employees_page/filter_users_by_departments.js
index 29e8683f0..578933863 100644
--- a/t/integration/employees_page/filter_users_by_departments.js
+++ b/t/integration/employees_page/filter_users_by_departments.js
@@ -1,22 +1,20 @@
-
-'use strict';
-
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird"),
- until = require('selenium-webdriver').until,
- register_new_user_func = require('../../lib/register_new_user'),
- login_user_func = require('../../lib/login_with_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- add_new_user_func = require('../../lib/add_new_user'),
- By = require('selenium-webdriver').By,
- new_department_form_id = '#add_new_department_form',
- config = require('../../lib/config'),
- application_host = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ var By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const Promise = require('bluebird');
+ const until = require('selenium-webdriver').until;
+ const register_new_user_func = require('../../lib/register_new_user');
+ const login_user_func = require('../../lib/login_with_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const add_new_user_func = require('../../lib/add_new_user');
+ var By = require('selenium-webdriver').By;
+ const new_department_form_id = '#add_new_department_form';
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host()
/*
* Scenario to check that filtering by department feature on users page.
@@ -31,155 +29,166 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Check filtering on "users" page', function(){
- var driver;
+describe('Check filtering on "users" page', function() {
+ let driver
- this.timeout( config.get_execution_timeout() );
+ this.timeout(config.get_execution_timeout())
- it("Performing registration process", function(done){
+ it('Performing registration process', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it('Create new department "IT": open page', function(done){
+ it('Create new department "IT": open page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("... and submit the form", function(done){
- driver.findElement(By.css('#add_new_department_btn'))
- .then(function(el){
- return el.click();
+ it('... and submit the form', function(done) {
+ driver
+ .findElement(By.css('#add_new_department_btn'))
+ .then(function(el) {
+ return el.click()
})
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_department_form_id+' input[name="name__new"]',
- value : 'IT',
- },{
- selector : new_department_form_id+' select[name="allowance__new"]',
- option_selector : 'option[value="10"]',
- value : '10',
- }],
- submit_button_selector : new_department_form_id+' button[type="submit"]',
- message : /Changes to departments were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_department_form_id + ' input[name="name__new"]',
+ value: 'IT'
+ },
+ {
+ selector:
+ new_department_form_id + ' select[name="allowance__new"]',
+ option_selector: 'option[value="10"]',
+ value: '10'
+ }
+ ],
+ submit_button_selector:
+ new_department_form_id + ' button[type="submit"]',
+ message: /Changes to departments were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Create new non-admin user", function(done){
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver,
// We know that departments are ordered alphabetically, so newly
// added "ID" is before default "Sales" one
- department_index : "0",
+ department_index: '0'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open 'users' page", function(done){
+ it("Open 'users' page", function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure that both users are shown", function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(2);
- done();
- });
- });
-
- it("Click on IT department", function(done){
+ it('Make sure that both users are shown', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(2)
+ done()
+ })
+ })
+
+ it('Click on IT department', function(done) {
driver
// Departments are ordered by names so we are sure that first item
// after general link "All" is going to be "IT"
- .findElement( By.css('div.all-departments a:nth-child(2)') )
- .then(function(element){
- element.click();
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ .findElement(By.css('div.all-departments a:nth-child(2)'))
+ .then(function(element) {
+ element.click()
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("... and make sure only user from IT department is shown", function(done){
+ it('... and make sure only user from IT department is shown', function(done) {
driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(1);
- return elements[0].getText();
+ .findElements(By.css('td.user_department'))
+ .then(function(elements) {
+ expect(elements.length).to.be.equal(1)
+ return elements[0].getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.equal('IT')
+ done()
})
- .then(function(text){
- expect(text).to.be.equal('IT');
- done();
- });
- });
-
- it('Click on "Sales"', function(done){
- driver
- // Departments are ordered by names so we are sure that second item
- // after general link "All" is going to be "Sales"
- .findElement( By.css('div.all-departments a:nth-child(3)') )
- .then(function(element){
- element.click();
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
- })
- .then(function(){ done() });
- });
-
- it("... department and make sure that only one user from that department is shown", function(done){
+ })
+
+ it('Click on "Sales"', function(done) {
driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(1);
- return elements[0].getText();
+ // Departments are ordered by names so we are sure that second item
+ // after general link "All" is going to be "Sales"
+ .findElement(By.css('div.all-departments a:nth-child(3)'))
+ .then(function(element) {
+ element.click()
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(text){
- expect(text).to.be.equal('Sales');
- done();
- });
- });
+ })
- it('Click on "All" filter', function(done){
+ it('... department and make sure that only one user from that department is shown', function(done) {
driver
- .findElement( By.css('div.all-departments a:nth-child(1)') )
- .then(function(element){
- element.click();
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ .findElements(By.css('td.user_department'))
+ .then(function(elements) {
+ expect(elements.length).to.be.equal(1)
+ return elements[0].getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.equal('Sales')
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("... and make sure that both users are presenyed", function(done){
+ it('Click on "All" filter', function(done) {
driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(2);
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ .findElement(By.css('div.all-departments a:nth-child(1)'))
+ .then(function(element) {
+ element.click()
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ done()
+ })
+ })
+
+ it('... and make sure that both users are presenyed', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(2)
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/employees_page/remaining_used_columns_match_user_details.js b/t/integration/employees_page/remaining_used_columns_match_user_details.js
index 0ba004998..4cec6779d 100644
--- a/t/integration/employees_page/remaining_used_columns_match_user_details.js
+++ b/t/integration/employees_page/remaining_used_columns_match_user_details.js
@@ -1,24 +1,22 @@
+'use strict'
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- until = require('selenium-webdriver').until,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- moment = require('moment'),
- add_new_user_func = require('../../lib/add_new_user'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- register_new_user_func = require('../../lib/register_new_user'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const until = require('selenium-webdriver').until;
+ const Promise = require('bluebird');
+ const expect = require('chai').expect;
+ const moment = require('moment');
+ const add_new_user_func = require('../../lib/add_new_user');
+ const check_elements_func = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const login_user_func = require('../../lib/login_with_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario (based in bug #166):
@@ -34,207 +32,242 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Leave request cancelation', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Leave request cancelation', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, email_A, user_id_A;
+ let driver, email_A, user_id_A
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
-
- it("Obtain information about admin user A", function(done){
+ })
+
+ it('Obtain information about admin user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Update admin details to have start date at very beginig of this year", done =>{
+ it('Update admin details to have start date at very beginig of this year', function(done) {
userStartsAtTheBeginingOfYear({
driver,
- email: email_A,
- })
- .then(() => done())
- });
+ email: email_A
+ }).then(() => done())
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Submit new leave request for user A one weekday", function(done){
- const currentYear = moment.utc().year();
+ it('Submit new leave request for user A one weekday', function(done) {
+ const currentYear = moment.utc().year()
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : `${currentYear}-05-01`,
- },{
- selector : 'input#to',
- value : `${currentYear}-05-07`,
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: `${currentYear}-05-01`
+ },
+ {
+ selector: 'input#to',
+ value: `${currentYear}-05-07`
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("Approve new leave request", function(done){
- driver.findElement(By.css(
- 'tr[vpp="pending_for__'+email_A+'"] .btn-success'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
- // Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
- })
- .then(function(){done()});
- });
+ })
+
+ it('Approve new leave request', function(done) {
+ driver
+ .findElement(
+ By.css('tr[vpp="pending_for__' + email_A + '"] .btn-success')
+ )
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
+ // Wait until page properly is reloaded
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ done()
+ })
+ })
- it('Open user A details page (abcenses section)', function(done){
+ it('Open user A details page (abcenses section)', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_A+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_A + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Check that allowance section of user details page shows "15 out of 20"', function(done){
+ it('Check that allowance section of user details page shows "15 out of 20"', function(done) {
driver
- .findElement( By.css('#days_remaining_inp') )
- .then(function(inp){
- return inp.getAttribute('value');
+ .findElement(By.css('#days_remaining_inp'))
+ .then(function(inp) {
+ return inp.getAttribute('value')
})
- .then(function(text){
- expect( text ).to.be.eq('15 out of 20');
- done();
+ .then(function(text) {
+ expect(text).to.be.eq('15 out of 20')
+ done()
})
- });
+ })
- it('Open employees list page', function(done){
+ it('Open employees list page', function(done) {
open_page_func({
- url : application_host + 'users',
- driver : driver,
+ url: application_host + 'users',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure "remaining" 15', function(done){
+ it('Ensure "remaining" 15', function(done) {
driver
- .findElement( By.css('tr[data-vpp-user-row="'+user_id_A+'"] .vpp-days-remaining') )
- .then(function(el){ return el.getText() })
- .then(function(text){
- expect( text ).to.be.eq('15');
- done();
+ .findElement(
+ By.css('tr[data-vpp-user-row="' + user_id_A + '"] .vpp-days-remaining')
+ )
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.eq('15')
+ done()
})
- });
+ })
- it('Ensure "used" shows 5', function(done){
+ it('Ensure "used" shows 5', function(done) {
driver
- .findElement( By.css('tr[data-vpp-user-row="'+user_id_A+'"] .vpp-days-used') )
- .then(function(el){ return el.getText() })
- .then(function(text){
- expect( text ).to.be.eq('5');
- done();
+ .findElement(
+ By.css('tr[data-vpp-user-row="' + user_id_A + '"] .vpp-days-used')
+ )
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.eq('5')
+ done()
})
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Initiate revoke procedure (but not finish)', function(done){
+ it('Initiate revoke procedure (but not finish)', function(done) {
driver
- .findElement(By.css(
- 'button.revoke-btn'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(By.css('button.revoke-btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open user A details page (abcenses section)', function(done){
+ it('Open user A details page (abcenses section)', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_A+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_A + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Check that allowance section of user details page shows "15 out of 20"', function(done){
+ it('Check that allowance section of user details page shows "15 out of 20"', function(done) {
driver
- .findElement( By.css('#days_remaining_inp') )
- .then(function(inp){
- return inp.getAttribute('value');
+ .findElement(By.css('#days_remaining_inp'))
+ .then(function(inp) {
+ return inp.getAttribute('value')
})
- .then(function(text){
- expect( text ).to.be.eq('15 out of 20');
- done();
+ .then(function(text) {
+ expect(text).to.be.eq('15 out of 20')
+ done()
})
- });
+ })
- it('Open employees list page', function(done){
+ it('Open employees list page', function(done) {
open_page_func({
- url : application_host + 'users',
- driver : driver,
+ url: application_host + 'users',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure "remaining" 15', function(done){
+ it('Ensure "remaining" 15', function(done) {
driver
- .findElement( By.css('tr[data-vpp-user-row="'+user_id_A+'"] .vpp-days-remaining') )
- .then(function(el){ return el.getText() })
- .then(function(text){
- expect( text ).to.be.eq('15');
- done();
+ .findElement(
+ By.css('tr[data-vpp-user-row="' + user_id_A + '"] .vpp-days-remaining')
+ )
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.eq('15')
+ done()
})
- });
+ })
- it('Ensure "used" shows 5', function(done){
+ it('Ensure "used" shows 5', function(done) {
driver
- .findElement( By.css('tr[data-vpp-user-row="'+user_id_A+'"] .vpp-days-used') )
- .then(function(el){ return el.getText() })
- .then(function(text){
- expect( text ).to.be.eq('5');
- done();
+ .findElement(
+ By.css('tr[data-vpp-user-row="' + user_id_A + '"] .vpp-days-used')
+ )
+ .then(function(el) {
+ return el.getText()
})
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ .then(function(text) {
+ expect(text).to.be.eq('5')
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/inactivate_user.js b/t/integration/inactivate_user.js
index e33177423..a2309027d 100644
--- a/t/integration/inactivate_user.js
+++ b/t/integration/inactivate_user.js
@@ -1,25 +1,24 @@
+'use strict'
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- moment = require('moment'),
- bluebird = require("bluebird"),
- until = require('selenium-webdriver').until,
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- add_new_user_func = require('../lib/add_new_user'),
- logout_user_func = require('../lib/logout_user'),
- check_elements_func = require('../lib/check_elements'),
- teamview_check_func = require('../lib/teamview_check_user'),
- user_info_func = require('../lib/user_info'),
- config = require('../lib/config'),
- application_host = config.get_application_host(),
- department_edit_form_id = '#department_edit_form';
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const moment = require('moment')
+const bluebird = require('bluebird')
+const until = require('selenium-webdriver').until
+const register_new_user_func = require('../lib/register_new_user')
+const login_user_func = require('../lib/login_with_user')
+const open_page_func = require('../lib/open_page')
+const submit_form_func = require('../lib/submit_form')
+const add_new_user_func = require('../lib/add_new_user')
+const logout_user_func = require('../lib/logout_user')
+const check_elements_func = require('../lib/check_elements')
+const teamview_check_func = require('../lib/teamview_check_user')
+const user_info_func = require('../lib/user_info')
+const config = require('../lib/config')
+const application_host = config.get_application_host()
+const department_edit_form_id = '#department_edit_form'
/*
* Scenario to check:
@@ -40,255 +39,285 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Dealing with inactive users', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Dealing with inactive users', function() {
+ this.timeout(config.get_execution_timeout())
- var email_admin , admin_user_id,
- email_manager, manager_user_id,
- email_employee, employee_user_id,
- employee_id, driver;
+ let email_admin,
+ admin_user_id,
+ email_manager,
+ manager_user_id,
+ email_employee,
+ employee_user_id,
+ employee_id,
+ driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_admin = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_admin = data.email;
- done();
- });
- });
+ })
- it("Create MANAGER", function(done){
+ it('Create MANAGER', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_manager = data.new_user_email
+ done()
})
- .then(function(data){
- email_manager = data.new_user_email;
- done();
- });
- });
+ })
- it("Create EMPLOYEE", function(done){
+ it('Create EMPLOYEE', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_employee = data.new_user_email
+ done()
})
- .then(function(data){
- email_employee = data.new_user_email;
- done();
- });
- });
+ })
- it("Open department management page", function(done){
+ it('Open department management page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Update department to be supervised by MANAGER', function(done){
+ it('Update department to be supervised by MANAGER', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
})
- .then(() => driver
- .findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(links => links[0].click())
- )
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="name"]',
- // Just to make sure it is always first in the lists
- value : 'AAAAA',
- },{
- selector : 'select[name="allowance"]',
- option_selector : 'option[value="15"]',
- value : '15',
- },{
- selector : 'select[name="boss_id"]',
- option_selector : 'select[name="boss_id"] option:nth-child(2)',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
- }))
- .then(() => done());
- });
+ .then(() =>
+ driver
+ .findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ .then(links => links[0].click())
+ )
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="name"]',
+ // Just to make sure it is always first in the lists
+ value: 'AAAAA'
+ },
+ {
+ selector: 'select[name="allowance"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ },
+ {
+ selector: 'select[name="manager_id"]',
+ option_selector: 'select[name="manager_id"] option:nth-child(2)'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ })
+ )
+ .then(() => done())
+ })
- it("Make sure EMPLOYEE shows up on the Team view page", function(done){
+ it('Make sure EMPLOYEE shows up on the Team view page', function(done) {
teamview_check_func({
- driver : driver,
- emails : [email_admin, email_manager, email_employee],
- is_link : true,
+ driver,
+ emails: [email_admin, email_manager, email_employee],
+ is_link: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open departments management page", function(done){
+ it('Open departments management page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("obtain detailed info about employee (ID etc)", function(done){
+ it('obtain detailed info about employee (ID etc)', function(done) {
user_info_func({
- driver : driver,
- email : email_employee,
+ driver,
+ email: email_employee
+ }).then(function(data) {
+ employee_id = data.user.id
+ done()
})
- .then(function(data){
- employee_id = data.user.id;
- done();
- });
- });
+ })
- it("See if EMPLOYEE is among possible approvers", function(done){
- driver.findElements(By.css(
- 'select[name="boss_id__new"] option[value="'+employee_id+'"]'
- ))
- .then(function(option){
- expect(option).to.be.not.empty;
- done();
- });
- });
+ it('See if EMPLOYEE is among possible approvers', function(done) {
+ driver
+ .findElements(
+ By.css(
+ 'select[name="manager_id__new"] option[value="' + employee_id + '"]'
+ )
+ )
+ .then(function(option) {
+ expect(option).to.be.not.empty
+ done()
+ })
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Login as an EMPLOYEE to make sure it is possible', function(done){
+ it('Login as an EMPLOYEE to make sure it is possible', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_employee,
- driver : driver,
+ application_host,
+ user_email: email_employee,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from EMPLOYEE account", function(done){
+ it('Logout from EMPLOYEE account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Login back as ADMIN', function(done){
+ it('Login back as ADMIN', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_admin,
- driver : driver,
+ application_host,
+ user_email: email_admin,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open employee details page', function(done){
+ it('Open employee details page', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+employee_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + employee_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Mark EMPLOYEE as one inactive one by specifying end date to be in past", function(done){
+ it('Mark EMPLOYEE as one inactive one by specifying end date to be in past', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#end_date_inp',
- value : moment().subtract(1, 'days').format('YYYY-MM-DD'),
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#end_date_inp',
+ value: moment()
+ .subtract(1, 'days')
+ .format('YYYY-MM-DD')
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure EMPLOYEE is not on Team view page anymore", function(done){
+ it('Make sure EMPLOYEE is not on Team view page anymore', function(done) {
teamview_check_func({
- driver : driver,
- emails : [email_admin, email_manager],
- is_link : true,
+ driver,
+ emails: [email_admin, email_manager],
+ is_link: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open users list page", function(done){
+ it('Open users list page', function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make sure that EMPLOYEE still is shown on users page decpite being inactive', function(done){
- driver
- .findElements(By.css( 'td.user_department' ))
- .then(function(elements){
- expect(elements.length).to.be.equal(3);
- done();
- });
- });
+ it('Make sure that EMPLOYEE still is shown on users page decpite being inactive', function(done) {
+ driver.findElements(By.css('td.user_department')).then(function(elements) {
+ expect(elements.length).to.be.equal(3)
+ done()
+ })
+ })
it('Check that employee is striked in the list', function(done) {
- driver.
- findElement(By.css('a[href="/users/edit/'+employee_id+'/"]'))
- .then(el => el.findElements(By.tagName("s")))
+ driver
+ .findElement(By.css('a[href="/users/edit/' + employee_id + '/"]'))
+ .then(el => el.findElements(By.tagName('s')))
.then(els => {
if (els.length === 1) {
- done();
+ done()
} else {
- throw new Error("User is not striked")
+ throw new Error('User is not striked')
}
})
- });
+ })
- it("Open department settings page", function(done){
+ it('Open department settings page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to add new department and make sure that EMPLOYEE is not among potentual approvers", function(done){
+ it('Try to add new department and make sure that EMPLOYEE is not among potentual approvers', function(done) {
driver
- .findElements(By.css(
- 'select[name="boss_id__new"] option[value="'+employee_id+'"]'
- ))
- .then(function(option){
- expect(option).to.be.empty;
- done();
- });
- });
+ .findElements(
+ By.css(
+ 'select[name="manager_id__new"] option[value="' + employee_id + '"]'
+ )
+ )
+ .then(function(option) {
+ expect(option).to.be.empty
+ done()
+ })
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to login as EMPLOYEE and make sure system rejects", function(done){
+ it('Try to login as EMPLOYEE and make sure system rejects', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_employee,
- driver : driver,
- should_fail : true,
+ application_host,
+ user_email: email_employee,
+ driver,
+ should_fail: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/integration_api/audit.js b/t/integration/integration_api/audit.js
index d717dc574..76417d47c 100644
--- a/t/integration/integration_api/audit.js
+++ b/t/integration/integration_api/audit.js
@@ -1,20 +1,18 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird"),
- rp = require('request-promise'),
- registerNewUserFunc = require('../../lib/register_new_user'),
- openPageFunc = require('../../lib/open_page'),
- submitFormFunc = require('../../lib/submit_form'),
- userInfoFunc = require('../../lib/user_info'),
- checkElementsFunc = require('../../lib/check_elements'),
- addNewUserFunc = require('../../lib/add_new_user'),
- config = require('../../lib/config'),
- applicationHost = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const Promise = require('bluebird')
+const rp = require('request-promise')
+const registerNewUserFunc = require('../../lib/register_new_user')
+const openPageFunc = require('../../lib/open_page')
+const submitFormFunc = require('../../lib/submit_form')
+const userInfoFunc = require('../../lib/user_info')
+const checkElementsFunc = require('../../lib/check_elements')
+const addNewUserFunc = require('../../lib/add_new_user')
+const config = require('../../lib/config')
+const applicationHost = config.get_application_host()
/*
* Scenario:
@@ -29,125 +27,143 @@ const
*
* */
-describe('Basic audit for user changes', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Basic audit for user changes', function() {
+ this.timeout(config.get_execution_timeout())
- let driver, token, email, userId, secondEmail, secondUserId;
+ let driver, token, email, userId, secondEmail, secondUserId
- it('Create new company', done => {
- registerNewUserFunc({applicationHost})
+ it('Create new company', function(done) {
+ registerNewUserFunc({ applicationHost })
.then(data => {
- ({driver, email} = data);
- return userInfoFunc({ driver, email });
+ ;({ driver, email } = data)
+ return userInfoFunc({ driver, email })
})
.then(data => (userId = data.user.id))
- .then(() => done());
- });
+ .then(() => done())
+ })
- it('Enable API integration and capture the token value', done => {
+ it('Enable API integration and capture the token value', function(done) {
openPageFunc({
driver,
- url: `${applicationHost}settings/company/integration-api/`,
+ url: `${applicationHost}settings/company/integration-api/`
})
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector : 'input[name="integration_api_enabled"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector: '#save_settings_btn',
- should_be_successful: true,
- message: /Settings were saved/,
- }))
- .then(() => driver.findElement(By.css('input#token-value')))
- .then(el => el.getAttribute('value'))
- .then(v => Promise.resolve(token=v))
- .then(obj => done());
- });
-
- it('Navigate to current user details and update its Name and Surname', done => {
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="integration_api_enabled"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: '#save_settings_btn',
+ should_be_successful: true,
+ message: /Settings were saved/
+ })
+ )
+ .then(() => driver.findElement(By.css('input#token-value')))
+ .then(el => el.getAttribute('value'))
+ .then(v => Promise.resolve((token = v)))
+ .then(obj => done())
+ })
+
+ it('Navigate to current user details and update its Name and Surname', function(done) {
openPageFunc({
url: `${applicationHost}users/edit/${userId}/`,
- driver,
+ driver
})
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector : 'input[name="name"]',
- value : 'NewAuditName',
- },{
- selector : 'input[name="lastname"]',
- value : 'NewAuditLastName',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .* were updated/,
- }))
- .then(() => done());
- });
-
- it("Create second user", done => {
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="name"]',
+ value: 'NewAuditName'
+ },
+ {
+ selector: 'input[name="lastname"]',
+ value: 'NewAuditLastName'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Create second user', function(done) {
addNewUserFunc({
- application_host : applicationHost,
- driver,
- })
- .then(data => {
- secondEmail = data.new_user_email;
- return userInfoFunc({ driver, email: secondEmail });
+ application_host: applicationHost,
+ driver
})
- .then(data => (secondUserId = data.user.id))
- .then(() => done());
- });
+ .then(data => {
+ secondEmail = data.new_user_email
+ return userInfoFunc({ driver, email: secondEmail })
+ })
+ .then(data => (secondUserId = data.user.id))
+ .then(() => done())
+ })
- it("Remove second account", done => {
+ it('Remove second account', function(done) {
openPageFunc({
url: `${applicationHost}users/edit/${secondUserId}/`,
- driver,
+ driver
})
- .then(() => submitFormFunc({
- submit_button_selector : 'button#remove_btn',
- message : /Employee records were removed from the system/,
- driver,
- confirm_dialog : true,
- }))
- .then(() => done());
- });
-
- it('Fetch the Audit feed from integration API', done => {
- rp(`${applicationHost}integration/v1/audit`,{
- method : 'GET',
+ .then(() =>
+ submitFormFunc({
+ submit_button_selector: 'button#remove_btn',
+ message: /Employee records were removed from the system/,
+ driver,
+ confirm_dialog: true
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Fetch the Audit feed from integration API', function(done) {
+ rp(`${applicationHost}integration/v1/audit`, {
+ method: 'GET',
body: '{}',
headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${token}`,
- },
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${token}`
+ }
})
- .then(res => JSON.parse(res))
- .then(obj => {
- const twoEvents = obj
- .filter(i=>i.entityType === 'USER')
- .filter(i=>i.entityId === userId);
-
- expect(twoEvents.length).to.be.eql(2);
-
- expect(twoEvents.map(i=>i.attribute).join(',')).to.be.eql('name,lastname');
- expect(twoEvents.map(i=>i.newValue).join(',')).to.be.eql('NewAuditName,NewAuditLastName');
-
- const removedEvents = obj
- .filter(i=>i.entityType === 'USER')
- .filter(i=>i.entityId === secondUserId);
-
- expect(removedEvents.length, 'There records regarding user deletion')
- .to.be.above(0);
- expect(removedEvents.filter(i=>i.newValue==='null').length, 'all of them are nulls')
- .to.be.eql( removedEvents.length );
-
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(() => done());
- });
-});
+ .then(res => JSON.parse(res))
+ .then(obj => {
+ const twoEvents = obj
+ .filter(i => i.entity_type === 'USER')
+ .filter(i => i.entity_id === userId)
+
+ expect(twoEvents.length).to.be.eql(2)
+
+ expect(twoEvents.map(i => i.attribute).join(',')).to.be.eql(
+ 'name,lastname'
+ )
+ expect(twoEvents.map(i => i.newValue).join(',')).to.be.eql(
+ 'NewAuditName,NewAuditLastName'
+ )
+
+ const removedEvents = obj
+ .filter(i => i.entity_type === 'USER')
+ .filter(i => i.entity_id === secondUserId)
+
+ expect(
+ removedEvents.length,
+ 'There records regarding user deletion'
+ ).to.be.above(0)
+ expect(
+ removedEvents.filter(i => i.newValue === 'null').length,
+ 'all of them are nulls'
+ ).to.be.eql(removedEvents.length)
+
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/integration_api/enable_disable.js b/t/integration/integration_api/enable_disable.js
index ca0091f32..e895b45d2 100644
--- a/t/integration/integration_api/enable_disable.js
+++ b/t/integration/integration_api/enable_disable.js
@@ -1,18 +1,16 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird"),
- rp = require('request-promise'),
- registerNewUserFunc = require('../../lib/register_new_user'),
- openPageFunc = require('../../lib/open_page'),
- submitFormFunc = require('../../lib/submit_form'),
- checkElementsFunc = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- applicationHost = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const Promise = require('bluebird');
+ const rp = require('request-promise');
+ const registerNewUserFunc = require('../../lib/register_new_user');
+ const openPageFunc = require('../../lib/open_page');
+ const submitFormFunc = require('../../lib/submit_form');
+ const checkElementsFunc = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const applicationHost = config.get_application_host()
/*
* Scenario to go in this test:
@@ -30,177 +28,222 @@ const
*
* */
-describe('Enable/disable Integration APIs', function(){
+describe('Enable/disable Integration APIs', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let driver, oldToken, newToken, email
- let driver, oldToken, newToken, email;
+ it('Create new company', function(done) {
+ registerNewUserFunc({ applicationHost }).then(data => {
+ ;({ driver, email } = data)
+ done()
+ })
+ })
- it('Create new company', done => {
- registerNewUserFunc({applicationHost})
- .then(data => {
- ({driver, email} = data);
- done();
- });
- });
-
- it('Navigate to API page and ensure the API is disable', done => {
+ it('Navigate to API page and ensure the API is disable', function(done) {
openPageFunc({
driver,
- url: `${applicationHost}settings/company/integration-api/`,
+ url: `${applicationHost}settings/company/integration-api/`
})
- .then(() => checkElementsFunc({
- driver,
- elements_to_check : [{
- selector : 'input[name="integration_api_enabled"]',
- tick : true,
- value : 'off',
- }]
- }))
- .then(() => done());
- });
-
- it('Read the key and try to invoke the API with that key: ensure the end point is blocked', done => {
+ .then(() =>
+ checkElementsFunc({
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="integration_api_enabled"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Read the key and try to invoke the API with that key: ensure the end point is blocked', function(done) {
driver
.findElement(By.css('input#token-value'))
.then(el => el.getAttribute('value'))
- .then(v => Promise.resolve(oldToken=v))
- .then(() => rp(`${applicationHost}integration/v1/report/absence`,{
- method : 'GET',
- body: '{}',
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${oldToken}`,
- },
- }))
- .then(res => {throw new Error('TOM_TEST')})
+ .then(v => Promise.resolve((oldToken = v)))
+ .then(() =>
+ rp(`${applicationHost}integration/v1/report/absence`, {
+ method: 'GET',
+ body: '{}',
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${oldToken}`
+ }
+ })
+ )
+ .then(res => {
+ throw new Error('TOM_TEST')
+ })
.catch(error => {
- expect(error).not.to.be.equal('TOM_TEST', 'Ensure contrl flow did not go beyond the "rp"');
- expect(error.response.statusCode).to.be.equal(401, 'Ensure response code is correct');
- done();
+ expect(error).not.to.be.equal(
+ 'TOM_TEST',
+ 'Ensure contrl flow did not go beyond the "rp"'
+ )
+ expect(error.response.statusCode).to.be.equal(
+ 401,
+ 'Ensure response code is correct'
+ )
+ done()
})
- });
+ })
- it('Enable the API and repeate the invokation above: ensure that now it is successful', done => {
+ it('Enable the API and repeate the invokation above: ensure that now it is successful', function(done) {
openPageFunc({
driver,
- url: `${applicationHost}settings/company/integration-api/`,
+ url: `${applicationHost}settings/company/integration-api/`
})
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector : 'input[name="integration_api_enabled"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector: '#save_settings_btn',
- should_be_successful: true,
- message: /Settings were saved/,
- }))
- .then(() => rp(`${applicationHost}integration/v1/report/absence`,{
- method : 'GET',
- body: '{}',
- headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${oldToken}`,
- },
- }))
- .then(res => JSON.parse(res))
- .then(obj => {
- expect(obj[0].user.email).to.be.equal(email, 'Ensure that report conatins email of admin user');
- done();
- });
- });
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="integration_api_enabled"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: '#save_settings_btn',
+ should_be_successful: true,
+ message: /Settings were saved/
+ })
+ )
+ .then(() =>
+ rp(`${applicationHost}integration/v1/report/absence`, {
+ method: 'GET',
+ body: '{}',
+ headers: {
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${oldToken}`
+ }
+ })
+ )
+ .then(res => JSON.parse(res))
+ .then(obj => {
+ expect(obj[0].user.email).to.be.equal(
+ email,
+ 'Ensure that report conatins email of admin user'
+ )
+ done()
+ })
+ })
- it('Regenerate the API key', done => {
+ it('Regenerate the API key', function(done) {
openPageFunc({
driver,
- url: `${applicationHost}settings/company/integration-api/`,
+ url: `${applicationHost}settings/company/integration-api/`
})
- .then(() => submitFormFunc({
- driver,
- form_params : [],
- submit_button_selector: '#regenerate_token_btn',
- should_be_successful: true,
- message: /Settings were saved/,
- }))
- .then(() => driver.findElement(By.css('input#token-value')))
- .then(el => el.getAttribute('value'))
- .then(v => Promise.resolve(newToken=v))
- .then(() => done());
- });
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [],
+ submit_button_selector: '#regenerate_token_btn',
+ should_be_successful: true,
+ message: /Settings were saved/
+ })
+ )
+ .then(() => driver.findElement(By.css('input#token-value')))
+ .then(el => el.getAttribute('value'))
+ .then(v => Promise.resolve((newToken = v)))
+ .then(() => done())
+ })
- it('Ensure that old API key is not valid anymore', done => {
- rp(`${applicationHost}integration/v1/report/absence`,{
- method : 'GET',
+ it('Ensure that old API key is not valid anymore', function(done) {
+ rp(`${applicationHost}integration/v1/report/absence`, {
+ method: 'GET',
body: '{}',
headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${oldToken}`,
- },
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${oldToken}`
+ }
})
- .then(res => {throw new Error('TOM_TEST')})
- .catch(error => {
- expect(error).not.to.be.equal('TOM_TEST', 'Ensure contrl flow did not go beyond the "rp"');
- expect(error.response.statusCode).to.be.equal(401, 'Ensure response code is correct');
- done();
- });
- });
+ .then(res => {
+ throw new Error('TOM_TEST')
+ })
+ .catch(error => {
+ expect(error).not.to.be.equal(
+ 'TOM_TEST',
+ 'Ensure contrl flow did not go beyond the "rp"'
+ )
+ expect(error.response.statusCode).to.be.equal(
+ 401,
+ 'Ensure response code is correct'
+ )
+ done()
+ })
+ })
- it('Ensure that newly renenerated API key works fine', done => {
- rp(`${applicationHost}integration/v1/report/absence`,{
- method : 'GET',
+ it('Ensure that newly renenerated API key works fine', function(done) {
+ rp(`${applicationHost}integration/v1/report/absence`, {
+ method: 'GET',
body: '{}',
headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${newToken}`,
- },
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${newToken}`
+ }
})
- .then(res => JSON.parse(res))
- .then(obj => {
- expect(obj[0].user.email).to.be.equal(email, 'Ensure that report conatins email of admin user');
- done();
- });
- });
+ .then(res => JSON.parse(res))
+ .then(obj => {
+ expect(obj[0].user.email).to.be.equal(
+ email,
+ 'Ensure that report conatins email of admin user'
+ )
+ done()
+ })
+ })
- it('Disable the API integration for current company', done => {
+ it('Disable the API integration for current company', function(done) {
openPageFunc({
driver,
- url: `${applicationHost}settings/company/integration-api/`,
+ url: `${applicationHost}settings/company/integration-api/`
})
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector : 'input[name="integration_api_enabled"]',
- tick : true,
- value : 'off',
- }],
- submit_button_selector: '#save_settings_btn',
- should_be_successful: true,
- message: /Settings were saved/,
- }))
- .then(() => done());
- });
-
- it('Ensure that API end points do not work anymore', done => {
- rp(`${applicationHost}integration/v1/report/absence`,{
- method : 'GET',
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="integration_api_enabled"]',
+ tick: true,
+ value: 'off'
+ }
+ ],
+ submit_button_selector: '#save_settings_btn',
+ should_be_successful: true,
+ message: /Settings were saved/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Ensure that API end points do not work anymore', function(done) {
+ rp(`${applicationHost}integration/v1/report/absence`, {
+ method: 'GET',
body: '{}',
headers: {
- "Content-Type": "application/json",
- "Authorization": `Bearer ${newToken}`,
- },
+ 'Content-Type': 'application/json',
+ Authorization: `Bearer ${newToken}`
+ }
})
- .then(res => {throw new Error('TOM_TEST')})
- .catch(error => {
- expect(error).not.to.be.equal('TOM_TEST', 'Ensure contrl flow did not go beyond the "rp"');
- expect(error.response.statusCode).to.be.equal(401, 'Ensure response code is correct');
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(() => done());
- });
+ .then(res => {
+ throw new Error('TOM_TEST')
+ })
+ .catch(error => {
+ expect(error).not.to.be.equal(
+ 'TOM_TEST',
+ 'Ensure contrl flow did not go beyond the "rp"'
+ )
+ expect(error.response.statusCode).to.be.equal(
+ 401,
+ 'Ensure response code is correct'
+ )
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/leave_request/auto_approve.js b/t/integration/leave_request/auto_approve.js
new file mode 100644
index 000000000..90a46668c
--- /dev/null
+++ b/t/integration/leave_request/auto_approve.js
@@ -0,0 +1,385 @@
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const until = require('selenium-webdriver').until;
+ const Promise = require('bluebird');
+ const expect = require('chai').expect;
+ const add_new_user_func = require('../../lib/add_new_user');
+ const check_elements_func = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const login_user_func = require('../../lib/login_with_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const some_weekday_date = '2015-06-17'
+
+/*
+ * Scenario:
+ * * Create new company with admin user A and regular employee B
+ * * Update details for user B to make all its leave requests autoapproved
+ * * Login as user B and place a leave request
+ * * Ensure that it went straight to Approved status
+ * * Login as user A and ensure there is no leave request pended
+ * * Go to email audit page and ensure that last two emails are related
+ * to auto approved leave requests
+ * * Login as user B
+ * * Revoke recently added leave
+ * * Ensure that it is gone without need to be approved, no leaves are listed
+ * for user B
+ * * Login back as user A and ensure that user B does not have any leaves
+ * * There is no leave request to be processed
+ * * Go to email audit page and ensure that the last two emails are about
+ * auto approving of leave revoke
+ *
+ * */
+
+describe('Auto approvals', function() {
+ this.timeout(config.get_execution_timeout())
+
+ let driver, email_A, email_B, user_id_A, user_id_B
+
+ it('Register new company', function(done) {
+ register_new_user_func({
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
+ })
+ })
+
+ it('Create second user B', function(done) {
+ add_new_user_func({
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
+ })
+ })
+
+ it('Obtain information about admin user A', function(done) {
+ user_info_func({
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
+ })
+ })
+
+ it('Obtain information about user B', function(done) {
+ user_info_func({
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
+ })
+ })
+
+ it('Open details page for user B', function(done) {
+ open_page_func({
+ url: application_host + 'users/edit/' + user_id_B + '/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Update settings to make all its leave requests auto approved', function(done) {
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="auto_approve"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Logout from admin user', function(done) {
+ logout_user_func({
+ application_host,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Login as regular user B', function(done) {
+ login_user_func({
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
+ // This is very important line when working with Bootstrap modals!
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Submit new leave requesti from user B', function(done) {
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: some_weekday_date
+ },
+ {
+ selector: 'input#to',
+ value: some_weekday_date
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
+ open_page_func({
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that new leave went straight to Approved status', function(done) {
+ driver
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(1)
+ return elements[0].getText()
+ })
+ .then(function(status) {
+ expect(status).to.be.eq('Approved')
+ done()
+ })
+ })
+
+ it('Logout from user B', function(done) {
+ logout_user_func({
+ application_host,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Login as admin user A', function(done) {
+ login_user_func({
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
+ open_page_func({
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that there is no pending leave requests', function(done) {
+ driver.findElements(By.css('.btn-warning')).then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Open email audit page', function(done) {
+ open_page_func({
+ url: application_host + 'audit/email/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure there were two emails regarding auto-approved leaves', function(done) {
+ driver
+ .findElements(By.css('tr.vpp-email-audit-entry-header a.collapsed'))
+ .then(function(elements) {
+ return Promise.map([elements[0], elements[1]], function(el) {
+ return el.getText()
+ })
+ })
+ .then(function(subjects) {
+ expect(subjects).to.contain('New leave was added and auto approved.')
+ expect(subjects).to.contain('New leave was added')
+ done()
+ })
+ })
+
+ it('Logout from admin user', function(done) {
+ logout_user_func({
+ application_host,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Login as regular user B', function(done) {
+ login_user_func({
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
+ open_page_func({
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Revoke request', function(done) {
+ driver
+ .findElement(By.css('button.revoke-btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
+ // Wait until page properly is reloaded
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ return driver.findElement(By.css('.alert-success')).then(function(el) {
+ expect(el).to.be.ok
+ return Promise.resolve(1)
+ })
+ })
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that it is gone without need to be approved', function(done) {
+ driver
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Logout from user B', function(done) {
+ logout_user_func({
+ application_host,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Login as admin user A', function(done) {
+ login_user_func({
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open user B absences section', function(done) {
+ open_page_func({
+ url: application_host + 'users/edit/' + user_id_B + '/absences/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that user B does not have any leaves', function(done) {
+ driver
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
+ open_page_func({
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that there is no pending leave requests', function(done) {
+ driver.findElements(By.css('.btn-warning')).then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Open email audit page', function(done) {
+ open_page_func({
+ url: application_host + 'audit/email/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure there were two emails regarding auto-approved leaves', function(done) {
+ driver
+ .findElements(By.css('tr.vpp-email-audit-entry-header a.collapsed'))
+ .then(function(elements) {
+ return Promise.map([elements[0], elements[1]], function(el) {
+ return el.getText()
+ })
+ })
+ .then(function(subjects) {
+ expect(subjects).to.contain('Leave was revoked and auto approved')
+ expect(subjects).to.contain('Leave was revoked')
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/basic_leave_request.js b/t/integration/leave_request/basic_leave_request.js
index 8a762b7d1..0b0b22b97 100644
--- a/t/integration/leave_request/basic_leave_request.js
+++ b/t/integration/leave_request/basic_leave_request.js
@@ -1,26 +1,24 @@
-
-'use strict';
-
-const test = require('selenium-webdriver/testing'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- until = require('selenium-webdriver').until,
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- user_info_func = require('../../lib/user_info'),
- add_new_user_func = require('../../lib/add_new_user'),
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
-
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const Promise = require('bluebird')
+const moment = require('moment')
+const until = require('selenium-webdriver').until
+const login_user_func = require('../../lib/login_with_user')
+const register_new_user_func = require('../../lib/register_new_user')
+const logout_user_func = require('../../lib/logout_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const check_elements_func = require('../../lib/check_elements')
+const check_booking_func = require('../../lib/check_booking_on_calendar')
+const user_info_func = require('../../lib/user_info')
+const add_new_user_func = require('../../lib/add_new_user')
+const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario to go in this test:
@@ -35,354 +33,406 @@ const test = require('selenium-webdriver/testing'),
*
* */
-describe('Basic leave request', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Basic leave request', function() {
+ this.timeout(config.get_execution_timeout())
- var non_admin_user_email, new_user_email, driver;
+ let non_admin_user_email, new_user_email, driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ new_user_email = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- new_user_email = data.email;
- driver = data.driver;
- done();
- });
- });
-
- it("Create new non-admin user", function(done){
+ })
+
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Login as non-admin user", function(done){
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2015&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2015&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
})
- .then(function(){done()});
- });
-
- it("And make sure that it is calendar indeed", function(done){
- driver.getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
-
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ })
+
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Following code is to ensure that non admin user can request leave only for herself', function(done) {
+ driver
+ .findElements(By.css('select#employee'))
+ .then(found => !!found.length)
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(false)
+ done()
})
- .then(function(){ done() });
- });
-
- it("Following code is to ensure that non admin user can request leave only for herself", function(done){
- driver.isElementPresent(By.css('select#employee'))
- .then(function(is_present){
- expect(is_present).to.be.equal(false);
- done();
- });
- });
-
- it("Submit new leave request", function(done){
+ })
+
+ it('Submit new leave request', function(done) {
submit_form_func({
- driver : driver,
+ driver,
// The order matters here as we need to populate dropdown prior date filds
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-16',
- }],
- message : /New leave request was added/,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-16'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-16')],
- halfs_1st_days : [moment('2015-06-15')],
- type : 'pended',
+ driver,
+ full_days: [moment('2015-06-16')],
+ halfs_1st_days: [moment('2015-06-15')],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Logout from non-admin acount", function(done){
+ it('Logout from non-admin acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Login as admin user", function(done){
+ it('Login as admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : new_user_email,
- driver : driver,
+ application_host,
+ user_email: new_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Make sure newly created request is shown for approval", function(done){
+ it('Make sure newly created request is shown for approval', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'tr[vpp="pending_for__'+non_admin_user_email+'"] .btn-warning',
- value : "Reject",
- }],
- })
- .then(function(){done()});
- });
-
- it("Approve newly added leave request", function(done){
- driver.findElement(By.css(
- 'tr[vpp="pending_for__'+non_admin_user_email+'"] .btn-success'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
- // Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ 'tr[vpp="pending_for__' + non_admin_user_email + '"] .btn-warning',
+ value: 'Reject'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
+
+ it('Approve newly added leave request', function(done) {
+ driver
+ .findElement(
+ By.css(
+ 'tr[vpp="pending_for__' + non_admin_user_email + '"] .btn-success'
+ )
+ )
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
+ // Wait until page properly is reloaded
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ done()
+ })
+ })
- it("Logout from admin acount", function(done){
+ it('Logout from admin acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
})
- it("Login as non-admin user", function(done){
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open calendar page (in full year mode)", function(done){
+ it('Open calendar page (in full year mode)', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2015&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2015&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
})
- .then(function(){done()});
- });
-
- it("And make sure that it is calendar indeed", function(done){
- driver.getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
-
- it("Check that all days are marked as pended", function(done){
+ })
+
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-16')],
- halfs_1st_days : [moment('2015-06-15')],
- type : 'approved',
+ driver,
+ full_days: [moment('2015-06-16')],
+ halfs_1st_days: [moment('2015-06-15')],
+ type: 'approved'
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open calendar page (short version)", function(done){
+ it('Open calendar page (short version)', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Make sure that requests have approver been populated", function(done){
- driver.findElement(
+ it('Make sure that requests have approver been populated', function(done) {
+ driver
+ .findElement(
By.css('.user-requests-table td.user-request-table-approver')
)
- .then(function(el){ return el.getText(); })
- .then(function(text){
- expect(text).to.be.not.empty;
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.not.empty
+ done()
+ })
+ })
-describe("Use problematic date with non default date format", function(){
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
- this.timeout( config.get_execution_timeout() );
+describe('Use problematic date with non default date format', function() {
+ this.timeout(config.get_execution_timeout())
- let driver, email, user_id;
+ let driver, email, user_id
- it("Register new company with default date to be DD/MM/YY", function(done){
+ it('Register new company with default date to be DD/MM/YY', function(done) {
register_new_user_func({
- application_host : application_host,
- default_date_format : 'DD/MM/YY',
+ application_host,
+ default_date_format: 'DD/MM/YY'
+ }).then(data => {
+ ;({ email, driver } = data)
+ done()
})
- .then((data) => {
- ({email, driver} = data);
- done();
- });
- });
-
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email, year:2016})
- .then(() => done())
- });
+ })
+
+ it('Ensure user starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email, year: 2016 }).then(() =>
+ done()
+ )
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2016&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2016&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done(); })
- });
+ })
- it("Open Book new leave pop up", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ it('Open Book new leave pop up', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
// This is very important line when working with Bootstrap modals!
- .then(function(){ return driver.sleep(1000) })
- .then(function(){ done() });
- });
-
- it("Make sure it is possible to place an leave request for date that was reported to be problematic", function(done){
+ .then(function() {
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
+ })
+ })
+ it('Make sure it is possible to place an leave request for date that was reported to be problematic', function(done) {
submit_form_func({
- driver : driver,
+ driver,
// The order matters here as we need to populate dropdown prior date filds
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '24/08/16',
- },{
- selector : 'input#to',
- value : '25/08/16',
- }],
- message : /New leave request was added/,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '24/08/16'
+ },
+ {
+ selector: 'input#to',
+ value: '25/08/16'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done(); });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ })
-describe("Book the very last day of year to be a holiday", function(){
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
- this.timeout( config.get_execution_timeout() );
+describe('Book the very last day of year to be a holiday', function() {
+ this.timeout(config.get_execution_timeout())
- let driver, email;
+ let driver, email
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ ;({ driver, email } = data)
+ done()
})
- .then(function(data){
- ({driver, email} = data);
- done();
- });
- });
-
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email, year: 2018})
- .then(() => done())
- });
+ })
- it("Place new holiday to be the very last day of the year", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
+ it('Ensure user starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email, year: 2018 }).then(() =>
+ done()
+ )
+ })
+
+ it('Place new holiday to be the very last day of the year', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2018-12-31',
- },{
- selector : 'input#to',
- value : '2018-12-31',
- }],
- message : /New leave request was added/,
- })
- )
- .then(() => done());
- });
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2018-12-31'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-12-31'
+ }
+ ],
+ message: /New leave request was added/
+ })
+ )
+ .then(() => done())
+ })
- it("Open calendar page and ensure that the very last day of the year is marked as pending", function(done){
+ it('Open calendar page and ensure that the very last day of the year is marked as pending', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2018&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2018&show_full_year=1',
+ driver
})
+ .then(() =>
+ check_booking_func({
+ driver,
+ full_days: [moment('2018-12-31')],
+ type: 'pended'
+ })
+ )
- .then(() => check_booking_func({
- driver : driver,
- full_days : [moment('2018-12-31')],
- type : 'pended',
- }))
-
- .then(() => done());
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ .then(() => done())
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/book_leave_request_form.js b/t/integration/leave_request/book_leave_request_form.js
index 168f5af93..2c59cd0ff 100644
--- a/t/integration/leave_request/book_leave_request_form.js
+++ b/t/integration/leave_request/book_leave_request_form.js
@@ -1,126 +1,155 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- until = require('selenium-webdriver').until,
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user');
-
-describe("Check the client side logic to facilitate filling new absence form", function(){
-
- this.timeout( config.get_execution_timeout() );
-
- var driver;
-
- it("Register new company", function(done){
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host();
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const until = require('selenium-webdriver').until;
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const check_booking_func = require('../../lib/check_booking_on_calendar');
+ const add_new_user_func = require('../../lib/add_new_user')
+
+describe('Check the client side logic to facilitate filling new absence form', function() {
+ this.timeout(config.get_execution_timeout())
+
+ let driver
+
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2017&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2017&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() })
- });
+ })
- it("Open Book new leave pop up window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ it('Open Book new leave pop up window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
// This is very important line when working with Bootstrap modals!
- .then(function(){ return driver.sleep(1000) })
- .then(function(){ done() });
- });
+ .then(function() {
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
+ })
+ })
- it("Ensure by default FROM and TO fields are populated with current date", function(done){
+ it('Ensure by default FROM and TO fields are populated with current date', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input.book-leave-from-input',
- value : moment().format('YYYY-MM-DD'),
- },{
- selector : 'input.book-leave-to-input',
- value : moment().format('YYYY-MM-DD'),
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input.book-leave-from-input',
+ value: moment().format('YYYY-MM-DD')
+ },
+ {
+ selector: 'input.book-leave-to-input',
+ value: moment().format('YYYY-MM-DD')
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("Update FROM to be in future and make sure TO is automatically addusted to the same date", function(done){
+ })
- var inp_from,
- tomorrow_str = moment().add(1, 'days').format('YYYY-MM-DD');
+ it('Update FROM to be in future and make sure TO is automatically addusted to the same date', function(done) {
+ let inp_from;
+ const tomorrow_str = moment()
+ .add(1, 'days')
+ .format('YYYY-MM-DD')
driver
.findElement(By.css('input.book-leave-from-input'))
- .then(function(el){ inp_from = el; return el.clear() })
- .then(function(){ return inp_from.sendKeys( tomorrow_str ) });
+ .then(function(el) {
+ inp_from = el
+ return el.clear()
+ })
+ .then(function() {
+ return inp_from.sendKeys(tomorrow_str)
+ })
- driver.call(function(){
+ driver.call(function() {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input.book-leave-from-input',
- value : tomorrow_str,
- },{
- selector : 'input.book-leave-to-input',
- value : tomorrow_str,
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input.book-leave-from-input',
+ value: tomorrow_str
+ },
+ {
+ selector: 'input.book-leave-to-input',
+ value: tomorrow_str
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- });
-
-
- it("Update FROM to be in past and make sure TO is stays unchanged", function(done){
+ })
+ })
- var inp_from,
- tomorrow_str = moment().add(1, 'days').format('YYYY-MM-DD'),
- yesterday_str = moment().subtract(1, 'days').format('YYYY-MM-DD');
+ it('Update FROM to be in past and make sure TO is stays unchanged', function(done) {
+ let inp_from;
+ const tomorrow_str = moment()
+ .add(1, 'days')
+ .format('YYYY-MM-DD');
+ const yesterday_str = moment()
+ .subtract(1, 'days')
+ .format('YYYY-MM-DD')
driver
.findElement(By.css('input.book-leave-from-input'))
- .then(function(el){ inp_from = el; return el.clear() })
- .then(function(){ return inp_from.sendKeys( yesterday_str ) });
+ .then(function(el) {
+ inp_from = el
+ return el.clear()
+ })
+ .then(function() {
+ return inp_from.sendKeys(yesterday_str)
+ })
- driver.call(function(){
+ driver.call(function() {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input.book-leave-from-input',
- value : yesterday_str,
- },{
- selector : 'input.book-leave-to-input',
- value : tomorrow_str,
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input.book-leave-from-input',
+ value: yesterday_str
+ },
+ {
+ selector: 'input.book-leave-to-input',
+ value: tomorrow_str
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/cancel_basic.js b/t/integration/leave_request/cancel_basic.js
index 19a3b19d1..4d4fd98af 100644
--- a/t/integration/leave_request/cancel_basic.js
+++ b/t/integration/leave_request/cancel_basic.js
@@ -1,22 +1,27 @@
-
-'use strict';
-
-const By = require('selenium-webdriver').By,
- until = require('selenium-webdriver').until,
- Promise = require("bluebird"),
- moment = require('moment'),
- expect = require('chai').expect,
- add_new_user_func = require('../../lib/add_new_user'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- register_new_user_func = require('../../lib/register_new_user'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- some_weekday_date = moment().utc().startOf('year').add(1, 'week').startOf('isoWeek').add(2, 'day').format('YYYY-MM-DD');
+'use strict'
+
+const By = require('selenium-webdriver').By;
+ const until = require('selenium-webdriver').until;
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const expect = require('chai').expect;
+ const add_new_user_func = require('../../lib/add_new_user');
+ const check_elements_func = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const login_user_func = require('../../lib/login_with_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const some_weekday_date = moment()
+ .utc()
+ .startOf('year')
+ .add(1, 'week')
+ .startOf('isoWeek')
+ .add(2, 'day')
+ .format('YYYY-MM-DD')
/*
* Scenario:
@@ -35,312 +40,345 @@ const By = require('selenium-webdriver').By,
*
* */
-describe('Leave request cancelation', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Leave request cancelation', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, email_A, email_B, user_id_A, user_id_B;
+ let driver, email_A, email_B, user_id_A, user_id_B
- it('Check precondition', function(){
- expect(moment().format('YYYY')).to.be.eq(moment(some_weekday_date).format('YYYY'));
- });
+ it('Check precondition', function() {
+ expect(moment().format('YYYY')).to.be.eq(
+ moment(some_weekday_date).format('YYYY')
+ )
+ })
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
+ })
- it("Create second user B", function(done){
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about admin user A", function(done){
+ it('Obtain information about admin user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Logout from user A (admin)", function(done){
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Submit new leave request from user B for one weekday", function(done){
+ it('Submit new leave request from user B for one weekday', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : some_weekday_date,
- },{
- selector : 'input#to',
- value : some_weekday_date,
- }],
- message : /New leave request was added/,
- })
- .then(function(){done()});
- });
-
- it("Open requests page", function( done ){
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: some_weekday_date
+ },
+ {
+ selector: 'input#to',
+ value: some_weekday_date
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure newly created request is on Requests page', function(done){
+ it('Ensure newly created request is on Requests page', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'tr.leave-request-row form[action="/requests/cancel/"] button[type="submit"]',
- value : "cancel",
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ 'tr.leave-request-row form[action="/requests/cancel/"] button[type="submit"]',
+ value: 'cancel'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that new request is single one', function(done){
+ it('Ensure that new request is single one', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row' ))
- .then(function(elements){
- expect( elements.length ).to.be.eq(1);
- done();
+ .findElements(By.css('tr.leave-request-row'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(1)
+ done()
})
- });
+ })
- it('Ensure that new request is in Pending status', function(done){
+ it('Ensure that new request is in Pending status', function(done) {
driver
- .findElement(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(element){
- return element.getText();
+ .findElement(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(element) {
+ return element.getText()
+ })
+ .then(function(status) {
+ expect(status).to.be.eq('Pending')
+ done()
})
- .then(function(status){
- expect( status ).to.be.eq('Pending');
- done();
- });
- });
+ })
- it("Cancel leave request", function(done){
+ it('Cancel leave request', function(done) {
driver
- .findElement(By.css(
- 'tr.leave-request-row form[action="/requests/cancel/"] button[type="submit"]'
- ))
- .then(function(cancel_btn){
- return cancel_btn.click();
+ .findElement(
+ By.css(
+ 'tr.leave-request-row form[action="/requests/cancel/"] button[type="submit"]'
+ )
+ )
+ .then(function(cancel_btn) {
+ return cancel_btn.click()
})
- .then(function(){
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it('Ensure that My requests page does not contain any entries', function(done){
+ it('Ensure that My requests page does not contain any entries', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row' ))
- .then(function(elements){
- expect( elements.length ).to.be.eq(0);
- done();
+ .findElements(By.css('tr.leave-request-row'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
})
- });
+ })
- it(" Logout from user B account", function(done){
+ it(' Logout from user B account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login back as admin user A", function(done){
+ it('Login back as admin user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that there is no pending leave requests', function(done){
- driver
- .findElements(By.css( '.btn-warning' ))
- .then(function(elements){
- expect( elements.length ).to.be.eq(0);
- done();
- })
- });
+ it('Ensure that there is no pending leave requests', function(done) {
+ driver.findElements(By.css('.btn-warning')).then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
- it("Open email audit page", function( done ){
+ it('Open email audit page', function(done) {
open_page_func({
- url : application_host + 'audit/email/',
- driver : driver,
+ url: application_host + 'audit/email/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that there were two emails regarding cancelation', function(done){
+ it('Ensure that there were two emails regarding cancelation', function(done) {
driver
- .findElements( By.css('tr.vpp-email-audit-entry-header a.collapsed') )
- .then(function(elements){
- return Promise.map(
- [elements[0], elements[1]],
- function(el){ return el.getText() }
- );
+ .findElements(By.css('tr.vpp-email-audit-entry-header a.collapsed'))
+ .then(function(elements) {
+ return Promise.map([elements[0], elements[1]], function(el) {
+ return el.getText()
+ })
})
- .then(function(subjects){
- expect(subjects).to.contain('Leave request was cancelled');
- expect(subjects).to.contain('Cancel leave request');
- done();
+ .then(function(subjects) {
+ expect(subjects).to.contain('Leave request was cancelled')
+ expect(subjects).to.contain('Cancel leave request')
+ done()
})
- });
+ })
- it('Open user B absences section', function(done){
+ it('Open user B absences section', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_B + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure its details shows nothing from allowance was used', function(done){
+ it('Ensure its details shows nothing from allowance was used', function(done) {
driver
- .findElement( By.css('#days_remaining_inp') )
- .then(function(inp){
- return inp.getAttribute('value');
+ .findElement(By.css('#days_remaining_inp'))
+ .then(function(inp) {
+ return inp.getAttribute('value')
})
- .then(function(text){
+ .then(function(text) {
// It says XX out of XX, where XX are the same
- var allowances = text.match(/(\d+) out of (\d+)/).slice(1,3);
- expect( allowances[0] ).to.be.eq( allowances[1] );
- done();
+ const allowances = text.match(/(\d+) out of (\d+)/).slice(1, 3)
+ expect(allowances[0]).to.be.eq(allowances[1])
+ done()
})
- });
+ })
- it("Logout from user A (admin)", function(done){
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Submit leave request for the same date as the first", function(done){
+ it('Submit leave request for the same date as the first', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : some_weekday_date,
- },{
- selector : 'input#to',
- value : some_weekday_date,
- }],
- message : /New leave request was added/,
- })
- .then(function(){done()});
- });
-
- it("Open requests page", function( done ){
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: some_weekday_date
+ },
+ {
+ selector: 'input#to',
+ value: some_weekday_date
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that new request is in Pending status', function(done){
+ it('Ensure that new request is in Pending status', function(done) {
driver
- .findElement(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(element){
- return element.getText();
+ .findElement(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(element) {
+ return element.getText()
})
- .then(function(status){
- expect( status ).to.be.eq('Pending');
- done();
- });
- });
+ .then(function(status) {
+ expect(status).to.be.eq('Pending')
+ done()
+ })
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
/*
* Scenario:
@@ -350,155 +388,166 @@ describe('Leave request cancelation', function(){
* * Login as admin user A
* * Go to user B details, ensure new reuest is there but no Cancel button
* */
-describe('Check only requestor can see the Cancel button', function(){
+describe('Check only requestor can see the Cancel button', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let driver, email_A, email_B, user_id_A, user_id_B
- var driver, email_A, email_B, user_id_A, user_id_B;
-
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
+ })
- it("Create second user B", function(done){
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about admin user A", function(done){
+ it('Obtain information about admin user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Logout from user A (admin)", function(done){
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Submit new leave requesti from user B", function(done){
+ it('Submit new leave requesti from user B', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : some_weekday_date,
- },{
- selector : 'input#to',
- value : some_weekday_date,
- }],
- message : /New leave request was added/,
- })
- .then(function(){done()});
- });
-
- it("Open requests page", function( done ){
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: some_weekday_date
+ },
+ {
+ selector: 'input#to',
+ value: some_weekday_date
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Ensure Cancel button is visible for user B", function(done){
+ it('Ensure Cancel button is visible for user B', function(done) {
driver
- .findElement(By.css(
- 'tr.leave-request-row form[action="/requests/cancel/"] button[type="submit"]'
- ))
- .then(function(cancel_btn){
- expect( cancel_btn ).to.be.ok;
- done();
- });
- });
-
- it("Logout from user A (admin)", function(done){
+ .findElement(
+ By.css(
+ 'tr.leave-request-row form[action="/requests/cancel/"] button[type="submit"]'
+ )
+ )
+ .then(function(cancel_btn) {
+ expect(cancel_btn).to.be.ok
+ done()
+ })
+ })
+
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as admin user A", function(done){
+ it('Login as admin user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open user B absences section', function(done){
+ it('Open user B absences section', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_B + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Ensure new request is there but no Cancel button", function(done){
+ it('Ensure new request is there but no Cancel button', function(done) {
driver
- .findElements(By.css(
- 'form[action="/requests/cancel/"]'
- ))
- .then(function(cancel_btns){
- expect( cancel_btns.length ).to.be.eq(0);
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ .findElements(By.css('form[action="/requests/cancel/"]'))
+ .then(function(cancel_btns) {
+ expect(cancel_btns.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/create_leave_with_single_user.js b/t/integration/leave_request/create_leave_with_single_user.js
index f921ebed4..8f10e0d3c 100644
--- a/t/integration/leave_request/create_leave_with_single_user.js
+++ b/t/integration/leave_request/create_leave_with_single_user.js
@@ -1,24 +1,21 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- user_info_func = require('../../lib/user_info'),
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
-
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host();
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const check_booking_func = require('../../lib/check_booking_on_calendar');
+ const user_info_func = require('../../lib/user_info');
+ const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario to go in this test:
@@ -31,76 +28,88 @@ const
*
* */
-describe('Leave request with single user', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Leave request with single user', function() {
+ this.timeout(config.get_execution_timeout())
- let new_user_email, driver;
+ let new_user_email, driver
- it('Create new company', function(done){
- register_new_user_func({ application_host })
- .then((data) => {
- ({driver, email:new_user_email} = data);
- done();
- });
- });
+ it('Create new company', function(done) {
+ register_new_user_func({ application_host }).then(data => {
+ ;({ driver, email: new_user_email } = data)
+ done()
+ })
+ })
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email: new_user_email, year:2015})
- .then(() => done())
- });
+ it('Ensure user starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({
+ driver,
+ email: new_user_email,
+ year: 2015
+ }).then(() => done())
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open page to create new leave", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){
- return el.click();
+ it('Open page to create new leave', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
})
- .then(function(){ done() });
- });
-
- it("Create new leave request", function(done){
+ .then(function() {
+ done()
+ })
+ })
+ it('Create new leave request', function(done) {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
+ driver,
// The order matters here as we need to populate dropdown prior date filds
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-16',
- }],
- message : /New leave request was added/,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-16'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-16')],
- halfs_1st_days : [moment('2015-06-15')],
- type : 'pended',
+ driver,
+ full_days: [moment('2015-06-16')],
+ halfs_1st_days: [moment('2015-06-15')],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/leave_in_next_year.js b/t/integration/leave_request/leave_in_next_year.js
index 7e69ac877..1469befd8 100644
--- a/t/integration/leave_request/leave_in_next_year.js
+++ b/t/integration/leave_request/leave_in_next_year.js
@@ -1,26 +1,26 @@
+'use strict'
-'use strict';
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const until = require('selenium-webdriver').until;
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_booking_func = require('../../lib/check_booking_on_calendar');
+ const add_new_user_func = require('../../lib/add_new_user');
+ const leave_type_edit_form_id = '#leave_type_edit_form';
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host();
+ const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird"),
- moment = require('moment'),
- until = require('selenium-webdriver').until,
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user'),
- leave_type_edit_form_id='#leave_type_edit_form',
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
-
-const nextYear = moment().add(1, 'y').format('YYYY');
+const nextYear = moment()
+ .add(1, 'y')
+ .format('YYYY')
/*
* Scenario to go in this test:
@@ -31,55 +31,52 @@ const nextYear = moment().add(1, 'y').format('YYYY');
*
* */
-describe(`Leave in the next year (${nextYear}) when no allowance in the current one`, function(){
-
- this.timeout( config.get_execution_timeout() );
+describe(`Leave in the next year (${nextYear}) when no allowance in the current one`, function() {
+ this.timeout(config.get_execution_timeout())
- let email, driver;
+ let email, driver
- it('Create new company', done => {
- register_new_user_func({application_host})
- .then(data => {
- ({driver,email} = data);
- done();
- });
- });
+ it('Create new company', function(done) {
+ register_new_user_func({ application_host }).then(data => {
+ ;({ driver, email } = data)
+ done()
+ })
+ })
- it("Update user to start at the very end of current year: 20 Dec", done =>{
+ it('Update user to start at the very end of current year: 20 Dec', function(done) {
userStartsAtTheBeginingOfYear({
driver,
email,
- overwriteDate:moment.utc(`${nextYear-1}-12-20`),
- })
- .then(() => done())
- });
+ overwriteDate: moment.utc(`${nextYear - 1}-12-20`)
+ }).then(() => done())
+ })
- it("Submit leave request for of one week in next year", done => {
+ it('Submit leave request for of one week in next year', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
.then(() => {
-
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : `${nextYear}-01-05`,
- },{
- selector : 'input#to',
- value : `${nextYear}-01-12`,
- }],
- message : /New leave request was added/,
- })
- .then(() => done());
- });
- });
-
- after(done => {
- driver.quit().then(() => done());
- });
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: `${nextYear}-01-05`
+ },
+ {
+ selector: 'input#to',
+ value: `${nextYear}-01-12`
+ }
+ ],
+ message: /New leave request was added/
+ }).then(() => done())
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/leave_request/leave_request_revoke.js b/t/integration/leave_request/leave_request_revoke.js
index bc11ec700..ac1b52491 100644
--- a/t/integration/leave_request/leave_request_revoke.js
+++ b/t/integration/leave_request/leave_request_revoke.js
@@ -1,26 +1,24 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- moment = require('moment'),
- Promise = require("bluebird"),
- until = require('selenium-webdriver').until,
- register_new_user_func = require('../../lib/register_new_user'),
- login_user_func = require('../../lib/login_with_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- add_new_user_func = require('../../lib/add_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- department_edit_form_id = '#department_edit_form',
- currentYear = moment.utc().year();
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const moment = require('moment')
+const Promise = require('bluebird')
+const until = require('selenium-webdriver').until
+const register_new_user_func = require('../../lib/register_new_user')
+const login_user_func = require('../../lib/login_with_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const add_new_user_func = require('../../lib/add_new_user')
+const logout_user_func = require('../../lib/logout_user')
+const check_booking_func = require('../../lib/check_booking_on_calendar')
+const check_elements_func = require('../../lib/check_elements')
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const department_edit_form_id = '#department_edit_form'
+const currentYear = moment.utc().year()
/*
* Scenario to check:
@@ -41,364 +39,417 @@ const
*
* */
-describe('Revoke leave request', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Revoke leave request', function() {
+ this.timeout(config.get_execution_timeout())
let email_admin,
- email_manager_a,
- email_manager_b,
- email_employee,
- driver;
+ admin_user_id,
+ email_manager_a,
+ manager_a_user_id,
+ email_manager_b,
+ manager_b_user_id,
+ email_employee,
+ employee_user_id,
+ driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_admin = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_admin = data.email;
- done();
- });
- });
-
- it("Create MANAGER_A-to-be user", function(done){
+ })
+
+ it('Create MANAGER_A-to-be user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_manager_a = data.new_user_email
+ done()
})
- .then(function(data){
- email_manager_a = data.new_user_email;
- done();
- });
- });
+ })
- it("Create MANAGER_A-to-be user", function(done){
+ it('Create MANAGER_A-to-be user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_manager_b = data.new_user_email
+ done()
})
- .then(function(data){
- email_manager_b = data.new_user_email;
- done();
- });
- });
+ })
- it("Create EMPLOYEE-to-be user", function(done){
+ it('Create EMPLOYEE-to-be user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_employee = data.new_user_email
+ done()
})
- .then(function(data){
- email_employee = data.new_user_email;
- done();
- });
- });
+ })
- it("Open department management page", function(done){
+ it('Open department management page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Update department to be supervised by MANAGER_A', function(done){
+ it('Update department to be supervised by MANAGER_A', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
})
- .then(() => driver
- .findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(links => links[0].click())
- )
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="name"]',
- // Just to make sure it is always first in the lists
- value : 'AAAAA',
- },{
- selector : 'select[name="allowance"]',
- option_selector : 'option[value="15"]',
- value : '15',
- },{
- selector : 'select[name="boss_id"]',
- option_selector : 'select[name="boss_id"] option:nth-child(2)',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
- }))
- .then(() => done());
- });
-
- it("Logout from admin account", function(done){
+ .then(() =>
+ driver
+ .findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ .then(links => links[0].click())
+ )
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="name"]',
+ // Just to make sure it is always first in the lists
+ value: 'AAAAA'
+ },
+ {
+ selector: 'select[name="allowance"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ },
+ {
+ selector: 'select[name="manager_id"]',
+ option_selector: 'select[name="manager_id"] option:nth-child(2)'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as EMPLOYEE user", function(done){
+ it('Login as EMPLOYEE user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_employee,
- driver : driver,
+ application_host,
+ user_email: email_employee,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure that it is calendar indeed", function(done){
- driver
- .getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
-
- it("Request new leave", function(done){
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
+ })
+ })
+
+ it('Request new leave', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){
- return el.click();
+ .then(function(el) {
+ return el.click()
})
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
+ driver,
// The order matters here as we need to populate dropdown prior date filds
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : `${currentYear}-05-11`,
- },{
- selector : 'input#to',
- value : `${currentYear}-05-12`,
- }],
- message : /New leave request was added/,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: `${currentYear}-05-11`
+ },
+ {
+ selector: 'input#to',
+ value: `${currentYear}-05-12`
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment.utc(`${currentYear}-05-12`)],
- halfs_1st_days : [moment.utc(`${currentYear}-05-11`)],
- type : 'pended',
+ driver,
+ full_days: [moment.utc(`${currentYear}-05-12`)],
+ halfs_1st_days: [moment.utc(`${currentYear}-05-11`)],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from EMPLOYEE account", function(done){
+ it('Logout from EMPLOYEE account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as MANAGER_A user", function(done){
+ it('Login as MANAGER_A user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_manager_a,
- driver : driver,
+ application_host,
+ user_email: email_manager_a,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make sure that newly created request is waiting for approval', function(done){
+ it('Make sure that newly created request is waiting for approval', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'tr[vpp="pending_for__'+email_employee+'"] .btn-warning',
- value : "Reject",
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ 'tr[vpp="pending_for__' + email_employee + '"] .btn-warning',
+ value: 'Reject'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Approve newly added leave request", function(done){
+ it('Approve newly added leave request', function(done) {
driver
- .findElement(By.css(
- 'tr[vpp="pending_for__'+email_employee+'"] .btn-success'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(
+ By.css('tr[vpp="pending_for__' + email_employee + '"] .btn-success')
+ )
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from MANAGER_A account", function(done){
+ it('Logout from MANAGER_A account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as ADMIN user", function(done){
+ it('Login as ADMIN user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_admin,
- driver : driver,
+ application_host,
+ user_email: email_admin,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open department management page", function(done){
+ it('Open department management page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Update department to be supervised by MANAGER_B', function(done){
+ it('Update department to be supervised by MANAGER_B', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
})
- .then(() => driver
- .findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(links => links[0].click())
- )
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="name"]',
- // Just to make sure it is always first in the lists
- value : 'AAAAA',
- },{
- selector : 'select[name="allowance"]',
- option_selector : 'option[value="15"]',
- value : '15',
- },{
- selector : 'select[name="boss_id"]',
- option_selector : 'select[name="boss_id"] option:nth-child(3)',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
- }))
- .then(() => done());
- });
-
- it("Logout from admin account", function(done){
+ .then(() =>
+ driver
+ .findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ .then(links => links[0].click())
+ )
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="name"]',
+ // Just to make sure it is always first in the lists
+ value: 'AAAAA'
+ },
+ {
+ selector: 'select[name="allowance"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ },
+ {
+ selector: 'select[name="manager_id"]',
+ option_selector: 'select[name="manager_id"] option:nth-child(3)'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as EMPLOYEE user", function(done){
+ it('Login as EMPLOYEE user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_employee,
- driver : driver,
+ application_host,
+ user_email: email_employee,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Revoke request', function(done){
+ it('Revoke request', function(done) {
driver
- .findElement(By.css(
- 'button.revoke-btn'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(By.css('button.revoke-btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Logout from EMPLOYEE account", function(done){
+ it('Logout from EMPLOYEE account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as MANAGER_B user", function(done){
+ it('Login as MANAGER_B user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_manager_b,
- driver : driver,
+ application_host,
+ user_email: email_manager_b,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure newly revoked request is shown for approval", function(done){
+ it('Make sure newly revoked request is shown for approval', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'tr[vpp="pending_for__'+email_employee+'"] .btn-warning',
- value : "Reject",
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ 'tr[vpp="pending_for__' + email_employee + '"] .btn-warning',
+ value: 'Reject'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Approve revoke request", function(done){
+ it('Approve revoke request', function(done) {
driver
- .findElement(By.css(
- 'tr[vpp="pending_for__'+email_employee+'"] .btn-success'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(
+ By.css('tr[vpp="pending_for__' + email_employee + '"] .btn-success')
+ )
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ .then(function() {
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/leave_request_revoke_by_admin.js b/t/integration/leave_request/leave_request_revoke_by_admin.js
index 849b5dede..6fa8e317c 100644
--- a/t/integration/leave_request/leave_request_revoke_by_admin.js
+++ b/t/integration/leave_request/leave_request_revoke_by_admin.js
@@ -1,24 +1,23 @@
+'use strict'
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- until = require('selenium-webdriver').until,
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- currentYear = moment.utc().year();
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const Promise = require('bluebird')
+const moment = require('moment')
+const until = require('selenium-webdriver').until
+const login_user_func = require('../../lib/login_with_user')
+const register_new_user_func = require('../../lib/register_new_user')
+const logout_user_func = require('../../lib/logout_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const check_elements_func = require('../../lib/check_elements')
+const check_booking_func = require('../../lib/check_booking_on_calendar')
+const add_new_user_func = require('../../lib/add_new_user')
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const currentYear = moment.utc().year()
/*
* Scenario to check:
@@ -32,232 +31,264 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Revoke leave request by Admin', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Revoke leave request by Admin', function() {
+ this.timeout(config.get_execution_timeout())
- let email_admin,
- email_employee, employee_user_id,
- driver;
+ let email_admin, email_employee, employee_user_id, driver
- it("Create new company", function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ email_admin = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- email_admin = data.email;
- driver = data.driver;
- done();
- });
- });
+ })
- it("Create EMPLOYEE-to-be user", function(done){
+ it('Create EMPLOYEE-to-be user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_employee = data.new_user_email
+ done()
})
- .then(function(data){
- email_employee = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as EMPLOYEE user", function(done){
+ it('Login as EMPLOYEE user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_employee,
- driver : driver,
+ application_host,
+ user_email: email_employee,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure that it is calendar indeed", function(done){
- driver.getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
+ })
+ })
- it("Create new leave request", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ it('Create new leave request', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
+ driver,
// The order matters here as we need to populate dropdown prior date filds
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : `${currentYear}-05-11`,
- },{
- selector : 'input#to',
- value : `${currentYear}-05-12`,
- }],
- message : /New leave request was added/,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: `${currentYear}-05-11`
+ },
+ {
+ selector: 'input#to',
+ value: `${currentYear}-05-12`
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment.utc(`${currentYear}-05-12`)],
- halfs_1st_days : [moment.utc(`${currentYear}-05-11`)],
- type : 'pended',
+ driver,
+ full_days: [moment.utc(`${currentYear}-05-12`)],
+ halfs_1st_days: [moment.utc(`${currentYear}-05-11`)],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from EMPLOYEE account", function(done){
+ it('Logout from EMPLOYEE account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as an ADMIN user", function(done){
+ it('Login as an ADMIN user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_admin,
- driver : driver,
+ application_host,
+ user_email: email_admin,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make sure that newly created request is waiting for approval', function(done){
+ it('Make sure that newly created request is waiting for approval', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'tr[vpp="pending_for__'+email_employee+'"] .btn-warning',
- value : "Reject",
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ 'tr[vpp="pending_for__' + email_employee + '"] .btn-warning',
+ value: 'Reject'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Approve newly added leave request", function(done){
+ it('Approve newly added leave request', function(done) {
driver
- .findElement(By.css(
- 'tr[vpp="pending_for__'+email_employee+'"] .btn-success'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(
+ By.css('tr[vpp="pending_for__' + email_employee + '"] .btn-success')
+ )
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
-
- it("Open department settings page", function(done){
- open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Obtain employee ID from department managment page", function(done){
- driver.findElement(
- By.css('select[name="boss_id__new"] option:nth-child(2)')
- )
- .then(function(el){ return el.getAttribute('value') })
- .then(function(value){
- employee_user_id = value;
- expect( employee_user_id ).to.match(/^\d+$/);
- done();
- });
- });
+ it('Open department settings page', function(done) {
+ open_page_func({
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Obtain employee ID from department managment page', function(done) {
+ driver
+ .findElement(By.css('select[name="manager_id__new"] option:nth-child(2)'))
+ .then(function(el) {
+ return el.getAttribute('value')
+ })
+ .then(function(value) {
+ employee_user_id = value
+ expect(employee_user_id).to.match(/^\d+$/)
+ done()
+ })
+ })
- it("Open user editing page for Employee", function(done){
+ it('Open user editing page for Employee', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+employee_user_id+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + employee_user_id + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("... and revoke her time off", function(done){
+ it('... and revoke her time off', function(done) {
driver
- .findElement(By.css(
- 'button.revoke-btn'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(By.css('button.revoke-btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure newly revoked request is shown for approval", function(done){
+ it('Make sure newly revoked request is shown for approval', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'tr[vpp="pending_for__'+email_employee+'"] .btn-warning',
- value : "Reject",
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ 'tr[vpp="pending_for__' + email_employee + '"] .btn-warning',
+ value: 'Reject'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Approve revoke request", function(done){
+ it('Approve revoke request', function(done) {
driver
- .findElement(By.css(
- 'tr[vpp="pending_for__'+email_employee+'"] .btn-success'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(
+ By.css('tr[vpp="pending_for__' + email_employee + '"] .btn-success')
+ )
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/ovelapping_bookings.js b/t/integration/leave_request/ovelapping_bookings.js
index df96ee40f..9364b6b7b 100644
--- a/t/integration/leave_request/ovelapping_bookings.js
+++ b/t/integration/leave_request/ovelapping_bookings.js
@@ -1,23 +1,22 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- until = require('selenium-webdriver').until,
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user'),
- config = require('../../lib/config'),
- application_host = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const until = require('selenium-webdriver').until;
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const check_booking_func = require('../../lib/check_booking_on_calendar');
+ const add_new_user_func = require('../../lib/add_new_user');
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host()
/*
* Scenario to go in this test:
@@ -31,131 +30,141 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Overlapping bookings', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Overlapping bookings', function() {
+ this.timeout(config.get_execution_timeout())
- var non_admin_user_email, new_user_email, driver;
+ let non_admin_user_email, new_user_email, driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ new_user_email = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- new_user_email = data.email;
- driver = data.driver;
- done();
- });
- });
-
- it("Create new non-admin user", function(done){
+ })
+
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin acount", function(done){
+ it('Logout from admin acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as non-admin user", function(done){
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure that it is calendar indeed", function(done){
- driver
- .getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
-
- it("Request new leave", function(done){
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
+ })
+ })
+
+ it('Request new leave', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-16',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-16'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-15'), moment('2015-06-16')],
- type : 'pended',
+ driver,
+ full_days: [moment('2015-06-15'), moment('2015-06-16')],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to request overlapping leave request", function(done){
+ it('Try to request overlapping leave request', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-16',
- },{
- selector : 'input#to',
- value : '2015-06-17',
- }],
- message : /Failed to create a leave request/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-16'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-17'
+ }
+ ],
+ message: /Failed to create a leave request/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/ovelapping_bookings_halfs.js b/t/integration/leave_request/ovelapping_bookings_halfs.js
index 520d4101e..74cbd8a35 100644
--- a/t/integration/leave_request/ovelapping_bookings_halfs.js
+++ b/t/integration/leave_request/ovelapping_bookings_halfs.js
@@ -1,23 +1,22 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- until = require('selenium-webdriver').until,
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user');
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const until = require('selenium-webdriver').until;
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host();
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const check_booking_func = require('../../lib/check_booking_on_calendar');
+ const add_new_user_func = require('../../lib/add_new_user')
/*
* Scenario to go in this test:
@@ -36,236 +35,273 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Overlapping leaverequest (with halfs)', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Overlapping leaverequest (with halfs)', function() {
+ this.timeout(config.get_execution_timeout())
- var non_admin_user_email, new_user_email, driver;
+ let non_admin_user_email, new_user_email, driver
- test.it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ new_user_email = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- new_user_email = data.email;
- done();
- });
- });
+ })
- it("Create new non-admin user", function(done){
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin acount", function(done){
+ it('Logout from admin acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as non-admin user", function(done){
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure that it is calendar indeed", function(done){
- driver
- .getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
+ })
+ })
- it("Request new leave", function(done){
+ it('Request new leave', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2015-06-16',
- },{
- selector : 'input#to',
- value : '2015-06-17',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-16'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-17'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-17')],
- halfs_1st_days : [moment('2015-06-16')],
- type : 'pended',
+ driver,
+ full_days: [moment('2015-06-17')],
+ halfs_1st_days: [moment('2015-06-16')],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to request overlapping leave request (new request overlaps with half by the full end)", function(done){
+ it('Try to request overlapping leave request (new request overlaps with half by the full end)', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-16',
- }],
- message : /Failed to create a leave request/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-16'
+ }
+ ],
+ message: /Failed to create a leave request/
+ }).then(function() {
+ done()
+ })
+ })
+ })
+
+ it(
+ "Try to create new request that overlaps with existing one: new request's " +
+ 'half end colides with full part of existing one',
+ function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
})
- .then(function(){ done() });
- });
- });
-
- it("Try to create new request that overlaps with existing one: new request's " +
- "half end colides with full part of existing one", function(done){
- driver
- .findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
-
- // Create new leave request
- .then(function(){
-
- // This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
- submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2015-06-17',
- },{
- selector : 'input#to',
- value : '2015-06-18',
- }],
- message : /Failed to create a leave request/,
+ // Create new leave request
+ .then(function() {
+ // This is very important line when working with Bootstrap modals!
+ driver.sleep(1000)
+
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-17'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-18'
+ }
+ ],
+ message: /Failed to create a leave request/
+ }).then(function() {
+ done()
+ })
})
- .then(function(){ done() });
- });
- });
+ }
+ )
- it("Try to create new leave request that colides with existing by halfs", function(done){
+ it('Try to create new leave request that colides with existing by halfs', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-16',
- }],
- message : /Failed to create a leave request/,
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-16'
+ }
+ ],
+ message: /Failed to create a leave request/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("And create correct one", function(done){
+ it('And create correct one', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="3"]',
- value : "3",
- },{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-16',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="3"]',
+ value: '3'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-16'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-15'),moment('2015-06-16'),moment('2015-06-17')],
- type : 'pended',
+ driver,
+ full_days: [
+ moment('2015-06-15'),
+ moment('2015-06-16'),
+ moment('2015-06-17')
+ ],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/rendering_of_halves.js b/t/integration/leave_request/rendering_of_halves.js
index 6d39a352c..21c865471 100644
--- a/t/integration/leave_request/rendering_of_halves.js
+++ b/t/integration/leave_request/rendering_of_halves.js
@@ -1,78 +1,70 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- until = require('selenium-webdriver').until,
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- add_new_user_func = require('../../lib/add_new_user');
-
-
-describe('Ensure that leaves with not full days are rendered properly', function(){
-
- this.timeout( config.get_execution_timeout() );
-
- var non_admin_user_email, new_user_email, driver;
-
- test.it('Create new company', done => {
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const until = require('selenium-webdriver').until;
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host();
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const add_new_user_func = require('../../lib/add_new_user')
+
+describe('Ensure that leaves with not full days are rendered properly', function() {
+ this.timeout(config.get_execution_timeout())
+
+ let non_admin_user_email, new_user_email, driver
+
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(data => {
+ driver = data.driver
+ new_user_email = data.email
+ done()
})
- .then(data => {
- driver = data.driver;
- new_user_email = data.email;
- done();
- });
- });
+ })
- it("Create new non-admin user", done => {
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(data => {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(data =>{
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin acount", done => {
+ it('Logout from admin acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as non-admin user", done => {
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(() => done())
+ })
- it("Open calendar page", done =>{
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(() => done())
+ })
- it("Request new partial leave: morning to afternoon", done => {
+ it('Request new partial leave: morning to afternoon', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
@@ -81,30 +73,36 @@ describe('Ensure that leaves with not full days are rendered properly', function
.then(() => driver.sleep(1000))
// Create new leave request
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2015-06-16',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="3"]',
- value : "3",
- },{
- selector : 'input#to',
- value : '2015-06-17',
- }],
- message : /New leave request was added/,
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-16'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="3"]',
+ value: '3'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-17'
+ }
+ ],
+ message: /New leave request was added/
})
)
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Request new partial leave: afternoon to morning", done => {
+ it('Request new partial leave: afternoon to morning', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
@@ -113,31 +111,36 @@ describe('Ensure that leaves with not full days are rendered properly', function
.then(() => driver.sleep(1000))
// Create new leave request
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="3"]',
- value : "3",
- },{
- selector : 'input#from',
- value : '2015-06-23',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#to',
- value : '2015-06-24',
- }],
- message : /New leave request was added/,
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="3"]',
+ value: '3'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-23'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-24'
+ }
+ ],
+ message: /New leave request was added/
})
)
- .then(() => done());
- });
-
+ .then(() => done())
+ })
- it("Request just morning", done => {
+ it('Request just morning', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
@@ -146,30 +149,36 @@ describe('Ensure that leaves with not full days are rendered properly', function
.then(() => driver.sleep(1000))
// Create new leave request
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2015-06-09',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="1"]',
- value : "1",
- },{
- selector : 'input#to',
- value : '2015-06-09',
- }],
- message : /New leave request was added/,
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-09'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="1"]',
+ value: '1'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-09'
+ }
+ ],
+ message: /New leave request was added/
})
)
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Request just multi days leave starting next afternoon", done => {
+ it('Request just multi days leave starting next afternoon', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
@@ -178,126 +187,162 @@ describe('Ensure that leaves with not full days are rendered properly', function
.then(() => driver.sleep(1000))
// Create new leave request
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="3"]',
- value : "3",
- },{
- selector : 'input#from',
- value : '2015-06-09',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="1"]',
- value : "1",
- },{
- selector : 'input#to',
- value : '2015-06-11',
- },{
- selector : 'select[name="leave_type"]',
- option_selector : 'option[data-tom-index="1"]',
- }],
- message : /New leave request was added/,
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="3"]',
+ value: '3'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-09'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="1"]',
+ value: '1'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-11'
+ },
+ {
+ selector: 'select[name="leave_type"]',
+ option_selector: 'option[data-tom-index="1"]'
+ }
+ ],
+ message: /New leave request was added/
})
)
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Go to my requests page", done => {
+ it('Go to my requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host + 'requests/',
+ driver
+ }).then(() => done())
+ })
- it("Ensure that both new leave requests are listed and both are marked as partial", done => {
+ it('Ensure that both new leave requests are listed and both are marked as partial', function(done) {
driver
- .findElements(By.css('table.user-requests-table td[data-tom-leave-dates="1"]'))
+ .findElements(
+ By.css('table.user-requests-table td[data-tom-leave-dates="1"]')
+ )
.then(els => {
- expect(els.length, 'Ensure two elements with leave dates were found').to.be.equal(4);
- return Promise.map(els, (el => el.getText()));
+ expect(
+ els.length,
+ 'Ensure two elements with leave dates were found'
+ ).to.be.equal(4)
+ return Promise.map(els, el => el.getText())
})
.then(dates_str => {
- expect(dates_str.sort(), 'Ensure that date ranges values are as expected')
- .to.be.deep.equal([
- '2015-06-09 (afternoon) 2015-06-11',
- '2015-06-09 (morning) 2015-06-09',
- '2015-06-16 (morning) 2015-06-17 (afternoon)',
- '2015-06-23 (afternoon) 2015-06-24 (morning)'
- ]);
- done();
- });
- });
+ expect(
+ dates_str.sort(),
+ 'Ensure that date ranges values are as expected'
+ ).to.be.deep.equal([
+ '2015-06-09 (afternoon) 2015-06-11',
+ '2015-06-09 (morning) 2015-06-09',
+ '2015-06-16 (morning) 2015-06-17 (afternoon)',
+ '2015-06-23 (afternoon) 2015-06-24 (morning)'
+ ])
+ done()
+ })
+ })
- it('Ensure tooltips include leave type name', done => {
+ it('Ensure tooltips include leave type name', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver,
- })
- .then(() => Promise.all(
- [9, 10, 11, 16, 17, 23, 24].map(day => driver.findElement(By.css(`.month_June td.half_1st.day_${day} span`)).then(el => el.getAttribute('data-original-title')))
- ))
- .then(([title9, title10, title11, title16, title17, title23, title24]) => {
- expect(title9).to.be.eq('Holiday (morning) Sick Leave (afternoon): New absence waiting approval');
- expect(title10).to.be.eq('Sick Leave: New absence waiting approval');
- expect(title11).to.be.eq('Sick Leave: New absence waiting approval');
- expect(title16).to.be.eq('Holiday (morning) : New absence waiting approval');
- expect(title17).to.be.eq('Holiday (afternoon): New absence waiting approval');
- expect(title23).to.be.eq('Holiday (afternoon): New absence waiting approval');
- expect(title24).to.be.eq('Holiday (morning) : New absence waiting approval');
- return Promise.resolve(1);
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
})
- .then(function(){ done() });
- });
+ .then(() =>
+ Promise.all(
+ [9, 10, 11, 16, 17, 23, 24].map(day =>
+ driver
+ .findElement(By.css(`.month_June td.half_1st.day_${day} span`))
+ .then(el => el.getAttribute('data-original-title'))
+ )
+ )
+ )
+ .then(
+ ([title9, title10, title11, title16, title17, title23, title24]) => {
+ expect(title9).to.be.eq(
+ 'Holiday (morning) Sick Leave (afternoon): New absence waiting approval'
+ )
+ expect(title10).to.be.eq('Sick Leave: New absence waiting approval')
+ expect(title11).to.be.eq('Sick Leave: New absence waiting approval')
+ expect(title16).to.be.eq(
+ 'Holiday (morning) : New absence waiting approval'
+ )
+ expect(title17).to.be.eq(
+ 'Holiday (afternoon): New absence waiting approval'
+ )
+ expect(title23).to.be.eq(
+ 'Holiday (afternoon): New absence waiting approval'
+ )
+ expect(title24).to.be.eq(
+ 'Holiday (morning) : New absence waiting approval'
+ )
+ return Promise.resolve(1)
+ }
+ )
+ .then(function() {
+ done()
+ })
+ })
- it("Logout from non-admin account", done => {
+ it('Logout from non-admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as admin user", done => {
+ it('Login as admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : new_user_email,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: new_user_email,
+ driver
+ }).then(() => done())
+ })
- it("Go to my requests page", done => {
+ it('Go to my requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host + 'requests/',
+ driver
+ }).then(() => done())
+ })
- it("Ensure that both new leave requests are listed for approval and both are marked as partial", done => {
+ it('Ensure that both new leave requests are listed for approval and both are marked as partial', function(done) {
driver
- .findElements(By.css('table.requests-to-approve-table td[data-tom-leave-dates="1"]'))
+ .findElements(
+ By.css('table.requests-to-approve-table td[data-tom-leave-dates="1"]')
+ )
.then(els => {
- expect(els.length, 'Ensure two elements with leave dates were found').to.be.equal(4);
- return Promise.map(els, (el => el.getText()));
+ expect(
+ els.length,
+ 'Ensure two elements with leave dates were found'
+ ).to.be.equal(4)
+ return Promise.map(els, el => el.getText())
})
.then(dates_str => {
- expect(dates_str.sort(), 'Ensure that date ranges values are as expected')
- .to.be.deep.equal([
- '2015-06-09 (afternoon) 2015-06-11',
- '2015-06-09 (morning) 2015-06-09',
- '2015-06-16 (morning) 2015-06-17 (afternoon)',
- '2015-06-23 (afternoon) 2015-06-24 (morning)'
- ]);
- done();
- });
- });
-
- after(done => {
- driver.quit().then(() => done());
- });
+ expect(
+ dates_str.sort(),
+ 'Ensure that date ranges values are as expected'
+ ).to.be.deep.equal([
+ '2015-06-09 (afternoon) 2015-06-11',
+ '2015-06-09 (morning) 2015-06-09',
+ '2015-06-16 (morning) 2015-06-17 (afternoon)',
+ '2015-06-23 (afternoon) 2015-06-24 (morning)'
+ ])
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/leave_request/request_leaves_for_other_users.js b/t/integration/leave_request/request_leaves_for_other_users.js
index fc0b66435..93ebc742a 100644
--- a/t/integration/leave_request/request_leaves_for_other_users.js
+++ b/t/integration/leave_request/request_leaves_for_other_users.js
@@ -1,21 +1,20 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- until = require('selenium-webdriver').until,
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- add_new_user_func = require('../../lib/add_new_user'),
- new_department_form_id = '#add_new_department_form';
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const Promise = require('bluebird')
+const until = require('selenium-webdriver').until
+const login_user_func = require('../../lib/login_with_user')
+const register_new_user_func = require('../../lib/register_new_user')
+const logout_user_func = require('../../lib/logout_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const add_new_user_func = require('../../lib/add_new_user')
+const new_department_form_id = '#add_new_department_form'
/*
* Scenario to go in this test:
@@ -34,285 +33,326 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Request leave for outher users', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Request leave for other users', function() {
+ this.timeout(config.get_execution_timeout())
- var ordenary_user_email, line_manager_email, admin_email,
- ordenary_user_id, driver;
+ let ordenary_user_email,
+ line_manager_email,
+ admin_email,
+ ordenary_user_id,
+ driver
- it("Create new company", function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ admin_email = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- admin_email = data.email;
- done();
- });
- });
-
- it("Create new line manager user", function(done){
+ })
+
+ it('Create new line manager user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(function(data){
- line_manager_email = data.new_user_email;
+ application_host,
+ driver
+ }).then(function(data) {
+ line_manager_email = data.new_user_email
done()
- });
- });
+ })
+ })
- it("Create new ordanry user", function(done){
+ it('Create new ordanry user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ ordenary_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- ordenary_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Open department management page", function(done){
+ it('Open department management page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Save ID of ordenry user", function(done){
- driver
- .findElement(
- By.css('select[name="boss_id__new"] option:nth-child(3)')
- )
- .then(function(el){ return el.getAttribute('value') })
- .then(function(value){
- ordenary_user_id = value;
- expect( ordenary_user_id ).to.match(/^\d+$/);
- done();
- });
- });
-
- it("Add new department and make its approver to be newly added " +
- "line manager (she is second in a list as users are ordered by AZ)", function(done){
+ it('Save ID of ordenry user', function(done) {
driver
- .findElement(By.css('#add_new_department_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
+ .findElement(By.css('select[name="manager_id__new"] option:nth-child(3)'))
+ .then(function(el) {
+ return el.getAttribute('value')
+ })
+ .then(function(value) {
+ ordenary_user_id = value
+ expect(ordenary_user_id).to.match(/^\d+$/)
+ done()
+ })
+ })
- // This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
-
- submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_department_form_id+' input[name="name__new"]',
- // Just to make sure it is always first in the lists
- value : 'AAAAA',
- },{
- selector : new_department_form_id+' select[name="allowance__new"]',
- option_selector : 'option[value="15"]',
- value : '15',
- },{
- selector : new_department_form_id+' select[name="boss_id__new"]',
- option_selector : 'select[name="boss_id__new"] option:nth-child(2)',
- }],
- submit_button_selector : new_department_form_id+' button[type="submit"]',
- message : /Changes to departments were saved/,
+ it(
+ 'Add new department and make its approver to be newly added ' +
+ 'line manager (she is second in a list as users are ordered by AZ)',
+ function(done) {
+ driver
+ .findElement(By.css('#add_new_department_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
+ // This is very important line when working with Bootstrap modals!
+ driver.sleep(1000)
+
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: new_department_form_id + ' input[name="name__new"]',
+ // Just to make sure it is always first in the lists
+ value: 'AAAAA'
+ },
+ {
+ selector:
+ new_department_form_id + ' select[name="allowance__new"]',
+ option_selector: 'option[value="15"]',
+ value: '15'
+ },
+ {
+ selector:
+ new_department_form_id + ' select[name="manager_id__new"]',
+ option_selector:
+ 'select[name="manager_id__new"] option:nth-child(2)'
+ }
+ ],
+ submit_button_selector:
+ new_department_form_id + ' button[type="submit"]',
+ message: /Changes to departments were saved/
+ }).then(function() {
+ done()
+ })
})
- .then(function(){ done() });
- });
- });
+ }
+ )
- it("Open user editing page for ordenry user", function(done){
+ it('Open user editing page for ordenry user', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+ordenary_user_id+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + ordenary_user_id + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure it is part of the newly added department", function(done){
+ it('And make sure it is part of the newly added department', function(done) {
submit_form_func({
- submit_button_selector : 'button#save_changes_btn',
- driver : driver,
- form_params : [{
- selector : 'select[name="department"]',
- // Newly added department should be first in the list as it is
- // sorted by AZ and department started with AA
- option_selector : 'select[name="department"] option:nth-child(1)',
- }],
- message : /Details for .* were updated/,
+ submit_button_selector: 'button#save_changes_btn',
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="department"]',
+ // Newly added department should be first in the list as it is
+ // sorted by AZ and department started with AA
+ option_selector: 'select[name="department"] option:nth-child(1)'
+ }
+ ],
+ message: /Details for .* were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from admin acount", function(done){
+ it('Logout from admin acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
})
- it("Login as ordenary user", function(done){
+ it('Login as ordenary user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : ordenary_user_email,
- driver : driver,
+ application_host,
+ user_email: ordenary_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure that user cannot select other users when requesting new leave", function(done){
+ it('And make sure that user cannot select other users when requesting new leave', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
driver
- .isElementPresent(By.css('select#employee'))
- .then(function(is_present){
- expect(is_present).to.be.equal(false);
- done();
- });
- });
- });
-
- it("Logout from ordenary acount", function(done){
+ .findElements(By.css('select#employee'))
+ .then(found => !!found.length)
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(false)
+ done()
+ })
+ })
+ })
+
+ it('Logout from ordenary acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as line manager user", function(done){
+ it('Login as line manager user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : line_manager_email,
- driver : driver,
+ application_host,
+ user_email: line_manager_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("And make sure that user can select herself and ordenary user (because she "+
- "belongs to the department managed by current line manager)", function(done){
- driver
- .findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
+ })
- // This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ it(
+ 'And make sure that user can select herself and ordenary user (because she ' +
+ 'belongs to the department managed by current line manager)',
+ function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
+ // This is very important line when working with Bootstrap modals!
+ driver.sleep(1000)
+
+ // Make sure there is a drop down with users
+ driver
+ .findElements(By.css('select#employee'))
+ .then(found => !!found.length)
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(true)
+ done()
+ })
+ })
+ }
+ )
- // Make sure there is a drop down with users
- driver
- .isElementPresent(By.css('select#employee'))
- .then(function(is_present){
- expect(is_present).to.be.equal(true);
- done();
- });
- });
- });
-
- it("... make sure there are two records in it", function(done){
+ it('... make sure there are two records in it', function(done) {
driver
.findElements(By.css('select#employee option'))
- .then(function(elements){
- expect( elements.length ).to.be.equal(2);
- done();
- });
- });
+ .then(function(elements) {
+ expect(elements.length).to.be.equal(2)
+ done()
+ })
+ })
- it("Make sure ordenary user is in that drop down list", function(done){
+ it('Make sure ordenary user is in that drop down list', function(done) {
driver
- .findElement(
- By.css('select#employee option:nth-child(2)')
- )
- .then(function(el){ return el.getInnerHtml() })
- .then(function(text){
- expect( text ).to.match( new RegExp(
- ordenary_user_email.substring(0,ordenary_user_email.lastIndexOf('@'))
- ));
- done();
- });
- });
-
- it("Logout from ordenary acount", function(done){
+ .findElement(By.css('select#employee option:nth-child(2)'))
+ .then(function(el) {
+ return el.getInnerHtml()
+ })
+ .then(function(text) {
+ expect(text).to.match(
+ new RegExp(
+ ordenary_user_email.substring(
+ 0,
+ ordenary_user_email.lastIndexOf('@')
+ )
+ )
+ )
+ done()
+ })
+ })
+
+ it('Logout from ordenary acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as admin user", function(done){
+ it('Login as admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : admin_email,
- driver : driver,
+ application_host,
+ user_email: admin_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure that user can select all three users", function(done){
+ it('And make sure that user can select all three users', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
// Make sure there is a drop down with users
driver
- .isElementPresent(By.css('select#employee'))
- .then(function(is_present){
- expect(is_present).to.be.equal(true);
- });
+ .findElements(By.css('select#employee'))
+ .then(found => !!found.length)
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(true)
+ })
// Make sure there are three records in it (all users for company)
driver
.findElements(By.css('select#employee option'))
- .then(function(elements){
- expect( elements.length ).to.be.equal(3);
- done();
- });
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ .then(function(elements) {
+ expect(elements.length).to.be.equal(3)
+ done()
+ })
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/try_to_overbook_allowance.js b/t/integration/leave_request/try_to_overbook_allowance.js
index fdc13a1de..1aadaaeee 100644
--- a/t/integration/leave_request/try_to_overbook_allowance.js
+++ b/t/integration/leave_request/try_to_overbook_allowance.js
@@ -1,23 +1,21 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- until = require('selenium-webdriver').until,
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user');
-
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const Promise = require('bluebird')
+const until = require('selenium-webdriver').until
+const login_user_func = require('../../lib/login_with_user')
+const register_new_user_func = require('../../lib/register_new_user')
+const logout_user_func = require('../../lib/logout_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const check_elements_func = require('../../lib/check_elements')
+const check_booking_func = require('../../lib/check_booking_on_calendar')
+const add_new_user_func = require('../../lib/add_new_user')
/*
* Scenario to go in this test:
@@ -29,133 +27,138 @@ var test = require('selenium-webdriver/testing'),
*
* */
+describe('Try to book more holidays then in allowance', function() {
+ this.timeout(config.get_execution_timeout())
-describe('Try to book more holidays then in allowance', function(){
-
- this.timeout( config.get_execution_timeout() );
-
- var non_admin_user_email, new_user_email, driver;
+ let non_admin_user_email, new_user_email, driver
- it("Create new company", function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ new_user_email = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- new_user_email = data.email;
- driver = data.driver;
- done();
- });
- });
-
- it("Create new non-admin user", function(done){
+ })
+
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as non-admin user", function(done){
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2015&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2015&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("And make sure that it is calendar indeed", function(done){
- driver.
- getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
+ })
- it("Request new leave", function(done){
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
+ })
+ })
+ it('Request new leave', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){
- return el.click();
+ .then(function(el) {
+ return el.click()
})
// Following code is to ensure that non admin user can request leave only for
// herself
- .then(function(){
- return driver.isElementPresent(By.css('select#employee'))
- .then(function(is_present){
- expect(is_present).to.be.equal(false);
- });
+ .then(function() {
+ return driver
+ .findElements(By.css('select#employee'))
+ .then(found => !!found.length)
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(false)
+ })
})
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
+ driver,
// The order matters here as we need to populate dropdown prior date filds
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2016-06-15',
- },{
- selector : 'input#to',
- value : '2016-07-16',
- }],
- should_be_successful : false,
- message : /Failed to create a leave request/,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2016-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2016-07-16'
+ }
+ ],
+ should_be_successful: false,
+ message: /Failed to create a leave request/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Check that correct warning messages are shown", function(done){
- driver
- .findElements( By.css('div.alert') )
- .then(function(els){
-
- Promise.all(
- _.map(els, function(el){ return el.getText(); })
- )
- .then(function(texts){
- expect(
- _.any(texts, function(text){ return /Requested absence is longer than remaining allowance/.test(text); })
- ).to.be.equal(true);
-
- done();
- });
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ it('Check that correct warning messages are shown', function(done) {
+ driver.findElements(By.css('div.alert')).then(function(els) {
+ Promise.all(
+ _.map(els, function(el) {
+ return el.getText()
+ })
+ ).then(function(texts) {
+ expect(
+ _.any(texts, function(text) {
+ return /Requested absence is longer than remaining allowance/.test(
+ text
+ )
+ })
+ ).to.be.equal(true)
+
+ done()
+ })
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_request/user_auto_approve.js b/t/integration/leave_request/user_auto_approve.js
index c002bc490..90a46668c 100644
--- a/t/integration/leave_request/user_auto_approve.js
+++ b/t/integration/leave_request/user_auto_approve.js
@@ -1,22 +1,21 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- until = require('selenium-webdriver').until,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- add_new_user_func = require('../../lib/add_new_user'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- register_new_user_func = require('../../lib/register_new_user'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- some_weekday_date = '2015-06-17';
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const until = require('selenium-webdriver').until;
+ const Promise = require('bluebird');
+ const expect = require('chai').expect;
+ const add_new_user_func = require('../../lib/add_new_user');
+ const check_elements_func = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const login_user_func = require('../../lib/login_with_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const some_weekday_date = '2015-06-17'
/*
* Scenario:
@@ -38,330 +37,349 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Auto approvals', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Auto approvals', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, email_A, email_B, user_id_A, user_id_B;
+ let driver, email_A, email_B, user_id_A, user_id_B
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
-
- it("Create second user B", function(done){
+ })
+
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about admin user A", function(done){
+ it('Obtain information about admin user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Open details page for user B", function(done){
+ it('Open details page for user B', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_B + '/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Update settings to make all its leave requests auto approved', function(done){
+ it('Update settings to make all its leave requests auto approved', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="auto_approve"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .+ were updated/,
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="auto_approve"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .+ were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from admin user", function(done){
+ it('Logout from admin user', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as regular user B", function(done){
+ it('Login as regular user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Submit new leave requesti from user B", function(done){
+ it('Submit new leave requesti from user B', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : some_weekday_date,
- },{
- selector : 'input#to',
- value : some_weekday_date,
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: some_weekday_date
+ },
+ {
+ selector: 'input#to',
+ value: some_weekday_date
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Ensure that new leave went straight to Approved status", function(done){
+ it('Ensure that new leave went straight to Approved status', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(elements){
- expect(elements.length).to.be.eq(1);
- return elements[0].getText();
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(1)
+ return elements[0].getText()
})
- .then(function(status){
- expect( status ).to.be.eq('Approved');
- done();
- });
- });
+ .then(function(status) {
+ expect(status).to.be.eq('Approved')
+ done()
+ })
+ })
- it("Logout from user B", function(done){
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as admin user A", function(done){
+ it('Login as admin user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that there is no pending leave requests', function(done){
- driver
- .findElements(By.css( '.btn-warning' ))
- .then(function(elements){
- expect( elements.length ).to.be.eq(0);
- done();
- })
- });
+ it('Ensure that there is no pending leave requests', function(done) {
+ driver.findElements(By.css('.btn-warning')).then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
- it("Open email audit page", function( done ){
+ it('Open email audit page', function(done) {
open_page_func({
- url : application_host + 'audit/email/',
- driver : driver,
+ url: application_host + 'audit/email/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure there were two emails regarding auto-approved leaves', function(done){
+ it('Ensure there were two emails regarding auto-approved leaves', function(done) {
driver
- .findElements( By.css('tr.vpp-email-audit-entry-header a.collapsed') )
- .then(function(elements){
- return Promise.map(
- [elements[0], elements[1]],
- function(el){ return el.getText() }
- );
+ .findElements(By.css('tr.vpp-email-audit-entry-header a.collapsed'))
+ .then(function(elements) {
+ return Promise.map([elements[0], elements[1]], function(el) {
+ return el.getText()
+ })
})
- .then(function(subjects){
- expect(subjects).to.contain('New leave was added and auto approved.');
- expect(subjects).to.contain('New leave was added');
- done();
+ .then(function(subjects) {
+ expect(subjects).to.contain('New leave was added and auto approved.')
+ expect(subjects).to.contain('New leave was added')
+ done()
})
- });
+ })
- it("Logout from admin user", function(done){
+ it('Logout from admin user', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as regular user B", function(done){
+ it('Login as regular user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Revoke request', function(done){
+ it('Revoke request', function(done) {
driver
- .findElement(By.css(
- 'button.revoke-btn'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(By.css('button.revoke-btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){
- return driver.findElement( By.css('.alert-success') )
- .then(function(el){
- expect(el).to.be.ok;
- return Promise.resolve(1);
- })
+ .then(function() {
+ return driver.findElement(By.css('.alert-success')).then(function(el) {
+ expect(el).to.be.ok
+ return Promise.resolve(1)
+ })
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Ensure that it is gone without need to be approved", function(done){
+ it('Ensure that it is gone without need to be approved', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(elements){
- expect(elements.length).to.be.eq(0);
- done();
- });
- });
-
- it("Logout from user B", function(done){
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as admin user A", function(done){
+ it('Login as admin user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open user B absences section', function(done){
+ it('Open user B absences section', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_B + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Ensure that user B does not have any leaves", function(done){
+ it('Ensure that user B does not have any leaves', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(elements){
- expect(elements.length).to.be.eq(0);
- done();
- });
- });
-
- it("Open requests page", function( done ){
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that there is no pending leave requests', function(done){
- driver
- .findElements(By.css( '.btn-warning' ))
- .then(function(elements){
- expect( elements.length ).to.be.eq(0);
- done();
- })
- });
+ it('Ensure that there is no pending leave requests', function(done) {
+ driver.findElements(By.css('.btn-warning')).then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
- it("Open email audit page", function( done ){
+ it('Open email audit page', function(done) {
open_page_func({
- url : application_host + 'audit/email/',
- driver : driver,
+ url: application_host + 'audit/email/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure there were two emails regarding auto-approved leaves', function(done){
+ it('Ensure there were two emails regarding auto-approved leaves', function(done) {
driver
- .findElements( By.css('tr.vpp-email-audit-entry-header a.collapsed') )
- .then(function(elements){
- return Promise.map(
- [elements[0], elements[1]],
- function(el){ return el.getText() }
- );
+ .findElements(By.css('tr.vpp-email-audit-entry-header a.collapsed'))
+ .then(function(elements) {
+ return Promise.map([elements[0], elements[1]], function(el) {
+ return el.getText()
+ })
})
- .then(function(subjects){
- expect(subjects).to.contain('Leave was revoked and auto approved');
- expect(subjects).to.contain('Leave was revoked');
- done();
+ .then(function(subjects) {
+ expect(subjects).to.contain('Leave was revoked and auto approved')
+ expect(subjects).to.contain('Leave was revoked')
+ done()
})
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_type/colouring_on_calendar.js b/t/integration/leave_type/colouring_on_calendar.js
index f9007a704..fa923cdc0 100644
--- a/t/integration/leave_type/colouring_on_calendar.js
+++ b/t/integration/leave_type/colouring_on_calendar.js
@@ -1,20 +1,18 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- until = require('selenium-webdriver').until,
- register_new_user_func = require('../../lib/register_new_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- By = require('selenium-webdriver').By,
- config = require('../../lib/config'),
- Bluebird = require('bluebird'),
- expect = require('chai').expect,
- application_host = config.get_application_host(),
- leave_type_edit_form_id='#leave_type_edit_form',
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const until = require('selenium-webdriver').until;
+ const register_new_user_func = require('../../lib/register_new_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const By = require('selenium-webdriver').By;
+ const config = require('../../lib/config');
+ const Bluebird = require('bluebird');
+ const expect = require('chai').expect;
+ const application_host = config.get_application_host();
+ const leave_type_edit_form_id = '#leave_type_edit_form';
+ const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Aim of the scenario: to ensure that half a days are highlighted correctly
@@ -42,229 +40,273 @@ const
*
* */
-describe('Coloring of half days', function(){
-
- let driver, user_email, user_id,
- leave_type_holiday_id, leave_type_sick_id;
+describe('Coloring of half days', function() {
+ let driver, user_email, user_id, leave_type_holiday_id, leave_type_sick_id
- this.timeout( config.get_execution_timeout() );
+ this.timeout(config.get_execution_timeout())
- it("Performing registration process", function(done){
+ it('Performing registration process', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(data => {
+ driver = data.driver
+ user_email = data.email
+ done()
})
- .then(data => {
- driver = data.driver;
- user_email = data.email;
- done();
- });
- });
-
- it("Obtain information user", function(done){
+ })
+
+ it('Obtain information user', function(done) {
user_info_func({
- driver : driver,
- email : user_email,
+ driver,
+ email: user_email
+ }).then(data => {
+ user_id = data.user.id
+ done()
})
- .then(data => {
- user_id = data.user.id;
- done();
- });
- });
-
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email:user_email, year:2018})
- .then(() => open_page_func({ url:application_host,driver}))
+ })
+
+ it('Ensure user starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email: user_email, year: 2018 })
+ .then(() => open_page_func({ url: application_host, driver }))
.then(() => done())
- });
+ })
- it('Changes default color for Sick days to be "color 3"', done => {
+ it('Changes default color for Sick days to be "color 3"', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
- })
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id + ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] button.dropdown-toggle',
- dropdown_option : leave_type_edit_form_id + ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] [data-tom-color-picker-css-class="leave_type_color_3"]'
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
- }))
-
- // Capture Leave type IDs while we are on this page
- .then(() => driver.findElements(By.css('button.leavetype-remove-btn')))
- .then(btns => Bluebird.map(btns, btn => btn.getAttribute('value')))
- .then(ids => {
- leave_type_holiday_id = ids[0];
- leave_type_sick_id = ids[1];
-
- done();
- });
- });
-
- it('Go Calendar page', done => {
+ url: application_host + 'settings/general/',
+ driver
+ })
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] button.dropdown-toggle',
+ dropdown_option:
+ leave_type_edit_form_id +
+ ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] [data-tom-color-picker-css-class="leave_type_color_3"]'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
+ })
+ )
+
+ // Capture Leave type IDs while we are on this page
+ .then(() => driver.findElements(By.css('button.leavetype-remove-btn')))
+ .then(btns => Bluebird.map(btns, btn => btn.getAttribute('value')))
+ .then(ids => {
+ leave_type_holiday_id = ids[0]
+ leave_type_sick_id = ids[1]
+
+ done()
+ })
+ })
+
+ it('Go Calendar page', function(done) {
open_page_func({
- url : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host,
+ driver
+ }).then(() => done())
+ })
- it("Add absence: 2018-02-01 (afternoon) - 2018-02-02 (morning) Sick", done => {
+ it('Add absence: 2018-02-01 (afternoon) - 2018-02-02 (morning) Sick', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="3"]',
- },{
- selector : 'input#from',
- value : '2018-02-01',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="2"]',
- },{
- selector : 'input#to',
- value : '2018-02-02',
- },{
- selector : 'select#leave_type',
- option_selector : '[data-tom="Sick Leave"]'
- }],
- message : /New leave request was added/,
- }))
- .then(() => done());
- });
-
- it("Add absence: 2018-02-02 (afternoon) - 2018-02-02 (afternnon) : Holiday", done => {
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="3"]'
+ },
+ {
+ selector: 'input#from',
+ value: '2018-02-01'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="2"]'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-02-02'
+ },
+ {
+ selector: 'select#leave_type',
+ option_selector: '[data-tom="Sick Leave"]'
+ }
+ ],
+ message: /New leave request was added/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Add absence: 2018-02-02 (afternoon) - 2018-02-02 (afternnon) : Holiday', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="3"]',
- },{
- selector : 'input#from',
- value : '2018-02-02',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="3"]',
- },{
- selector : 'input#to',
- value : '2018-02-02',
- },{
- selector : 'select#leave_type',
- option_selector : '[data-tom="Holiday"]'
- }],
- message : /New leave request was added/,
- submit_button_selector : '#book_leave_modal button[type="submit"]'
- }))
- .then(() => done());
- });
-
- it("Add absence: 2018-02-08 (morning) - 2018-02-08 (morning) : Holiday (0.5 days)", done => {
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="3"]'
+ },
+ {
+ selector: 'input#from',
+ value: '2018-02-02'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="3"]'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-02-02'
+ },
+ {
+ selector: 'select#leave_type',
+ option_selector: '[data-tom="Holiday"]'
+ }
+ ],
+ message: /New leave request was added/,
+ submit_button_selector: '#book_leave_modal button[type="submit"]'
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Add absence: 2018-02-08 (morning) - 2018-02-08 (morning) : Holiday (0.5 days)', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- },{
- selector : 'input#from',
- value : '2018-02-08',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="2"]',
- },{
- selector : 'input#to',
- value : '2018-02-08',
- },{
- selector : 'select#leave_type',
- option_selector : '[data-tom="Holiday"]'
- }],
- message : /New leave request was added/,
- submit_button_selector : '#book_leave_modal button[type="submit"]'
- }))
- .then(() => done());
- });
-
- it("Add absence: 2018-02-13 (afternoon) - 2018-02-14 (morning) : Sick", done => {
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]'
+ },
+ {
+ selector: 'input#from',
+ value: '2018-02-08'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="2"]'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-02-08'
+ },
+ {
+ selector: 'select#leave_type',
+ option_selector: '[data-tom="Holiday"]'
+ }
+ ],
+ message: /New leave request was added/,
+ submit_button_selector: '#book_leave_modal button[type="submit"]'
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Add absence: 2018-02-13 (afternoon) - 2018-02-14 (morning) : Sick', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="3"]',
- },{
- selector : 'input#from',
- value : '2018-02-13',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="2"]',
- },{
- selector : 'input#to',
- value : '2018-02-14',
- },{
- selector : 'select#leave_type',
- option_selector : '[data-tom="Sick Leave"]'
- }],
- message : /New leave request was added/,
- submit_button_selector : '#book_leave_modal button[type="submit"]'
- }))
- .then(() => done());
- });
-
- it("Add absence: 2018-02-14 (afternoon) - 2018-02-15 (morning) : Holiday", done => {
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="3"]'
+ },
+ {
+ selector: 'input#from',
+ value: '2018-02-13'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="2"]'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-02-14'
+ },
+ {
+ selector: 'select#leave_type',
+ option_selector: '[data-tom="Sick Leave"]'
+ }
+ ],
+ message: /New leave request was added/,
+ submit_button_selector: '#book_leave_modal button[type="submit"]'
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Add absence: 2018-02-14 (afternoon) - 2018-02-15 (morning) : Holiday', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="3"]',
- },{
- selector : 'input#from',
- value : '2018-02-14',
- },{
- selector : 'select[name="to_date_part"]',
- option_selector : 'option[value="2"]',
- },{
- selector : 'input#to',
- value : '2018-02-15',
- },{
- selector : 'select#leave_type',
- option_selector : '[data-tom="Holiday"]'
- }],
- message : /New leave request was added/,
- submit_button_selector : '#book_leave_modal button[type="submit"]'
- }))
- .then(() => done());
- });
-
- it("Open requests page", function(done){
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="3"]'
+ },
+ {
+ selector: 'input#from',
+ value: '2018-02-14'
+ },
+ {
+ selector: 'select[name="to_date_part"]',
+ option_selector: 'option[value="2"]'
+ },
+ {
+ selector: 'input#to',
+ value: '2018-02-15'
+ },
+ {
+ selector: 'select#leave_type',
+ option_selector: '[data-tom="Holiday"]'
+ }
+ ],
+ message: /New leave request was added/,
+ submit_button_selector: '#book_leave_modal button[type="submit"]'
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host + 'requests/',
+ driver
+ }).then(() => done())
+ })
- it("Ensure that all absences are approved", function(done){
- driver.findElement(By.css('tr[vpp] .btn-success'))
+ it('Ensure that all absences are approved', function(done) {
+ driver
+ .findElement(By.css('tr[vpp] .btn-success'))
.then(el => el.click())
.then(() => driver.wait(until.elementLocated(By.css('h1')), 1000))
@@ -284,244 +326,406 @@ describe('Coloring of half days', function(){
.then(el => el.click())
.then(() => driver.wait(until.elementLocated(By.css('h1')), 1000))
- .then(() => done());
- });
+ .then(() => done())
+ })
- it('Go to callendar page and ensure that all half days cells have correct color classes', done =>{
+ it('Go to callendar page and ensure that all half days cells have correct color classes', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2018&show_full_year=1',
- driver : driver,
- })
-
- // Check Feb 1
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_1.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_1.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
-
- // Check Feb 2
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_2.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_2.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
+ url: application_host + 'calendar/?year=2018&show_full_year=1',
+ driver
+ })
+ // Check Feb 1
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_1.half_1st')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_1.half_2nd')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 2
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_2.half_1st')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_2.half_2nd')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 8
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_8.half_1st')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_8.half_2nd')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 13
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_13.half_1st')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_13.half_2nd')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 14
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_14.half_1st')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_14.half_2nd')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 15
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_15.half_1st')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css('table.month_February td.calendar_cell.day_15.half_2nd')
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
- // Check Feb 8
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_8.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_8.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- // Check Feb 13
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_13.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_13.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
-
- // Check Feb 14
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_14.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_14.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
-
- // Check Feb 15
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_15.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.month_February td.calendar_cell.day_15.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Go to Team view page and ensure that all half a day cells have correct color classes", done => {
+ it('Go to Team view page and ensure that all half a day cells have correct color classes', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?date=2018-02',
- driver : driver,
- })
-
- // Check Feb 1
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_1.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_1.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
-
- // Check Feb 2
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_2.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_2.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
-
- // Check Feb 8
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_8.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_8.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- // Check Feb 13
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_13.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_13.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
-
- // Check Feb 14
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_14.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_3/);
- return Bluebird.resolve();
- })
+ url: application_host + 'calendar/teamview/?date=2018-02',
+ driver
+ })
+ // Check Feb 1
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_1.half_1st'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_1.half_2nd'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 2
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_2.half_1st'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_2.half_2nd'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 8
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_8.half_1st'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_8.half_2nd'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 13
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_13.half_1st'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_13.half_2nd'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 14
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_14.half_1st'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_3/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_14.half_2nd'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ // Check Feb 15
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_15.half_1st'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).to.match(/leave_type_color_1/)
+ return Bluebird.resolve()
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id +
+ '"] td.calendar_cell.day_15.half_2nd'
+ )
+ )
+ )
+ .then(el => el.getAttribute('class'))
+ .then(cls => {
+ expect(cls).not.to.match(/leave_type_color_/)
+ return Bluebird.resolve()
+ })
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_14.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
-
- // Check Feb 15
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_15.half_1st')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).to.match(/leave_type_color_1/);
- return Bluebird.resolve();
- })
-
- .then(() => driver.findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id+'"] td.calendar_cell.day_15.half_2nd')))
- .then(el => el.getAttribute('class'))
- .then(cls => {
- expect(cls).not.to.match(/leave_type_color_/);
- return Bluebird.resolve();
- })
-
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("On Team view page ensure that days deducted from allowance are stated correctly", done => {
+ it('On Team view page ensure that days deducted from allowance are stated correctly', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?date=2018-02',
- driver : driver,
- })
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt, 'Ensure that system shows 2 days as deducted')
- .to.be.eql('2');
- done();
- });
- });
-
- it("Go to report page and for 2018-02 ensure that report contains correct summaries", done => {
+ url: application_host + 'calendar/teamview/?date=2018-02',
+ driver
+ })
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt, 'Ensure that system shows 2 days as deducted').to.be.eql(
+ '2'
+ )
+ done()
+ })
+ })
+
+ it('Go to report page and for 2018-02 ensure that report contains correct summaries', function(done) {
open_page_func({
- url : application_host + 'reports/allowancebytime/?start_date=2018-02&end_date=2018-02',
- driver : driver,
- })
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id}"]`)))
-
- .then(tr => Bluebird.join(
- tr.findElement(By.css('[data-vpp-deducted-days="1"]')),
- tr.findElement(By.css(`[data-vpp-leave-type-id="${leave_type_holiday_id}"]`)),
- tr.findElement(By.css(`[data-vpp-leave-type-id="${leave_type_sick_id}"]`)),
- (allowance_el, holiday_el, sick_el) => Bluebird.map([ allowance_el, holiday_el, sick_el ], el => el.getText())
- ))
- .then(stat => {
- expect(stat, 'Ensure that report shows correct deducted days')
- .to.be.deep.equal(['2','2','2']);
- done();
- });
-
- });
-
- after(function(done){
- driver.quit().then(() => done() );
- });
-
-});
+ url:
+ application_host +
+ 'reports/allowancebytime/?start_date=2018-02&end_date=2018-02',
+ driver
+ })
+ .then(() =>
+ driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id}"]`))
+ )
+
+ .then(tr =>
+ Bluebird.join(
+ tr.findElement(By.css('[data-vpp-deducted-days="1"]')),
+ tr.findElement(
+ By.css(`[data-vpp-leave-type-id="${leave_type_holiday_id}"]`)
+ ),
+ tr.findElement(
+ By.css(`[data-vpp-leave-type-id="${leave_type_sick_id}"]`)
+ ),
+ (allowance_el, holiday_el, sick_el) =>
+ Bluebird.map([allowance_el, holiday_el, sick_el], el =>
+ el.getText()
+ )
+ )
+ )
+ .then(stat => {
+ expect(
+ stat,
+ 'Ensure that report shows correct deducted days'
+ ).to.be.deep.equal(['2', '2', '2'])
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/leave_type/crud_leave_type.js b/t/integration/leave_type/crud_leave_type.js
index a1af253c6..7cb455366 100644
--- a/t/integration/leave_type/crud_leave_type.js
+++ b/t/integration/leave_type/crud_leave_type.js
@@ -1,415 +1,596 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- register_new_user_func = require('../../lib/register_new_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- By = require('selenium-webdriver').By,
- config = require('../../lib/config'),
- Bluebird = require('bluebird'),
- expect = require('chai').expect,
- application_host = config.get_application_host(),
- leave_type_edit_form_id='#leave_type_edit_form',
- leave_type_new_form_id ='#leave_type_new_form';
-
-
-describe('CRUD for leave types', function(){
- var driver;
-
- this.timeout( config.get_execution_timeout() );
-
- it("Performing registration process", function(done){
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const By = require('selenium-webdriver').By;
+ const config = require('../../lib/config');
+ const Bluebird = require('bluebird');
+ const expect = require('chai').expect;
+ const application_host = config.get_application_host();
+ const leave_type_edit_form_id = '#leave_type_edit_form';
+ const leave_type_new_form_id = '#leave_type_new_form'
+
+describe('CRUD for leave types', function() {
+ let driver
+
+ this.timeout(config.get_execution_timeout())
+
+ it('Performing registration process', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open page with leave types", function(done){
+ it('Open page with leave types', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
})
- it("Check if there are default leave types", function(done){
+ it('Check if there are default leave types', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'Holiday',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_1"]',
- value : 'Sick Leave',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'Holiday'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_1"]',
+ value: 'Sick Leave'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure default colours are set for leave types", done => {
- driver.findElements(By.css('form#leave_type_edit_form [data-tom-color-picker]'))
+ it('Make sure default colours are set for leave types', function(done) {
+ driver
+ .findElements(By.css('form#leave_type_edit_form [data-tom-color-picker]'))
.then(els => {
- expect(els.length, "Ensure number of colour pickers is the same as leave types")
- .to.be.equal(2);
-
- return Bluebird.map(els, el => el.findElement(By.css('input[type="hidden"]')));
+ expect(
+ els.length,
+ 'Ensure number of colour pickers is the same as leave types'
+ ).to.be.equal(2)
+
+ return Bluebird.map(els, el =>
+ el.findElement(By.css('input[type="hidden"]'))
+ )
})
.then(els => Bluebird.map(els, el => el.getAttribute('value')))
.then(colours => {
- expect( colours.sort(), 'Check default colour values' )
- .to.be.deep.equal(['leave_type_color_1', 'leave_type_color_1']);
- done();
- });
- });
-
- it("Change Sick leave type to be non-default colour", done => {
+ expect(colours.sort(), 'Check default colour values').to.be.deep.equal([
+ 'leave_type_color_1',
+ 'leave_type_color_1'
+ ])
+ done()
+ })
+ })
+ it('Change Sick leave type to be non-default colour', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id + ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] button.dropdown-toggle',
- dropdown_option : leave_type_edit_form_id + ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] [data-tom-color-picker-css-class="leave_type_color_2"]'
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
- })
- .then(() => done() );
- });
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] button.dropdown-toggle',
+ dropdown_option:
+ leave_type_edit_form_id +
+ ' [data-tom-color-picker="1"][data-tom-leave-type-order="colour__1"] [data-tom-color-picker-css-class="leave_type_color_2"]'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
+ }).then(() => done())
+ })
- it('Ensure that color class for Sick days was updated to be non-default', done => {
- driver.findElements(By.css('form#leave_type_edit_form [data-tom-color-picker] input[type="hidden"]'))
+ it('Ensure that color class for Sick days was updated to be non-default', function(done) {
+ driver
+ .findElements(
+ By.css(
+ 'form#leave_type_edit_form [data-tom-color-picker] input[type="hidden"]'
+ )
+ )
.then(els => Bluebird.map(els, el => el.getAttribute('value')))
.then(colours => {
- expect( colours.sort(), 'Check default colour values' )
- .to.be.deep.equal(['leave_type_color_1', 'leave_type_color_2']);
- done();
+ expect(colours.sort(), 'Check default colour values').to.be.deep.equal([
+ 'leave_type_color_1',
+ 'leave_type_color_2'
+ ])
+ done()
})
- });
+ })
- it('Make sure that both leave types have "use allowance" tick boxes set', function(done){
+ it('Make sure that both leave types have "use allowance" tick boxes set', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="allowance_0"]',
- tick : true,
- value : 'on',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="allowance_1"]',
- tick : true,
- value : 'off',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="allowance_0"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="allowance_1"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Check that updating "use allowance flag" works', function(done){
+ it('Check that updating "use allowance flag" works', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="allowance_1"]',
- tick : true,
- value : 'on',
- }],
- should_be_successful : true,
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="allowance_1"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ should_be_successful: true,
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Double check that "use allowance" tick boxes were updated correctly', function( done ){
+ it('Double check that "use allowance" tick boxes were updated correctly', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="allowance_0"]',
- value : 'on',
- tick : true,
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="allowance_1"]',
- value : 'on',
- tick : true,
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="allowance_0"]',
+ value: 'on',
+ tick: true
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="allowance_1"]',
+ value: 'on',
+ tick: true
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Check that it is possible to update Limits", function(done){
+ it('Check that it is possible to update Limits', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="limit_0"]',
- value : '0',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="limit_1"]',
- value : '5',
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- should_be_successful : true,
- message : /Changes to leave types were saved/,
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="limit_0"]',
+ value: '0'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="limit_1"]',
+ value: '5'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ should_be_successful: true,
+ message: /Changes to leave types were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure that Limit cannot be negative", function(done){
+ it('Make sure that Limit cannot be negative', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="limit_0"]',
- value : '-1',
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- message : /New limit for .* should be positive number or 0/,
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="limit_0"]',
+ value: '-1'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ message: /New limit for .* should be positive number or 0/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Add new leave type", function(done){
- driver.findElement(By.css('#add_new_leave_type_btn'))
- .then(function(el){
- return el.click();
+ it('Add new leave type', function(done) {
+ driver
+ .findElement(By.css('#add_new_leave_type_btn'))
+ .then(function(el) {
+ return el.click()
})
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_new_form_id+' input[name="name__new"]',
- value : 'AAAAA',
- },{
- selector : leave_type_new_form_id+' input[name="use_allowance__new"]',
- value : 'on',
- tick : true,
- }],
- submit_button_selector : leave_type_new_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ driver,
+ form_params: [
+ {
+ selector: leave_type_new_form_id + ' input[name="name__new"]',
+ value: 'AAAAA'
+ },
+ {
+ selector:
+ leave_type_new_form_id + ' input[name="use_allowance__new"]',
+ value: 'on',
+ tick: true
+ }
+ ],
+ submit_button_selector:
+ leave_type_new_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it('Check that new leave type was added at the beginning of the list as it starts with "A"', function(done){
+ it('Check that new leave type was added at the beginning of the list as it starts with "A"', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'AAAAA',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_1"]',
- value : 'Holiday',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_2"]',
- value : 'Sick Leave',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'AAAAA'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_1"]',
+ value: 'Holiday'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_2"]',
+ value: 'Sick Leave'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('And rename newly added leave type to start with "M"', function(done){
+ it('And rename newly added leave type to start with "M"', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'MM',
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'MM'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure that updated new leave type was moved into second position", function(done){
+ it('Make sure that updated new leave type was moved into second position', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'Holiday',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_1"]',
- value : 'MM',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_2"]',
- value : 'Sick Leave',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'Holiday'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_1"]',
+ value: 'MM'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_2"]',
+ value: 'Sick Leave'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Remove empty newly added leave type", function(done){
+ it('Remove empty newly added leave type', function(done) {
submit_form_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'Holiday',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_1"]',
- value : 'Sick Leave',
- }],
- submit_button_selector : leave_type_edit_form_id+' button[data-tom-leave-type-order="remove_1"]',
- message : /Leave type was successfully removed/,
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'Holiday'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_1"]',
+ value: 'Sick Leave'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id +
+ ' button[data-tom-leave-type-order="remove_1"]',
+ message: /Leave type was successfully removed/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And make sure only two old leave types are left", function(done){
+ it('And make sure only two old leave types are left', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'Holiday',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_1"]',
- value : 'Sick Leave',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'Holiday'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_1"]',
+ value: 'Sick Leave'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Add AAA and ZZZ leave types", function(done){
+ it('Add AAA and ZZZ leave types', function(done) {
driver
.findElement(By.css('#add_new_leave_type_btn'))
.then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_new_form_id+' input[name="name__new"]',
- value : 'ZZZ',
- },{
- selector : leave_type_new_form_id+' input[name="use_allowance__new"]',
- value : 'on',
- tick : true,
- }],
- submit_button_selector : leave_type_new_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: leave_type_new_form_id + ' input[name="name__new"]',
+ value: 'ZZZ'
+ },
+ {
+ selector:
+ leave_type_new_form_id + ' input[name="use_allowance__new"]',
+ value: 'on',
+ tick: true
+ }
+ ],
+ submit_button_selector:
+ leave_type_new_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
})
)
.then(() => driver.findElement(By.css('#add_new_leave_type_btn')))
.then(el => el.click())
.then(() => driver.sleep(1000))
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_new_form_id+' input[name="name__new"]',
- value : 'AAA',
- },{
- selector : leave_type_new_form_id+' input[name="use_allowance__new"]',
- value : 'on',
- tick : true,
- }],
- submit_button_selector : leave_type_new_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: leave_type_new_form_id + ' input[name="name__new"]',
+ value: 'AAA'
+ },
+ {
+ selector:
+ leave_type_new_form_id + ' input[name="use_allowance__new"]',
+ value: 'on',
+ tick: true
+ }
+ ],
+ submit_button_selector:
+ leave_type_new_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
})
)
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Ensure AAA is first and ZZZ is last in the list (general settings page)", function(done){
+ it('Ensure AAA is first and ZZZ is last in the list (general settings page)', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'AAA',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_1"]',
- value : 'Holiday',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_2"]',
- value : 'Sick Leave',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_3"]',
- value : 'ZZZ',
- }],
- })
- .then(() => done());
- });
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'AAA'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_1"]',
+ value: 'Holiday'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_2"]',
+ value: 'Sick Leave'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_3"]',
+ value: 'ZZZ'
+ }
+ ]
+ }).then(() => done())
+ })
- it("Ensure AAA is a first and ZZZ is a last in a list on book holiday modal", function(done){
+ it('Ensure AAA is a first and ZZZ is a last in a list on book holiday modal', function(done) {
driver
.findElements(By.css('select#leave_type option'))
- .then(options => Bluebird.map(options, option => {
- let option_info = {};
- return option.getAttribute('data-tom-index')
- .then(val => Bluebird.resolve(option_info.value = val))
- .then(() => option.getAttribute('data-tom'))
- .then(txt => Bluebird.resolve(option_info.text = txt))
- .then(() => Bluebird.resolve(option_info));
- }))
+ .then(options =>
+ Bluebird.map(options, option => {
+ const option_info = {}
+ return option
+ .getAttribute('data-tom-index')
+ .then(val => Bluebird.resolve((option_info.value = val)))
+ .then(() => option.getAttribute('data-tom'))
+ .then(txt => Bluebird.resolve((option_info.text = txt)))
+ .then(() => Bluebird.resolve(option_info))
+ })
+ )
.then(option_infos => {
- expect(option_infos[0], 'AAA is first').to.include({ value : '0', text : 'AAA'});
- expect(option_infos[3], 'ZZZ is last').to.include({ value : '3', text : 'ZZZ'});
- done();
- });
- });
+ expect(option_infos[0], 'AAA is first').to.include({
+ value: '0',
+ text: 'AAA'
+ })
+ expect(option_infos[3], 'ZZZ is last').to.include({
+ value: '3',
+ text: 'ZZZ'
+ })
+ done()
+ })
+ })
- it('Mark ZZZ as one to be default one', function(done){
+ it('Mark ZZZ as one to be default one', function(done) {
driver
- .findElement(By.css(leave_type_edit_form_id+' input[data-tom-leave-type-order="name_3"]'))
+ .findElement(
+ By.css(
+ leave_type_edit_form_id + ' input[data-tom-leave-type-order="name_3"]'
+ )
+ )
.then(inp => inp.getAttribute('name'))
.then(name => Bluebird.resolve(name.split('__')[1]))
- .then(id => submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id+' input[type="radio"][value="'+id+'"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ .then(id =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[type="radio"][value="' +
+ id +
+ '"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
})
)
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Ensure AAA is first and ZZZ is last in the list (general settings page)", function(done){
+ it('Ensure AAA is first and ZZZ is last in the list (general settings page)', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_0"]',
- value : 'AAA',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_1"]',
- value : 'Holiday',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_2"]',
- value : 'Sick Leave',
- },{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="name_3"]',
- value : 'ZZZ',
- }],
- })
- .then(() => done());
- });
+ driver,
+ elements_to_check: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_0"]',
+ value: 'AAA'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_1"]',
+ value: 'Holiday'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_2"]',
+ value: 'Sick Leave'
+ },
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="name_3"]',
+ value: 'ZZZ'
+ }
+ ]
+ }).then(() => done())
+ })
- it("Ensure ZZZ is a first and AAA is a second in a list on book holiday modal", function(done){
+ it('Ensure ZZZ is a first and AAA is a second in a list on book holiday modal', function(done) {
driver
.findElements(By.css('select#leave_type option'))
- .then(options => Bluebird.map(options, option => {
- let option_info = {};
- return option.getAttribute('data-tom-index')
- .then(val => Bluebird.resolve(option_info.value = val))
- .then(() => option.getAttribute('data-tom'))
- .then(txt => Bluebird.resolve(option_info.text = txt))
- .then(() => Bluebird.resolve(option_info));
- }))
+ .then(options =>
+ Bluebird.map(options, option => {
+ const option_info = {}
+ return option
+ .getAttribute('data-tom-index')
+ .then(val => Bluebird.resolve((option_info.value = val)))
+ .then(() => option.getAttribute('data-tom'))
+ .then(txt => Bluebird.resolve((option_info.text = txt)))
+ .then(() => Bluebird.resolve(option_info))
+ })
+ )
.then(option_infos => {
- expect(option_infos[0], 'ZZZ is first').to.include({ value : '0', text : 'ZZZ'});
- expect(option_infos[1], 'AAA is last').to.include({ value : '1', text : 'AAA'});
- done();
- });
- });
+ expect(option_infos[0], 'ZZZ is first').to.include({
+ value: '0',
+ text: 'ZZZ'
+ })
+ expect(option_infos[1], 'AAA is last').to.include({
+ value: '1',
+ text: 'AAA'
+ })
+ done()
+ })
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_type/leave_type_auto_approve.js b/t/integration/leave_type/leave_type_auto_approve.js
index 29e0c9cd1..78abd58a2 100644
--- a/t/integration/leave_type/leave_type_auto_approve.js
+++ b/t/integration/leave_type/leave_type_auto_approve.js
@@ -1,22 +1,21 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- until = require('selenium-webdriver').until,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- add_new_user_func = require('../../lib/add_new_user'),
- config = require('../../lib/config'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- register_new_user_func = require('../../lib/register_new_user'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- some_weekday_date = '2015-06-17',
- leave_type_new_form_id ='#leave_type_new_form';
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const until = require('selenium-webdriver').until;
+ const Promise = require('bluebird');
+ const expect = require('chai').expect;
+ const add_new_user_func = require('../../lib/add_new_user');
+ const config = require('../../lib/config');
+ const login_user_func = require('../../lib/login_with_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const some_weekday_date = '2015-06-17';
+ const leave_type_new_form_id = '#leave_type_new_form'
/*
* Scenario:
@@ -38,332 +37,353 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Auto approval leave type', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Auto approval leave type', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, email_A, email_B, user_id_B;
+ let driver, email_A, email_B, user_id_B
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
-
- it("Create second user B", function(done){
+ })
+
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Open page with leave types", function(done){
+ it('Open page with leave types', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver,
- })
- .then(() => done());
- });
+ url: application_host + 'settings/general/',
+ driver
+ }).then(() => done())
+ })
- it("Add auto approve leave type", function(done){
- driver.findElement(By.css('#add_new_leave_type_btn'))
- .then(function(el){
- return el.click();
+ it('Add auto approve leave type', function(done) {
+ driver
+ .findElement(By.css('#add_new_leave_type_btn'))
+ .then(function(el) {
+ return el.click()
})
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_new_form_id+' input[name="name__new"]',
- value : 'AAAAA',
- },{
- selector : leave_type_new_form_id+' input[name="auto_approve__new"]',
- value : 'on',
- tick : true,
- }],
- submit_button_selector : leave_type_new_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ driver,
+ form_params: [
+ {
+ selector: leave_type_new_form_id + ' input[name="name__new"]',
+ value: 'AAAAA'
+ },
+ {
+ selector:
+ leave_type_new_form_id + ' input[name="auto_approve__new"]',
+ value: 'on',
+ tick: true
+ }
+ ],
+ submit_button_selector:
+ leave_type_new_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Logout from admin user", function(done){
+ it('Logout from admin user', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as regular user B", function(done){
+ it('Login as regular user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Submit new leave request from non admin user", function(done){
+ it('Submit new leave request from non admin user', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : some_weekday_date,
- },{
- selector : 'input#to',
- value : some_weekday_date,
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: some_weekday_date
+ },
+ {
+ selector: 'input#to',
+ value: some_weekday_date
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Ensure that new leave went straight to Approved status", function(done){
+ it('Ensure that new leave went straight to Approved status', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(elements){
- expect(elements.length).to.be.eq(1);
- return elements[0].getText();
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(1)
+ return elements[0].getText()
+ })
+ .then(function(status) {
+ expect(status).to.be.eq('Approved')
+ done()
})
- .then(function(status){
- expect( status ).to.be.eq('Approved');
- done();
- });
- });
+ })
- it("Logout from user B", function(done){
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as admin user A", function(done){
+ it('Login as admin user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that there is no pending leave requests', function(done){
- driver
- .findElements(By.css( '.btn-warning' ))
- .then(function(elements){
- expect( elements.length ).to.be.eq(0);
- done();
- })
- });
+ it('Ensure that there is no pending leave requests', function(done) {
+ driver.findElements(By.css('.btn-warning')).then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
- it("Open email audit page", function( done ){
+ it('Open email audit page', function(done) {
open_page_func({
- url : application_host + 'audit/email/',
- driver : driver,
+ url: application_host + 'audit/email/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure there were two emails regarding auto-approved leaves', function(done){
+ it('Ensure there were two emails regarding auto-approved leaves', function(done) {
driver
- .findElements( By.css('tr.vpp-email-audit-entry-header a.collapsed') )
- .then(function(elements){
- return Promise.map(
- [elements[0], elements[1]],
- function(el){ return el.getText() }
- );
+ .findElements(By.css('tr.vpp-email-audit-entry-header a.collapsed'))
+ .then(function(elements) {
+ return Promise.map([elements[0], elements[1]], function(el) {
+ return el.getText()
+ })
})
- .then(function(subjects){
- expect(subjects).to.contain('New leave was added and auto approved.');
- expect(subjects).to.contain('New leave was added');
- done();
+ .then(function(subjects) {
+ expect(subjects).to.contain('New leave was added and auto approved.')
+ expect(subjects).to.contain('New leave was added')
+ done()
})
- });
+ })
- it("Logout from admin user", function(done){
+ it('Logout from admin user', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as regular user B", function(done){
+ it('Login as regular user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Revoke request', function(done){
+ it('Revoke request', function(done) {
driver
- .findElement(By.css(
- 'button.revoke-btn'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(By.css('button.revoke-btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
+ })
+ .then(function() {
+ return driver.findElement(By.css('.alert-success')).then(function(el) {
+ expect(el).to.be.ok
+ return Promise.resolve(1)
+ })
})
- .then(function(){
- return driver.findElement( By.css('.alert-success') )
- .then(function(el){
- expect(el).to.be.ok;
- return Promise.resolve(1);
- })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Ensure that it is gone without need to be approved", function(done){
+ it('Ensure that it is gone without need to be approved', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(elements){
- expect(elements.length).to.be.eq(0);
- done();
- });
- });
-
- it("Logout from user B", function(done){
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as admin user A", function(done){
+ it('Login as admin user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open user B absences section', function(done){
+ it('Open user B absences section', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/absences/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_B + '/absences/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Ensure that user B does not have any leaves", function(done){
+ it('Ensure that user B does not have any leaves', function(done) {
driver
- .findElements(By.css( 'tr.leave-request-row .leave-request-row-status' ))
- .then(function(elements){
- expect(elements.length).to.be.eq(0);
- done();
- });
- });
-
- it("Open requests page", function( done ){
+ .findElements(By.css('tr.leave-request-row .leave-request-row-status'))
+ .then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
+
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that there is no pending leave requests', function(done){
- driver
- .findElements(By.css( '.btn-warning' ))
- .then(function(elements){
- expect( elements.length ).to.be.eq(0);
- done();
- })
- });
+ it('Ensure that there is no pending leave requests', function(done) {
+ driver.findElements(By.css('.btn-warning')).then(function(elements) {
+ expect(elements.length).to.be.eq(0)
+ done()
+ })
+ })
- it("Open email audit page", function( done ){
+ it('Open email audit page', function(done) {
open_page_func({
- url : application_host + 'audit/email/',
- driver : driver,
+ url: application_host + 'audit/email/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure there were two emails regarding auto-approved leaves', function(done){
+ it('Ensure there were two emails regarding auto-approved leaves', function(done) {
driver
- .findElements( By.css('tr.vpp-email-audit-entry-header a.collapsed') )
- .then(function(elements){
- return Promise.map(
- [elements[0], elements[1]],
- function(el){ return el.getText() }
- );
+ .findElements(By.css('tr.vpp-email-audit-entry-header a.collapsed'))
+ .then(function(elements) {
+ return Promise.map([elements[0], elements[1]], function(el) {
+ return el.getText()
+ })
})
- .then(function(subjects){
- expect(subjects).to.contain('Leave was revoked and auto approved');
- expect(subjects).to.contain('Leave was revoked');
- done();
+ .then(function(subjects) {
+ expect(subjects).to.contain('Leave was revoked and auto approved')
+ expect(subjects).to.contain('Leave was revoked')
+ done()
})
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_type/leave_type_limit_in_action.js b/t/integration/leave_type/leave_type_limit_in_action.js
index 496073f57..afcb59c3c 100644
--- a/t/integration/leave_type/leave_type_limit_in_action.js
+++ b/t/integration/leave_type/leave_type_limit_in_action.js
@@ -1,23 +1,22 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user'),
- leave_type_edit_form_id='#leave_type_edit_form',
- config = require('../../lib/config'),
- application_host = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const _ = require('underscore')
+const Promise = require('bluebird')
+const moment = require('moment')
+const login_user_func = require('../../lib/login_with_user')
+const register_new_user_func = require('../../lib/register_new_user')
+const logout_user_func = require('../../lib/logout_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const check_elements_func = require('../../lib/check_elements')
+const check_booking_func = require('../../lib/check_booking_on_calendar')
+const add_new_user_func = require('../../lib/add_new_user')
+const leave_type_edit_form_id = '#leave_type_edit_form'
+const config = require('../../lib/config')
+const application_host = config.get_application_host()
/*
* Scenario to go in this test:
@@ -32,146 +31,168 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Leave type limits in actoion', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Leave type limits in action', function() {
+ this.timeout(config.get_execution_timeout())
- var non_admin_user_email, driver;
+ let non_admin_user_email, driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open page with leave types", function(done){
+ it('Open page with leave types', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("Check that it is possible to update Limits", function(done){
- submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="limit_0"]',
- value : '3',
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- should_be_successful : true,
- message : /Changes to leave types were saved/,
+ })
+
+ it('Check that it is possible to update Limits', function(done) {
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="limit_0"]',
+ value: '3'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ should_be_successful: true,
+ message: /Changes to leave types were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Create new non-admin user", function(done){
+ it('Create new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as non-admin user", function(done){
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2015&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2015&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("And make sure that it is calendar indeed", function(done){
- driver.getTitle()
- .then(function(title){
- expect(title).to.be.equal('Calendar');
- done();
- });
- });
-
- it("Try to request new leave that exceed the limit", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
+ })
+ it('And make sure that it is calendar indeed', function(done) {
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Calendar')
+ done()
+ })
+ })
+
+ it('Try to request new leave that exceed the limit', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-18',
- }],
- message : /Adding requested .* absence would exceed maximum allowed for such type by 1/,
- multi_line_message : true,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-18'
+ }
+ ],
+ message: /Adding requested .* absence would exceed maximum allowed for such type by 1/,
+ multi_line_message: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Add a request that fits under the limit", function(done){
+ it('Add a request that fits under the limit', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-17',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-17'
+ }
+ ],
+ message: /New leave request was added/
})
- // Check that all days are marked as pended
- .then(function(){
- check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-16'),moment('2015-06-16'),moment('2015-06-17')],
- type : 'pended',
+ // Check that all days are marked as pended
+ .then(function() {
+ check_booking_func({
+ driver,
+ full_days: [
+ moment('2015-06-16'),
+ moment('2015-06-16'),
+ moment('2015-06-17')
+ ],
+ type: 'pended'
+ }).then(function() {
+ done()
+ })
})
- .then(function(){ done() });
- });
- });
- });
+ })
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_type/leave_type_limit_next_year.js b/t/integration/leave_type/leave_type_limit_next_year.js
index f9ce4793f..42b117ee5 100644
--- a/t/integration/leave_type/leave_type_limit_next_year.js
+++ b/t/integration/leave_type/leave_type_limit_next_year.js
@@ -1,25 +1,25 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird"),
- moment = require('moment'),
- until = require('selenium-webdriver').until,
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- add_new_user_func = require('../../lib/add_new_user'),
- leave_type_edit_form_id='#leave_type_edit_form',
- config = require('../../lib/config'),
- application_host = config.get_application_host();
-
-const next_year = moment().add(1, 'y').format('YYYY');
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const until = require('selenium-webdriver').until;
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_booking_func = require('../../lib/check_booking_on_calendar');
+ const add_new_user_func = require('../../lib/add_new_user');
+ const leave_type_edit_form_id = '#leave_type_edit_form';
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host()
+
+const next_year = moment()
+ .add(1, 'y')
+ .format('YYYY')
/*
* Scenario to go in this test:
@@ -36,193 +36,219 @@ const next_year = moment().add(1, 'y').format('YYYY');
*
* */
-describe('Leave type limits for next year: ' + next_year, function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Leave type limits for next year: ' + next_year, function() {
+ this.timeout(config.get_execution_timeout())
- let admin_user_email, non_admin_user_email, driver;
+ let admin_user_email, non_admin_user_email, driver
- it('Create new company', function(done){
- register_new_user_func({application_host})
- .then(data =>{
- ({driver,email:admin_user_email} = data);
- done();
- });
- });
+ it('Create new company', function(done) {
+ register_new_user_func({ application_host }).then(data => {
+ ;({ driver, email: admin_user_email } = data)
+ done()
+ })
+ })
- it("Open page with leave types", function(done){
+ it('Open page with leave types', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver,
- })
- .then(() => done());
- });
+ url: application_host + 'settings/general/',
+ driver
+ }).then(() => done())
+ })
- it("Check that it is possible to update Limits", function(done){
+ it('Check that it is possible to update Limits', function(done) {
submit_form_func({
driver,
- form_params : [{
- selector : leave_type_edit_form_id+' input[data-tom-leave-type-order="limit_0"]',
- value : '1',
- }],
- submit_button_selector : leave_type_edit_form_id+' button[type="submit"]',
- should_be_successful : true,
- message : /Changes to leave types were saved/,
+ form_params: [
+ {
+ selector:
+ leave_type_edit_form_id +
+ ' input[data-tom-leave-type-order="limit_0"]',
+ value: '1'
+ }
+ ],
+ submit_button_selector:
+ leave_type_edit_form_id + ' button[type="submit"]',
+ should_be_successful: true,
+ message: /Changes to leave types were saved/
+ }).then(() => done())
+ })
+
+ it('Create new non-admin user', function(done) {
+ add_new_user_func({ application_host, driver }).then(data => {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(() => done());
- });
-
- it("Create new non-admin user", function(done){
- add_new_user_func({ application_host, driver })
- .then(data => {
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
-
- it("Logout from admin account", function(done){
- logout_user_func({application_host, driver})
- .then(() => done());
- });
-
- it("Login as non-admin user", function(done){
+ })
+
+ it('Logout from admin account', function(done) {
+ logout_user_func({ application_host, driver }).then(() => done())
+ })
+
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year='+next_year+'&show_full_year=1',
- driver : driver,
+ url:
+ application_host + 'calendar/?year=' + next_year + '&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Add a request that fits under the limit", function(done){
+ it('Add a request that fits under the limit', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : next_year + '-05-10',
- },{
- selector : 'input#to',
- value : next_year + '-05-10',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: next_year + '-05-10'
+ },
+ {
+ selector: 'input#to',
+ value: next_year + '-05-10'
+ }
+ ],
+ message: /New leave request was added/
})
- // Check that all days are marked as pended
- .then(function(){
- check_booking_func({
- driver : driver,
- full_days : [moment(next_year + '-05-10')],
- type : 'pended',
+ // Check that all days are marked as pended
+ .then(function() {
+ check_booking_func({
+ driver,
+ full_days: [moment(next_year + '-05-10')],
+ type: 'pended'
+ }).then(function() {
+ done()
+ })
})
- .then(function(){ done() });
- });
- });
- });
+ })
+ })
- it("Logout from regular user session", function(done){
+ it('Logout from regular user session', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as Admin", function(done){
+ it('Login as Admin', function(done) {
login_user_func({
- application_host : application_host,
- user_email : admin_user_email,
- driver : driver,
+ application_host,
+ user_email: admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
})
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Approve newly added leave request", function(done){
+ it('Approve newly added leave request', function(done) {
driver
- .findElement(By.css(
- 'tr[vpp="pending_for__'+non_admin_user_email+'"] .btn-success'
- ))
- .then(function(el){ return el.click(); })
- .then(function(){
+ .findElement(
+ By.css(
+ 'tr[vpp="pending_for__' + non_admin_user_email + '"] .btn-success'
+ )
+ )
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// Wait until page properly is reloaded
- return driver.wait(until.elementLocated(By.css('h1')), 1000);
+ return driver.wait(until.elementLocated(By.css('h1')), 1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as non-admin user", function(done){
+ it('Login as non-admin user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year='+ next_year +'&show_full_year=1',
- driver : driver,
+ url:
+ application_host + 'calendar/?year=' + next_year + '&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And try to request one more day of the type already 100% taken", function(done){
+ it('And try to request one more day of the type already 100% taken', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : next_year + '-05-17',
- },{
- selector : 'input#to',
- value : next_year + '-05-17',
- }],
- message : /Failed to create a leave request/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: next_year + '-05-17'
+ },
+ {
+ selector: 'input#to',
+ value: next_year + '-05-17'
+ }
+ ],
+ message: /Failed to create a leave request/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/leave_type/remove_used_leave_type.js b/t/integration/leave_type/remove_used_leave_type.js
index 1d8db84c0..8e18bf647 100644
--- a/t/integration/leave_type/remove_used_leave_type.js
+++ b/t/integration/leave_type/remove_used_leave_type.js
@@ -1,24 +1,22 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- moment = require('moment'),
- login_user_func = require('../../lib/login_with_user'),
- register_new_user_func = require('../../lib/register_new_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- check_booking_func = require('../../lib/check_booking_on_calendar'),
- leave_type_edit_form_id='#leave_type_edit_form',
- leave_type_new_form_id ='#leave_type_new_form',
- config = require('../../lib/config'),
- application_host = config.get_application_host(),
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const login_user_func = require('../../lib/login_with_user');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const check_booking_func = require('../../lib/check_booking_on_calendar');
+ const leave_type_edit_form_id = '#leave_type_edit_form';
+ const leave_type_new_form_id = '#leave_type_new_form';
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host();
+ const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario to go in this test:
@@ -30,131 +28,152 @@ const
*
* */
-describe('Try to remove used leave type', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Try to remove used leave type', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, email;
+ let driver, email
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ ;({ driver, email } = data)
+ done()
})
- .then(function(data){
- ({driver, email} = data);
- done();
- });
- });
-
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email, year:2015})
- .then(() => done())
- });
-
- it("Open page with leave types", function(done){
+ })
+
+ it('Ensure user starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email, year: 2015 }).then(() =>
+ done()
+ )
+ })
+
+ it('Open page with leave types', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Add new leave type", function(done){
+ it('Add new leave type', function(done) {
driver
.findElement(By.css('#add_new_leave_type_btn'))
- .then(function(el){ return el.click() })
- .then(function(){
-
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : leave_type_new_form_id+' input[name="name__new"]',
- value : 'AAAAA',
- },{
- selector : leave_type_new_form_id+' input[name="use_allowance__new"]',
- value : 'on',
- tick : true,
- }],
- submit_button_selector : leave_type_new_form_id+' button[type="submit"]',
- message : /Changes to leave types were saved/,
+ driver,
+ form_params: [
+ {
+ selector: leave_type_new_form_id + ' input[name="name__new"]',
+ value: 'AAAAA'
+ },
+ {
+ selector:
+ leave_type_new_form_id + ' input[name="use_allowance__new"]',
+ value: 'on',
+ tick: true
+ }
+ ],
+ submit_button_selector:
+ leave_type_new_form_id + ' button[type="submit"]',
+ message: /Changes to leave types were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Open calendar page", function(done){
+ it('Open calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?show_full_year=1&year=2015',
- driver : driver,
+ url: application_host + 'calendar/?show_full_year=1&year=2015',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Request new leave", function(done){
+ it('Request new leave', function(done) {
driver
.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
+ .then(function(el) {
+ return el.click()
+ })
// Create new leave request
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
+ driver,
// The order matters here as we need to populate dropdown prior date filds
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- },{
- selector : 'select[name="leave_type"]',
- option_selector : 'option[data-tom-index="0"]',
- },{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-16',
- }],
- message : /New leave request was added/,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]'
+ },
+ {
+ selector: 'select[name="leave_type"]',
+ option_selector: 'option[data-tom-index="0"]'
+ },
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-16'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Check that all days are marked as pended", function(done){
+ it('Check that all days are marked as pended', function(done) {
check_booking_func({
- driver : driver,
- full_days : [moment('2015-06-16')],
- halfs_1st_days : [moment('2015-06-15')],
- type : 'pended',
+ driver,
+ full_days: [moment('2015-06-16')],
+ halfs_1st_days: [moment('2015-06-15')],
+ type: 'pended'
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open page with leave types", function(done){
+ it('Open page with leave types', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to remove newly added leave type and ensure it fails", function(done){
+ it('Try to remove newly added leave type and ensure it fails', function(done) {
submit_form_func({
- driver : driver,
- submit_button_selector : leave_type_edit_form_id+' button[data-tom-leave-type-order="remove_0"]',
- message : /Cannot remove leave type: type is in use/,
+ driver,
+ submit_button_selector:
+ leave_type_edit_form_id +
+ ' button[data-tom-leave-type-order="remove_0"]',
+ message: /Cannot remove leave type: type is in use/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/login_case_sensitive.js b/t/integration/login_case_sensitive.js
index 11e27fedb..41b191faf 100644
--- a/t/integration/login_case_sensitive.js
+++ b/t/integration/login_case_sensitive.js
@@ -1,16 +1,15 @@
+'use strict'
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- login_user_func = require('../lib/login_with_user'),
- register_new_user_func = require('../lib/register_new_user'),
- logout_user_func = require('../lib/logout_user'),
- config = require('../lib/config'),
- application_host = config.get_application_host();
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const login_user_func = require('../lib/login_with_user');
+ const register_new_user_func = require('../lib/register_new_user');
+ const logout_user_func = require('../lib/logout_user');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host()
/*
User emails are case insensitive.
@@ -22,59 +21,63 @@ var test = require('selenium-webdriver/testing'),
*/
-describe('Emails are case insensitive', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Emails are case insensitive', function() {
+ this.timeout(config.get_execution_timeout())
- var admin_email, driver;
+ let admin_email, driver
- it('Register an account useing upper case letters', function(done){
+ it('Register an account useing upper case letters', function(done) {
register_new_user_func({
- application_host : application_host,
- user_email : (new Date()).getTime() + 'John.Smith@TEST.com',
+ application_host,
+ user_email: new Date().getTime() + 'John.Smith@TEST.com'
+ }).then(function(data) {
+ admin_email = data.email
+ driver = data.driver
+ done()
})
- .then(function(data){
- admin_email = data.email;
- driver = data.driver;
- done();
- });
- });
+ })
- it("Logount from current session", function(done){
+ it('Logount from current session', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login with lower case email", function(done){
+ it('Login with lower case email', function(done) {
login_user_func({
- application_host : application_host,
- user_email : admin_email.toLowerCase(),
- driver : driver,
+ application_host,
+ user_email: admin_email.toLowerCase(),
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout", function(done){
+ it('Logout', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Try to login with upper case email", function(done){
+ it('Try to login with upper case email', function(done) {
login_user_func({
- application_host : application_host,
- user_email : admin_email.toUpperCase(),
- driver : driver,
+ application_host,
+ user_email: admin_email.toUpperCase(),
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/menu_bar_reflect_user.js b/t/integration/menu_bar_reflect_user.js
index 844e477c7..7966e8101 100644
--- a/t/integration/menu_bar_reflect_user.js
+++ b/t/integration/menu_bar_reflect_user.js
@@ -1,18 +1,16 @@
-
-'use strict';
-
-
-var test = require('selenium-webdriver/testing'),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- add_new_user_func = require('../lib/add_new_user'),
- By = require('selenium-webdriver').By,
- bluebird = require("bluebird"),
- expect = require('chai').expect,
- _ = require('underscore'),
- logout_user_func = require('../lib/logout_user'),
- config = require('../lib/config'),
- application_host = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const register_new_user_func = require('../lib/register_new_user')
+const login_user_func = require('../lib/login_with_user')
+const add_new_user_func = require('../lib/add_new_user')
+const By = require('selenium-webdriver').By
+const bluebird = require('bluebird')
+const expect = require('chai').expect
+const _ = require('underscore')
+const logout_user_func = require('../lib/logout_user')
+const config = require('../lib/config')
+const application_host = config.get_application_host()
/*
* Scenario to check in thus test.
@@ -27,27 +25,25 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Menu bar reflect permissions of logged in user', function(){
+describe('Menu bar reflect permissions of logged in user', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let ordinary_user_email, driver
- var ordinary_user_email, driver;
-
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
-
- it("Check that all necessary menus are shown", function(done){
- var promises_to_check = check_presense_promises({
- driver : driver,
- presense : true,
- selectors : [
+ })
+
+ it('Check that all necessary menus are shown', function(done) {
+ const promises_to_check = check_presense_promises({
+ driver,
+ presense: true,
+ selectors: [
'li > a[href="/calendar/"]',
'li > a[href="/calendar/teamview/"]',
'li > a[href="/calendar/feeds/"]',
@@ -55,100 +51,99 @@ describe('Menu bar reflect permissions of logged in user', function(){
'li > a[href="/settings/general/"]',
'li > a[href="/settings/departments/"]',
'li > a[href="/requests/"]',
- 'li > a[href="/logout/"]',
- ],
- });
+ 'li > a[href="/logout/"]'
+ ]
+ })
- bluebird
- .all( promises_to_check )
- .then(function(){ done() });
- });
+ bluebird.all(promises_to_check).then(function() {
+ done()
+ })
+ })
- it("Create non-admin user", function(done){
+ it('Create non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ ordinary_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- ordinary_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin acount", function(done){
+ it('Logout from admin acount', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as ordinary user", function(done){
+ it('Login as ordinary user', function(done) {
login_user_func({
- application_host : application_host,
- user_email : ordinary_user_email,
- driver : driver,
+ application_host,
+ user_email: ordinary_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("Check that limited links are there", function(done){
- var promises_to_check = check_presense_promises({
- driver : driver,
- presense : true,
- selectors : [
+ })
+
+ it('Check that limited links are there', function(done) {
+ const promises_to_check = check_presense_promises({
+ driver,
+ presense: true,
+ selectors: [
'li > a[href="/calendar/"]',
'li > a[href="/calendar/teamview/"]',
'li > a[href="/calendar/feeds/"]',
'li > a[href="/requests/"]',
- 'li > a[href="/logout/"]',
- ],
- });
-
- bluebird
- .all( promises_to_check)
- .then( function(){ done() });
- });
-
- it("Check that admin links are not shown", function(done){
- var promises_to_check = check_presense_promises({
- driver : driver,
- presense : false,
- selectors : [
+ 'li > a[href="/logout/"]'
+ ]
+ })
+
+ bluebird.all(promises_to_check).then(function() {
+ done()
+ })
+ })
+
+ it('Check that admin links are not shown', function(done) {
+ const promises_to_check = check_presense_promises({
+ driver,
+ presense: false,
+ selectors: [
'li > a[href="/users/"]',
'li > a[href="/settings/general/"]',
- 'li > a[href="/settings/departments/"]',
- ],
- });
-
- bluebird
- .all( promises_to_check)
- .then( function(){ done() });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
-
-function check_presense_promises(args){
-
- var selectors = args.selectors,
- driver = args.driver,
- presense = args.presense || false;
-
- var promises_to_check = _.map(
- selectors,
- function( selector ){
- return driver
- .isElementPresent(By.css(selector))
- .then(function(is_present){
- expect(is_present).to.be.equal(presense);
- return bluebird.resolve();
- })
- }
- );
-
- return promises_to_check;
-};
+ 'li > a[href="/settings/departments/"]'
+ ]
+ })
+
+ bluebird.all(promises_to_check).then(function() {
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
+
+function check_presense_promises(args) {
+ const selectors = args.selectors
+ const driver = args.driver
+ const presense = args.presense || false
+
+ const promises_to_check = _.map(selectors, function(selector) {
+ return driver
+ .findElements(By.css(selector))
+ .then(found => !!found.length)
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(presense)
+ return bluebird.resolve()
+ })
+ })
+
+ return promises_to_check
+}
diff --git a/t/integration/register_new_company_for_existing_email.js b/t/integration/register_new_company_for_existing_email.js
index ded2354d4..a685c73c0 100644
--- a/t/integration/register_new_company_for_existing_email.js
+++ b/t/integration/register_new_company_for_existing_email.js
@@ -1,18 +1,17 @@
+'use strict'
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- config = require('../lib/config'),
- application_host = config.get_application_host(),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- login_user_func = require('../lib/login_with_user'),
- register_new_user_func = require('../lib/register_new_user'),
- logout_user_func = require('../lib/logout_user'),
- submit_form_func = require('../lib/submit_form'),
- add_new_user_func = require('../lib/add_new_user');
+const test = require('selenium-webdriver/testing');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host();
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const login_user_func = require('../lib/login_with_user');
+ const register_new_user_func = require('../lib/register_new_user');
+ const logout_user_func = require('../lib/logout_user');
+ const submit_form_func = require('../lib/submit_form');
+ const add_new_user_func = require('../lib/add_new_user')
/*
At this moment there is a bug when anyone can hijack acount if primary email
@@ -27,62 +26,64 @@ var test = require('selenium-webdriver/testing'),
*/
-describe('Reuse email from existing acount when creating new company', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Reuse email from existing acount when creating new company', function() {
+ this.timeout(config.get_execution_timeout())
- var admin_email, driver;
+ let admin_email, driver
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ admin_email = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- admin_email = data.email;
- done();
- });
- });
+ })
- it('Logout from newly created account', function(done){
+ it('Logout from newly created account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Close the browser", function(done){
- driver.quit().then(function(){ done() });
- });
+ it('Close the browser', function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
- it('Try to create another account with the same email', function(done){
+ it('Try to create another account with the same email', function(done) {
register_new_user_func({
- application_host : application_host,
- user_email : admin_email,
- failing_error_message : 'Failed to register user please contact customer service. Error: Email is already used',
+ application_host,
+ user_email: admin_email,
+ failing_error_message:
+ 'Failed to register user please contact customer service. Error: Email is already used'
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data .driver;
- done();
- });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done() });
- });
-
-// after(function() {
-// if (this.currentTest.state == 'failed') {
-// driver.takeScreenshot().then(function(image, err) {
-// return require('fs').writeFile('out.png', image, 'base64', function(err) {
-// console.log(err);
-// });
-// })
-// .close();
-//
-//
-// }
-// });
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
-});
+ // after(function() {
+ // if (this.currentTest.state == 'failed') {
+ // driver.takeScreenshot().then(function(image, err) {
+ // return require('fs').writeFile('out.png', image, 'base64', function(err) {
+ // console.log(err);
+ // });
+ // })
+ // .close();
+ //
+ //
+ // }
+ // });
+})
diff --git a/t/integration/register_new_user.js b/t/integration/register_new_user.js
index 45fadeaaf..3042338d4 100644
--- a/t/integration/register_new_user.js
+++ b/t/integration/register_new_user.js
@@ -1,133 +1,133 @@
+'use strict'
-'use strict';
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const register_new_user_func = require('../lib/register_new_user');
+ const expect = require('chai').expect;
+ const login_user_func = require('../lib/login_with_user');
+ const open_page_func = require('../lib/open_page');
+ const submit_form_func = require('../lib/submit_form');
+ const config = require('../lib/config');
+ const moment = require('moment');
+ const application_host = config.get_application_host()
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- register_new_user_func = require('../lib/register_new_user'),
- expect = require('chai').expect,
- login_user_func = require('../lib/login_with_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- config = require('../lib/config'),
- moment = require('moment'),
- application_host = config.get_application_host();
+describe('Register new user', function() {
+ let driver
+ this.timeout(config.get_execution_timeout())
-describe('Register new user', function(){
- var driver;
-
- this.timeout( config.get_execution_timeout() );
-
-
- it("Performing registration process", function(done){
+ it('Performing registration process', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it('Navigate to current uer details', done => {
+ it('Navigate to current uer details', function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
})
- .then(() => driver
- .findElement(By.css( 'td.user-link-cell a' ))
- )
- .then(element => element.click())
- .then(() => done() );
- });
+ .then(() => driver.findElement(By.css('td.user-link-cell a')))
+ .then(element => element.click())
+ .then(() => done())
+ })
- it('Update start date to be mid-year', done => {
+ it('Update start date to be mid-year', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#start_date_inp',
- value : moment.utc().year() + '-06-01',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .* were updated/,
- })
- .then(() => done());
- });
-
- it('Go back to Calendar page and ensure that available and total days are same and are 12', done =>{
+ driver,
+ form_params: [
+ {
+ selector: 'input#start_date_inp',
+ value: moment.utc().year() + '-06-01'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ }).then(() => done())
+ })
+
+ it('Go back to Calendar page and ensure that available and total days are same and are 12', function(done) {
open_page_func({
- url : application_host + 'calendar/',
- driver : driver,
- })
- .then(() => driver
- .findElement(By.css( '[data-tom-days-available-in-allowance]' ))
- )
- .then(element => element.getText())
- .then(days => {
- expect(days, 'Ensure that reported days available in allowance is correct')
- .to.be.equal('12');
- return driver
- .findElement(By.css('[data-tom-total-days-in-allowance]'));
+ url: application_host + 'calendar/',
+ driver
})
- .then(element => element.getText())
- .then(days => {
- expect(days, 'Ensure that reported total days in allowance is correct')
- .to.be.equal('12');
- done();
- });
- });
-
- it('Navigate to current uer details', done => {
+ .then(() =>
+ driver.findElement(By.css('[data-tom-days-available-in-allowance]'))
+ )
+ .then(element => element.getText())
+ .then(days => {
+ expect(
+ days,
+ 'Ensure that reported days available in allowance is correct'
+ ).to.be.equal('12')
+ return driver.findElement(By.css('[data-tom-total-days-in-allowance]'))
+ })
+ .then(element => element.getText())
+ .then(days => {
+ expect(
+ days,
+ 'Ensure that reported total days in allowance is correct'
+ ).to.be.equal('12')
+ done()
+ })
+ })
+
+ it('Navigate to current uer details', function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
})
- .then(() => driver
- .findElement(By.css( 'td.user-link-cell a' ))
- )
- .then(element => element.click())
- .then(() => done() );
- });
+ .then(() => driver.findElement(By.css('td.user-link-cell a')))
+ .then(element => element.click())
+ .then(() => done())
+ })
- it('Update start date to be start of the year', done => {
+ it('Update start date to be start of the year', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#start_date_inp',
- value : moment.utc().year() + '-01-01',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .* were updated/,
- })
- .then(() => done());
- });
-
- it('Go back to Calendar page and ensure that available and total days are same and are 20', done =>{
+ driver,
+ form_params: [
+ {
+ selector: 'input#start_date_inp',
+ value: moment.utc().year() + '-01-01'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ }).then(() => done())
+ })
+
+ it('Go back to Calendar page and ensure that available and total days are same and are 20', function(done) {
open_page_func({
- url : application_host + 'calendar/',
- driver : driver,
+ url: application_host + 'calendar/',
+ driver
})
- .then(() => driver
- .findElement(By.css( '[data-tom-days-available-in-allowance]' ))
- )
- .then(element => element.getText())
- .then(days => {
- expect(days, 'Ensure that reported days available in allowance is correct')
- .to.be.equal('20');
- return driver
- .findElement(By.css('[data-tom-total-days-in-allowance]'));
+ .then(() =>
+ driver.findElement(By.css('[data-tom-days-available-in-allowance]'))
+ )
+ .then(element => element.getText())
+ .then(days => {
+ expect(
+ days,
+ 'Ensure that reported days available in allowance is correct'
+ ).to.be.equal('20')
+ return driver.findElement(By.css('[data-tom-total-days-in-allowance]'))
+ })
+ .then(element => element.getText())
+ .then(days => {
+ expect(
+ days,
+ 'Ensure that reported total days in allowance is correct'
+ ).to.be.equal('20')
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
})
- .then(element => element.getText())
- .then(days => {
- expect(days, 'Ensure that reported total days in allowance is correct')
- .to.be.equal('20');
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
-
+ })
+})
diff --git a/t/integration/schedule/company_wide.js b/t/integration/schedule/company_wide.js
index 25f1a65d1..5460d7322 100644
--- a/t/integration/schedule/company_wide.js
+++ b/t/integration/schedule/company_wide.js
@@ -1,21 +1,19 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- Promise = require("bluebird"),
- moment = require('moment'),
- expect = require('chai').expect,
- register_new_user_func = require('../../lib/register_new_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- user_info_func = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- schedule_form_id = '#company_schedule_form',
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const Promise = require('bluebird');
+ const moment = require('moment');
+ const expect = require('chai').expect;
+ const register_new_user_func = require('../../lib/register_new_user');
+ const open_page_func = require('../../lib/open_page');
+ const submit_form_func = require('../../lib/submit_form');
+ const check_elements_func = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const user_info_func = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const schedule_form_id = '#company_schedule_form';
+ const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario 1:
@@ -27,178 +25,209 @@ const
*
* */
-describe("Changing default company wide schedule", function(){
+describe('Changing default company wide schedule', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let driver
- var driver;
-
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open company details page", function(done){
+ it('Open company details page', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure company has default schedule', function(done){
+ it('Ensure company has default schedule', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : schedule_form_id + ' input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="wednesday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="thursday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="friday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : schedule_form_id + ' input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: schedule_form_id + ' input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="wednesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="thursday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="friday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: schedule_form_id + ' input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make Wednesday to be non-working day', function(done){
+ it('Make Wednesday to be non-working day', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : schedule_form_id + ' #schedule_item_wednesday',
- tick : true,
- }],
- submit_button_selector : schedule_form_id+' button[type="submit"]',
- message : /Schedule for company was saved/,
+ driver,
+ form_params: [
+ {
+ selector: schedule_form_id + ' #schedule_item_wednesday',
+ tick: true
+ }
+ ],
+ submit_button_selector: schedule_form_id + ' button[type="submit"]',
+ message: /Schedule for company was saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('And make sure that it was indeed marked so', function(done){
+ it('And make sure that it was indeed marked so', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : schedule_form_id + ' input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="wednesday"]',
- tick : true,
- value : 'off',
- },{
- selector : schedule_form_id + ' input[name="thursday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="friday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : schedule_form_id + ' input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: schedule_form_id + ' input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="wednesday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: schedule_form_id + ' input[name="thursday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="friday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: schedule_form_id + ' input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open Calendar page', function(done){
+ it('Open Calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2015&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2015&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... and ensure Wednesday is marked as non-working day', function(done){
+ it('... and ensure Wednesday is marked as non-working day', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
.findElement(By.css('table.month_January td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- done();
- });
- });
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ done()
+ })
+ })
- it('... and ensure that Monday is still working day', function(done){
+ it('... and ensure that Monday is still working day', function(done) {
driver
.findElement(By.css('table.month_January td.day_5'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).not.to.match(/\bweekend_cell\b/);
- done();
- });
- });
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).not.to.match(/\bweekend_cell\b/)
+ done()
+ })
+ })
- it('Open Team view page', function(done){
+ it('Open Team view page', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?&date=2015-01',
- driver : driver,
+ url: application_host + 'calendar/teamview/?&date=2015-01',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... and make sure Wednsday is marked as non-working day', function(done){
+ it('... and make sure Wednsday is marked as non-working day', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
.findElement(By.css('table.team-view-table td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- done();
- });
- });
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ done()
+ })
+ })
- it('... and ensure Monday is still working day', function(done){
+ it('... and ensure Monday is still working day', function(done) {
driver
.findElement(By.css('table.team-view-table td.day_5'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).not.to.match(/\bweekend_cell\b/);
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).not.to.match(/\bweekend_cell\b/)
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
/*
* Scenario 2:
@@ -209,115 +238,139 @@ describe("Changing default company wide schedule", function(){
* * Ensure the "used days" for previously added leave reflects the change
* */
-describe('Leave request reflects shanges in company schedule', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Leave request reflects changes in company schedule', function() {
+ this.timeout(config.get_execution_timeout())
- let driver, email_A;
+ let driver, email_A
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
+ })
- it("Obtain information about newly added user", (done) => {
- user_info_func({driver, email:email_A})
- .then(data => done());
- });
+ it('Obtain information about newly added user', function(done) {
+ user_info_func({ driver, email: email_A }).then(data => done())
+ })
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email:email_A, year:2015})
- .then(() => done())
- });
+ it('Ensure user starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email: email_A, year: 2015 }).then(
+ () => done()
+ )
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Submit new leave requesti for 7 calendar days", function(done){
+ it('Submit new leave requesti for 7 calendar days', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-21',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-21'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... and ensure newly created request deducts 5 days from allowance', function(done){
- driver.findElement(By.css('td[data-vpp="days_used"]'))
- .then(function(el){ return el.getText() })
- .then(function(days_used){
- expect(days_used).to.be.equal('5');
- })
- .then(function(){done()});
- });
+ it('... and ensure newly created request deducts 5 days from allowance', function(done) {
+ driver
+ .findElement(By.css('td[data-vpp="days_used"]'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(days_used) {
+ expect(days_used).to.be.equal('5')
+ })
+ .then(function() {
+ done()
+ })
+ })
- it("Open company details page", function(done){
+ it('Open company details page', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make Saturday to be working day', function(done){
+ it('Make Saturday to be working day', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : schedule_form_id + ' #schedule_item_saturday',
- tick : true,
- }],
- submit_button_selector : schedule_form_id+' button[type="submit"]',
- message : /Schedule for company was saved/,
+ driver,
+ form_params: [
+ {
+ selector: schedule_form_id + ' #schedule_item_saturday',
+ tick: true
+ }
+ ],
+ submit_button_selector: schedule_form_id + ' button[type="submit"]',
+ message: /Schedule for company was saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... and ensure newly created request deducts 6 days from allowance', function(done){
- driver.findElement(By.css('td[data-vpp="days_used"]'))
- .then(function(el){ return el.getText() })
- .then(function(days_used){
- expect(days_used).to.be.equal('6');
- })
- .then(function(){done()});
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ it('... and ensure newly created request deducts 6 days from allowance', function(done) {
+ driver
+ .findElement(By.css('td[data-vpp="days_used"]'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(days_used) {
+ expect(days_used).to.be.equal('6')
+ })
+ .then(function() {
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/schedule/user_specific.js b/t/integration/schedule/user_specific.js
index 30b61bc1a..d905692c3 100644
--- a/t/integration/schedule/user_specific.js
+++ b/t/integration/schedule/user_specific.js
@@ -1,23 +1,22 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- moment = require('moment'),
- add_new_user_func = require('../../lib/add_new_user'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- register_new_user_func = require('../../lib/register_new_user'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- schedule_form_id = '#company_schedule_form',
- userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year');
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const Promise = require('bluebird');
+ const expect = require('chai').expect;
+ const moment = require('moment');
+ const add_new_user_func = require('../../lib/add_new_user');
+ const check_elements_func = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const login_user_func = require('../../lib/login_with_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const application_host = config.get_application_host();
+ const schedule_form_id = '#company_schedule_form';
+ const userStartsAtTheBeginingOfYear = require('../../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Scenario 1: Basic user specific schedule
@@ -40,620 +39,826 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Basic user specific schedule', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Basic user specific schedule', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, email_A, email_B, user_id_A, user_id_B;
+ let driver, email_A, email_B, user_id_A, user_id_B
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
+ })
- it("Create second user B", function(done){
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user A", function(done){
+ it('Obtain information about user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Ensure that user A started at the begining of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email:email_A, year: 2015})
- .then(() => done())
- });
+ it('Ensure that user A started at the begining of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email: email_A, year: 2015 }).then(
+ () => done()
+ )
+ })
- it('Open user B schedule and ensure wording indicates company wide one is used', function(done){
+ it('Open user B schedule and ensure wording indicates company wide one is used', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/schedule/',
- driver : driver,
- })
- .then(function(){
- return driver
- .findElement( By.css('a[data-vpp="link-to-company-schedule"]') )
- .then(function(company_schedule_link){
- expect(company_schedule_link).to.be.ok;
- return Promise.resolve();
- })
- })
- .then(function(){
+ url: application_host + 'users/edit/' + user_id_B + '/schedule/',
driver
- .findElement( By.css('button[name="save_user_specific_schedule"]') )
- .then(function(button){ return button.getText() })
- .then(function(caption){
- expect(caption).to.be.equal('Override company wide schedule');
- done();
- })
- });
- });
+ })
+ .then(function() {
+ return driver
+ .findElement(By.css('a[data-vpp="link-to-company-schedule"]'))
+ .then(function(company_schedule_link) {
+ expect(company_schedule_link).to.be.ok
+ return Promise.resolve()
+ })
+ })
+ .then(function() {
+ driver
+ .findElement(By.css('button[name="save_user_specific_schedule"]'))
+ .then(function(button) {
+ return button.getText()
+ })
+ .then(function(caption) {
+ expect(caption).to.be.equal('Override company wide schedule')
+ done()
+ })
+ })
+ })
- it('Ensure it has default configuration', function(done){
+ it('Ensure it has default configuration', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="wednesday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="thursday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="friday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : 'input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
- })
- .then(function(){ done() });
- });
-
- it('Update user B to have Wed to be non-working day', function(done){
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="wednesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="thursday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="friday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: 'input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Update user B to have Wed to be non-working day', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : '#schedule_item_wednesday',
- tick : true,
- }],
- submit_button_selector : 'button[name="save_user_specific_schedule"]',
- message : /Schedule for user was saved/,
- })
- .then(function(){ done() });
- });
-
- it('Ensure that User B details shows new schedule', function(done){
+ driver,
+ form_params: [
+ {
+ selector: '#schedule_item_wednesday',
+ tick: true
+ }
+ ],
+ submit_button_selector: 'button[name="save_user_specific_schedule"]',
+ message: /Schedule for user was saved/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that User B details shows new schedule', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="wednesday"]',
- tick : true,
- value : 'off',
- },{
- selector : 'input[name="thursday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="friday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : 'input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
- })
- .then(function(){ done() });
- });
-
- it("Open company details page", function(done){
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="wednesday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: 'input[name="thursday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="friday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: 'input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open company details page', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure Company wide schedule is still default: Sat, Sun are non-working', function(done){
+ it('Ensure Company wide schedule is still default: Sat, Sun are non-working', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : schedule_form_id + ' input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="wednesday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="thursday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="friday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : schedule_form_id + ' input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
- })
- .then(function(){ done() });
- });
-
- it('Open Team view page', function(done){
+ driver,
+ elements_to_check: [
+ {
+ selector: schedule_form_id + ' input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="wednesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="thursday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="friday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: schedule_form_id + ' input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open Team view page', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?&date=2015-01',
- driver : driver,
+ url: application_host + 'calendar/teamview/?&date=2015-01',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('Make sure that team view shows user A has Sat and Sun as non-working days', function(done){
+ it('Make sure that team view shows user A has Sat and Sun as non-working days', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.not.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_7'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.not.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
- .then(function(){
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_10'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
- })
- .then(function(){
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_10'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ })
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_11'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_11'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it('Make sure team view shows user B has Wed, Sat, Sun as non-working days', function(done){
+ it('Make sure team view shows user B has Wed, Sat, Sun as non-working days', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_7'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
- .then(function(){
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_10'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
- })
- .then(function(){
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_10'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ })
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_11'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_11'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open Calendar page', function(done){
+ it('Open Calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2015&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2015&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... ensure that only Sat and Sun are non-working days', function(done){
+ it('... ensure that only Sat and Sun are non-working days', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
.findElement(By.css('table.month_January td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.not.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.not.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
- .then(function(){
+ .then(function() {
return driver
.findElement(By.css('table.month_January td.day_10'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
})
- .then(function(){
+ .then(function() {
return driver
.findElement(By.css('table.month_January td.day_11'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Submit new leave requesti from user A for 7 calendar days", function(done){
+ it('Submit new leave requesti from user A for 7 calendar days', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-21',
- }],
- message : /New leave request was added/,
- })
- .then(function(){done()});
- });
-
- it("Open requests page", function(done){
- open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-21'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... and ensure newly created request deducts 5 days from allowance', function(done){
- driver.findElement(By.css('td[data-vpp="days_used"]'))
- .then(function(el){ return el.getText() })
- .then(function(days_used){
- expect(days_used).to.be.equal('5');
+ it('Open requests page', function(done) {
+ open_page_func({
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Logout from user A (admin)", function(done){
+ it('... and ensure newly created request deducts 5 days from allowance', function(done) {
+ driver
+ .findElement(By.css('td[data-vpp="days_used"]'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(days_used) {
+ expect(days_used).to.be.equal('5')
+ })
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open Calendar page', function(done){
+ it('Open Calendar page', function(done) {
open_page_func({
- url : application_host + 'calendar/?year=2015&show_full_year=1',
- driver : driver,
+ url: application_host + 'calendar/?year=2015&show_full_year=1',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... ensure its calendar page shows WED,Sat, and Sun as non-working days', function(done){
+ it('... ensure its calendar page shows WED,Sat, and Sun as non-working days', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
.findElement(By.css('table.month_January td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .then(function(el) {
+ return el.getAttribute('class')
})
- .then(function(){
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ .then(function() {
return driver
.findElement(By.css('table.month_January td.day_10'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
})
- .then(function(){
+ .then(function() {
return driver
.findElement(By.css('table.month_January td.day_11'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- //* * Book a holiday for 7 days and make sure that 4 days deducted from allowance
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then(function(el){ return el.click() })
- .then(function(el){
+ //* * Book a holiday for 7 days and make sure that 4 days deducted from allowance
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(function(el) {
+ return el.click()
+ })
+ .then(function(el) {
// This is very important line when working with Bootstrap modals!
- return driver.sleep(1000);
+ return driver.sleep(1000)
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Submit new leave requesti from user A for 7 calendar days", function(done){
+ it('Submit new leave requesti from user A for 7 calendar days', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2015-06-15',
- },{
- selector : 'input#to',
- value : '2015-06-21',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2015-06-15'
+ },
+ {
+ selector: 'input#to',
+ value: '2015-06-21'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
-
- it("Logout from user B", function(done){
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user A (admin)", function(done){
+ it('Login as user A (admin)', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open requests page", function(done){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('... and ensure irequest from user B deducts 4 days from allowance', function(done){
- driver.findElement(By.css('tr[vpp="pending_for__'+email_B+'"] td[data-vpp="days_used"]'))
- .then(function(el){ return el.getText() })
- .then(function(days_used){
- expect(days_used).to.be.equal('4');
- })
- .then(function(){done()});
- });
+ it('... and ensure irequest from user B deducts 4 days from allowance', function(done) {
+ driver
+ .findElement(
+ By.css(
+ 'tr[vpp="pending_for__' + email_B + '"] td[data-vpp="days_used"]'
+ )
+ )
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(days_used) {
+ expect(days_used).to.be.equal('4')
+ })
+ .then(function() {
+ done()
+ })
+ })
- it('Open user B schedule', function(done){
+ it('Open user B schedule', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/schedule/',
- driver : driver,
- })
- .then(function(){
- return driver
- .findElement( By.css('strong[data-vpp="declare-user-specific-schedule"]') )
- .then(function(el){
- expect(el).to.be.ok;
- return Promise.resolve();
- })
- })
- .then(function(){
+ url: application_host + 'users/edit/' + user_id_B + '/schedule/',
driver
- .findElement( By.css('button[name="save_user_specific_schedule"]') )
- .then(function(button){ return button.getText() })
- .then(function(caption){
- expect(caption).to.be.equal('Save employee specific schedule');
- done();
- })
- });
- });
+ })
+ .then(function() {
+ return driver
+ .findElement(
+ By.css('strong[data-vpp="declare-user-specific-schedule"]')
+ )
+ .then(function(el) {
+ expect(el).to.be.ok
+ return Promise.resolve()
+ })
+ })
+ .then(function() {
+ driver
+ .findElement(By.css('button[name="save_user_specific_schedule"]'))
+ .then(function(button) {
+ return button.getText()
+ })
+ .then(function(caption) {
+ expect(caption).to.be.equal('Save employee specific schedule')
+ done()
+ })
+ })
+ })
- it('Revoke user specific schedule and replace it with company wide one', function(done){
+ it('Revoke user specific schedule and replace it with company wide one', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{}],
- submit_button_selector : 'button[name="revoke_user_specific_schedule"]',
- message : /Schedule for user was saved/,
+ driver,
+ form_params: [{}],
+ submit_button_selector: 'button[name="revoke_user_specific_schedule"]',
+ message: /Schedule for user was saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that User B details shows new schedule', function(done){
+ it('Ensure that User B details shows new schedule', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="wednesday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="thursday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="friday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : 'input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
- })
- .then(function(){ done() });
- });
-
- it('Open Team view page', function(done){
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="wednesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="thursday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="friday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: 'input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open Team view page', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?&date=2015-01',
- driver : driver,
+ url: application_host + 'calendar/teamview/?&date=2015-01',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('Make sure that team view shows user A has Sat and Sun as non-working days', function(done){
+ it('Make sure that team view shows user A has Sat and Sun as non-working days', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.not.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_7'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
})
- .then(function(){
+ .then(function(css) {
+ expect(css).to.not.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_10'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
- })
- .then(function(){
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_10'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ })
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_11'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_11'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ })
+ .then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make sure team view shows user B also has Sat, Sun as non-working days', function(done){
+ it('Make sure team view shows user B also has Sat, Sun as non-working days', function(done) {
driver
// We know that 7th of January 2015 is Wednesday
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_7'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.not.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_7'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
})
- .then(function(){
+ .then(function(css) {
+ expect(css).to.not.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_10'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
- })
- .then(function(){
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_10'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ })
+ .then(function() {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_11'))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
- });
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_11'
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
/*
* Scenario 2: Populate company wide schedule before using user specific one
@@ -667,234 +872,299 @@ describe('Basic user specific schedule', function(){
*
* */
-describe('Populate company wide schedule before using user specific one', function(){
+describe('Populate company wide schedule before using user specific one', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let driver, email_A, email_B, user_id_A, user_id_B
- var driver, email_A, email_B, user_id_A, user_id_B;
-
- it("Register new company", function(done){
+ it('Register new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
+ })
- it("Create second user B", function(done){
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ email_B = data.new_user_email
+ done()
})
- .then(function(data){
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user A", function(done){
+ it('Obtain information about user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(function(data) {
+ user_id_A = data.user.id
+ done()
})
- .then(function(data){
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(function(data) {
+ user_id_B = data.user.id
+ done()
})
- .then(function(data){
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Open company details page", function(done){
+ it('Open company details page', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make Thu and Fri to be non-working day', function(done){
+ it('Make Thu and Fri to be non-working day', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : schedule_form_id + ' #schedule_item_thursday',
- tick : true,
- },{
- selector : schedule_form_id + ' #schedule_item_friday',
- tick : true,
- }],
- submit_button_selector : schedule_form_id+' button[type="submit"]',
- message : /Schedule for company was saved/,
- })
- .then(function(){ done() });
- });
-
- it('And make sure that it was indeed marked so', function(done){
+ driver,
+ form_params: [
+ {
+ selector: schedule_form_id + ' #schedule_item_thursday',
+ tick: true
+ },
+ {
+ selector: schedule_form_id + ' #schedule_item_friday',
+ tick: true
+ }
+ ],
+ submit_button_selector: schedule_form_id + ' button[type="submit"]',
+ message: /Schedule for company was saved/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('And make sure that it was indeed marked so', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : schedule_form_id + ' input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="wednesday"]',
- tick : true,
- value : 'on',
- },{
- selector : schedule_form_id + ' input[name="thursday"]',
- tick : true,
- value : 'off',
- },{
- selector : schedule_form_id + ' input[name="friday"]',
- tick : true,
- value : 'off',
- },{
- selector : schedule_form_id + ' input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : schedule_form_id + ' input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
- })
- .then(function(){ done() });
- });
-
- it('Open user B schedule', function(done){
+ driver,
+ elements_to_check: [
+ {
+ selector: schedule_form_id + ' input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="wednesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: schedule_form_id + ' input[name="thursday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: schedule_form_id + ' input[name="friday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: schedule_form_id + ' input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: schedule_form_id + ' input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open user B schedule', function(done) {
open_page_func({
- url : application_host + 'users/edit/'+user_id_B+'/schedule/',
- driver : driver,
+ url: application_host + 'users/edit/' + user_id_B + '/schedule/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Update user B to have Fri to be non-working day (by toggling off Thu)', function(done){
+ it('Update user B to have Fri to be non-working day (by toggling off Thu)', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : '#schedule_item_thursday',
- tick : true,
- }],
- submit_button_selector : 'button[name="save_user_specific_schedule"]',
- message : /Schedule for user was saved/,
- })
- .then(function(){ done() });
- });
-
- it('Ensure that User B details shows new schedule', function(done){
+ driver,
+ form_params: [
+ {
+ selector: '#schedule_item_thursday',
+ tick: true
+ }
+ ],
+ submit_button_selector: 'button[name="save_user_specific_schedule"]',
+ message: /Schedule for user was saved/
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that User B details shows new schedule', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input[name="monday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="tuesday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="wednesday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="thursday"]',
- tick : true,
- value : 'on',
- },{
- selector : 'input[name="friday"]',
- tick : true,
- value : 'off',
- },{
- selector : 'input[name="saturday"]',
- tick : true,
- value : 'off',
- },{
- selector : 'input[name="sunday"]',
- tick : true,
- value : 'off',
- }],
- })
- .then(function(){ done() });
- });
-
- it('Open Team view page', function(done){
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="monday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="tuesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="wednesday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="thursday"]',
+ tick: true,
+ value: 'on'
+ },
+ {
+ selector: 'input[name="friday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: 'input[name="saturday"]',
+ tick: true,
+ value: 'off'
+ },
+ {
+ selector: 'input[name="sunday"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Open Team view page', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?&date=2015-01',
- driver : driver,
+ url: application_host + 'calendar/teamview/?&date=2015-01',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('Ensure team view shows user A has Mon, Tue, Wed as working days', function(done){
- Promise.map([5,6,7], function(day_number){
+ it('Ensure team view shows user A has Mon, Tue, Wed as working days', function(done) {
+ Promise.map([5, 6, 7], function(day_number) {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_'+day_number))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.not.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_' +
+ day_number
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
})
+ .then(function(css) {
+ expect(css).to.not.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure team view shows user A has Thu, Fri, Sat, Sun as non-working days', function(done){
- Promise.map([8,9,10,11], function(day_number){
+ it('Ensure team view shows user A has Thu, Fri, Sat, Sun as non-working days', function(done) {
+ Promise.map([8, 9, 10, 11], function(day_number) {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_A+'"] td.day_'+day_number))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_A +
+ '"] td.day_' +
+ day_number
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure team view shows user B has Mon, Tue, Wed, Thu as working days', function(done){
- Promise.map([5,6,7,8], function(day_number){
+ it('Ensure team view shows user B has Mon, Tue, Wed, Thu as working days', function(done) {
+ Promise.map([5, 6, 7, 8], function(day_number) {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_'+day_number))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.not.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_' +
+ day_number
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
})
+ .then(function(css) {
+ expect(css).to.not.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
+ })
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure team view shows user B has Fri, Sat, Sun as non-working days', function(done){
- Promise.map([9,10,11], function(day_number){
+ it('Ensure team view shows user B has Fri, Sat, Sun as non-working days', function(done) {
+ Promise.map([9, 10, 11], function(day_number) {
return driver
- .findElement(By.css('table.team-view-table tr[data-vpp-user-list-row="'+user_id_B+'"] td.day_'+day_number))
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(/\bweekend_cell\b/);
- return Promise.resolve(1);
+ .findElement(
+ By.css(
+ 'table.team-view-table tr[data-vpp-user-list-row="' +
+ user_id_B +
+ '"] td.day_' +
+ day_number
+ )
+ )
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(/\bweekend_cell\b/)
+ return Promise.resolve(1)
})
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/team_view/basic_wall_chart.js b/t/integration/team_view/basic_wall_chart.js
index 7b317c2bb..4cfb4cf0c 100644
--- a/t/integration/team_view/basic_wall_chart.js
+++ b/t/integration/team_view/basic_wall_chart.js
@@ -1,24 +1,22 @@
-
-'use strict';
-
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird"),
- until = require('selenium-webdriver').until,
- _ = require('underscore'),
- register_new_user_func = require('../../lib/register_new_user'),
- login_user_func = require('../../lib/login_with_user'),
- open_page_func = require('../../lib/open_page'),
- submit_form_func = require('../../lib/submit_form'),
- add_new_user_func = require('../../lib/add_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- config = require('../../lib/config'),
- new_department_form_id = '#add_new_department_form',
- application_host = config.get_application_host(),
- company_edit_form_id ='#company_edit_form',
- department_edit_form_id = '#department_edit_form';
+'use strict'
+
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const Promise = require('bluebird')
+const until = require('selenium-webdriver').until
+const _ = require('underscore')
+const register_new_user_func = require('../../lib/register_new_user')
+const login_user_func = require('../../lib/login_with_user')
+const open_page_func = require('../../lib/open_page')
+const submit_form_func = require('../../lib/submit_form')
+const add_new_user_func = require('../../lib/add_new_user')
+const logout_user_func = require('../../lib/logout_user')
+const config = require('../../lib/config')
+const new_department_form_id = '#add_new_department_form'
+const application_host = config.get_application_host()
+const company_edit_form_id = '#company_edit_form'
+const department_edit_form_id = '#department_edit_form'
/*
* Scenario to check in thus test.
@@ -47,330 +45,368 @@ var test = require('selenium-webdriver/testing'),
// Helper function to check that provided users (email) are shown on the Team view
// page
-function check_teamview(data, emails){
-
+function check_teamview(data, emails) {
return open_page_func({
- url : application_host + 'calendar/teamview/',
- driver : data.driver,
- })
- .then(function(data){
- var promise_to_check = data.driver
- .findElements(By.css( 'tr.teamview-user-list-row > td.left-column-cell' ))
+ url: application_host + 'calendar/teamview/',
+ driver: data.driver
+ }).then(function(data) {
+ const promise_to_check = data.driver
+ .findElements(By.css('tr.teamview-user-list-row > td.left-column-cell'))
// Make sure that number of users is as expected
- .then(function(elements){
-
- expect(elements.length).to.be.equal( emails.length );
-
- return Promise.all(_.map(elements, function(el){ return el.getText(); }));
+ .then(function(elements) {
+ expect(elements.length).to.be.equal(emails.length)
+
+ return Promise.all(
+ _.map(elements, function(el) {
+ return el.getText()
+ })
+ )
})
// Make sure that users are actually those as expected
- .then(function(full_names){
-
+ .then(function(full_names) {
// The idea is to extract unique tokens from provided emails
- var tokens_from_emails = _.map(emails, function(email){
- return email.substring(0, email.lastIndexOf("@"));
- }).sort();
+ const tokens_from_emails = _.map(emails, function(email) {
+ return email.substring(0, email.lastIndexOf('@'))
+ }).sort()
// ... extract unique tokens from full names on the page
- var tokens_from_name = _.map(full_names, function(name){
- return name.substring(4, name.lastIndexOf(" "));
- }).sort();
+ const tokens_from_name = _.map(full_names, function(name) {
+ return name.substring(4, name.lastIndexOf(' '))
+ }).sort()
// ... and make sure that they are matched
- expect( tokens_from_emails ).to.be.eql(tokens_from_name);
+ expect(tokens_from_emails).to.be.eql(tokens_from_name)
- return Promise.resolve(data);
- });
-
- return promise_to_check;
- });
-};
+ return Promise.resolve(data)
+ })
-describe('Check basic scenario for Team view page', function(){
+ return promise_to_check
+ })
+}
- this.timeout( config.get_execution_timeout() );
+describe('Check basic scenario for Team view page', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, user_A, user_B, user_C;
+ let driver, user_A, user_B, user_C
- test.it('Performing registration process', function( done ){
+ it('Performing registration process', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ user_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- user_A = data.email;
- done();
- });
- });
-
- it("Create new user B", function(done){
+ })
+
+ it('Create new user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver,
// We have just one department so far
- department_index : "0",
+ department_index: '0'
+ }).then(function(data) {
+ user_B = data.new_user_email
+ done()
})
- .then(function(data){
- user_B = data.new_user_email;
- done();
- });
- });
-
- it("Make sure that both users are shown on Team view page", function(done){
- check_teamview({driver : driver}, [user_A, user_B])
- .then(function(){ done() });
- });
-
- it('Create new department: "IT"', function(done){
+ })
+
+ it('Make sure that both users are shown on Team view page', function(done) {
+ check_teamview({ driver }, [user_A, user_B]).then(function() {
+ done()
+ })
+ })
+
+ it('Create new department: "IT"', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("... open new department popup and submit form", function(done){
+ it('... open new department popup and submit form', function(done) {
driver
.findElement(By.css('#add_new_department_btn'))
- .then(function(el){
- return el.click();
+ .then(function(el) {
+ return el.click()
})
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_department_form_id+' input[name="name__new"]',
- value : 'IT',
- },{
- selector : new_department_form_id+' select[name="allowance__new"]',
- option_selector : 'option[value="10"]',
- value : '10',
- }],
- submit_button_selector : new_department_form_id+' button[type="submit"]',
- message : /Changes to departments were saved/,
+ driver,
+ form_params: [
+ {
+ selector: new_department_form_id + ' input[name="name__new"]',
+ value: 'IT'
+ },
+ {
+ selector:
+ new_department_form_id + ' select[name="allowance__new"]',
+ option_selector: 'option[value="10"]',
+ value: '10'
+ }
+ ],
+ submit_button_selector:
+ new_department_form_id + ' button[type="submit"]',
+ message: /Changes to departments were saved/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
- });
+ })
+ })
- it("Create user C", function(done){
+ it('Create user C', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver,
// We know that departments are ordered alphabetically, so newly
// added "ID" is before default "Sales" one
- department_index : "0",
+ department_index: '0'
+ }).then(function(data) {
+ user_C = data.new_user_email
+ done()
})
- .then(function(data){
- user_C = data.new_user_email;
- done();
- });
- });
+ })
- it("Make sure user C is superviser of IT department", function(done){
+ it('Make sure user C is superviser of IT department', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
})
- .then(() => driver
- .findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(links => links[0].click())
- )
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="boss_id"]',
- // because we have test names generated based on time, user C
- // is going to be last in a drop down
- option_selector : 'option:nth-child(3)',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
- }))
- .then(() => done());
- });
-
- it("Logout from A account", function(done){
+ .then(() =>
+ driver
+ .findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ .then(links => links[0].click())
+ )
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="manager_id"]',
+ // because we have test names generated based on time, user C
+ // is going to be last in a drop down
+ option_selector: 'option:nth-child(3)'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Logout from A account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : user_B,
- driver : driver,
+ application_host,
+ user_email: user_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("and make sure that only user A and B are presented", function(done){
- check_teamview({driver : driver}, [user_A, user_B])
- .then(function(){done()});
- });
+ it('and make sure that only user A and B are presented', function(done) {
+ check_teamview({ driver }, [user_A, user_B]).then(function() {
+ done()
+ })
+ })
- it("Logout from B account", function(done){
+ it('Logout from B account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login back as user A", function(done){
+ it('Login back as user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : user_A,
- driver : driver,
+ application_host,
+ user_email: user_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("and make sure that all users are shown: A, B, and C", function(done){
- check_teamview({driver : driver}, [user_A, user_B, user_C])
- .then(function(){ done() });
- });
+ it('and make sure that all users are shown: A, B, and C', function(done) {
+ check_teamview({ driver }, [user_A, user_B, user_C]).then(function() {
+ done()
+ })
+ })
- it("Update IT department to be supervised by user B", function(done){
+ it('Update IT department to be supervised by user B', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
+ url: application_host + 'settings/departments/',
+ driver
})
- .then(() => driver
- .findElements(By.css('a[href*="/settings/departments/edit/"]'))
- .then(links => links[0].click())
- )
- .then(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="boss_id"]',
- // because we have test names generated based on time, user B
- // is going to be second one in a drop down as it was added before
- // all other ones
- option_selector : 'option:nth-child(2)',
- }],
- submit_button_selector : department_edit_form_id+' button[type="submit"]',
- message : /Department .* was updated/,
- }))
- .then(() => done());
- });
-
- it("Logout from A account", function(done){
+ .then(() =>
+ driver
+ .findElements(By.css('a[href*="/settings/departments/edit/"]'))
+ .then(links => links[0].click())
+ )
+ .then(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="manager_id"]',
+ // because we have test names generated based on time, user B
+ // is going to be second one in a drop down as it was added before
+ // all other ones
+ option_selector: 'option:nth-child(2)'
+ }
+ ],
+ submit_button_selector:
+ department_edit_form_id + ' button[type="submit"]',
+ message: /Department .* was updated/
+ })
+ )
+ .then(() => done())
+ })
+
+ it('Logout from A account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : user_B,
- driver : driver,
+ application_host,
+ user_email: user_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("and make sure that all users are shown: A, B, and C", function(done){
- check_teamview({driver : driver}, [user_A, user_B, user_C])
- .then(function(){ done() });
- });
+ it('and make sure that all users are shown: A, B, and C', function(done) {
+ check_teamview({ driver }, [user_A, user_B, user_C]).then(function() {
+ done()
+ })
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user C", function(done){
+ it('Login as user C', function(done) {
login_user_func({
- application_host : application_host,
- user_email : user_C,
- driver : driver,
+ application_host,
+ user_email: user_C,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("and make sure that only one user C is here", function(done){
- check_teamview({ driver : driver }, [user_C])
- .then(function(){ done() });
- });
+ it('and make sure that only one user C is here', function(done) {
+ check_teamview({ driver }, [user_C]).then(function() {
+ done()
+ })
+ })
- it("Logout from user C account", function(done){
+ it('Logout from user C account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user A", function(done){
+ it('Login as user A', function(done) {
login_user_func({
- application_host : application_host,
- user_email : user_A,
- driver : driver,
+ application_host,
+ user_email: user_A,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open page for editing company details", function(done){
+ it('Open page for editing company details', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Check that company is been updated if valid values are submitted", function(done){
+ it('Check that company is been updated if valid values are submitted', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : company_edit_form_id+' input[name="share_all_absences"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : company_edit_form_id+' button[type="submit"]',
- message : /successfully/i,
- should_be_successful : true,
+ driver,
+ form_params: [
+ {
+ selector: company_edit_form_id + ' input[name="share_all_absences"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: company_edit_form_id + ' button[type="submit"]',
+ message: /successfully/i,
+ should_be_successful: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from user A account", function(done){
+ it('Logout from user A account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user C", function(done){
+ it('Login as user C', function(done) {
login_user_func({
- application_host : application_host,
- user_email : user_C,
- driver : driver,
+ application_host,
+ user_email: user_C,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("and make sure that all users are shown on Team view page", function(done){
- check_teamview({driver : driver}, [user_A, user_B, user_C])
- .then(function(){ done() });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ })
+
+ it('and make sure that all users are shown on Team view page', function(done) {
+ check_teamview({ driver }, [user_A, user_B, user_C]).then(function() {
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/team_view/deducted_column.js b/t/integration/team_view/deducted_column.js
index e5cea219f..a3c619bda 100644
--- a/t/integration/team_view/deducted_column.js
+++ b/t/integration/team_view/deducted_column.js
@@ -1,5 +1,4 @@
-
-'use strict';
+'use strict'
/*
* Scenario:
@@ -21,361 +20,391 @@
*
* */
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- add_new_user_func = require('../../lib/add_new_user'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- register_new_user_func = require('../../lib/register_new_user'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- new_bankholiday_form_id= '#add_new_bank_holiday_form',
- application_host = config.get_application_host();
-
-describe('Case when holidays spans through more then one month and is devided by bank holiday', function(){
-
- this.timeout( config.get_execution_timeout() );
-
- let driver,
- email_A, user_id_A,
- email_B, user_id_B;
-
- it("Register new company as admin user A", function(done){
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const Promise = require('bluebird');
+ const expect = require('chai').expect;
+ const add_new_user_func = require('../../lib/add_new_user');
+ const check_elements_func = require('../../lib/check_elements');
+ const config = require('../../lib/config');
+ const login_user_func = require('../../lib/login_with_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const open_page_func = require('../../lib/open_page');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const submit_form_func = require('../../lib/submit_form');
+ const user_info_func = require('../../lib/user_info');
+ const new_bankholiday_form_id = '#add_new_bank_holiday_form';
+ const application_host = config.get_application_host()
+
+describe('Case when holidays spans through more then one month and is devided by bank holiday', function() {
+ this.timeout(config.get_execution_timeout())
+
+ let driver, email_A, user_id_A, email_B, user_id_B
+
+ it('Register new company as admin user A', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(data => {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(data => {
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
-
- it("Create second user B", function(done){
+ })
+
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(data => {
+ email_B = data.new_user_email
+ done()
})
- .then(data => {
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user A", function(done){
+ it('Obtain information about user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(data => {
+ user_id_A = data.user.id
+ done()
})
- .then(data => {
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(data => {
+ user_id_B = data.user.id
+ done()
})
- .then(data => {
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Open page with bank holidays", function(done){
+ it('Open page with bank holidays', function(done) {
open_page_func({
driver,
- url: application_host + 'settings/bankholidays/',
- })
- .then(() => done());
- });
+ url: application_host + 'settings/bankholidays/'
+ }).then(() => done())
+ })
- it("Create new bank holiday to be on 2 Aug 2016", function(done){
- driver.findElement(By.css('#add_new_bank_holiday_btn'))
+ it('Create new bank holiday to be on 2 Aug 2016', function(done) {
+ driver
+ .findElement(By.css('#add_new_bank_holiday_btn'))
.then(el => el.click())
.then(() => {
-
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : new_bankholiday_form_id+' input[name="name__new"]',
- value : 'Some summer holiday',
- },{
- selector : new_bankholiday_form_id+' input[name="date__new"]',
- value : '2016-08-02',
- }],
- submit_button_selector: new_bankholiday_form_id+' button[type="submit"]',
- message : /Changes to bank holidays were saved/,
- })
- .then(() => done());
- });
- });
-
- it("Logout from user A (admin)", function(done){
+ driver,
+ form_params: [
+ {
+ selector: new_bankholiday_form_id + ' input[name="name__new"]',
+ value: 'Some summer holiday'
+ },
+ {
+ selector: new_bankholiday_form_id + ' input[name="date__new"]',
+ value: '2016-08-02'
+ }
+ ],
+ submit_button_selector:
+ new_bankholiday_form_id + ' button[type="submit"]',
+ message: /Changes to bank holidays were saved/
+ }).then(() => done())
+ })
+ })
+
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(() => done())
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then( el => el.click() )
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(el => el.click())
// This is very important line when working with Bootstrap modals!
- .then( el => driver.sleep(1000) )
- .then(() => done());
- });
+ .then(el => driver.sleep(1000))
+ .then(() => done())
+ })
- it("As user B create a holiday request from 28 July to morning of 4 Aug 2016 (a)", function(done){
+ it('As user B create a holiday request from 28 July to morning of 4 Aug 2016 (a)', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="from_date_part"]',
- option_selector : 'option[value="2"]',
- value : "2",
- },{
- selector : 'input#from',
- value : '2016-07-28',
- },{
- selector : 'input#to',
- value : '2016-08-04',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="from_date_part"]',
+ option_selector: 'option[value="2"]',
+ value: '2'
+ },
+ {
+ selector: 'input#from',
+ value: '2016-07-28'
+ },
+ {
+ selector: 'input#to',
+ value: '2016-08-04'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then( el => el.click() )
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(el => el.click())
// This is very important line when working with Bootstrap modals!
- .then( el => driver.sleep(1000) )
- .then(() => done());
- });
+ .then(el => driver.sleep(1000))
+ .then(() => done())
+ })
- it('As user B create a holiday request from 12 Aug to 15 Aug 2016 (b)', function(done){
+ it('As user B create a holiday request from 12 Aug to 15 Aug 2016 (b)', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2016-08-12',
- },{
- selector : 'input#to',
- value : '2016-08-15',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2016-08-12'
+ },
+ {
+ selector: 'input#to',
+ value: '2016-08-15'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then( el => el.click() )
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(el => el.click())
// This is very important line when working with Bootstrap modals!
- .then( el => driver.sleep(1000) )
- .then(() => done());
- });
+ .then(el => driver.sleep(1000))
+ .then(() => done())
+ })
- it('As user B create a holiday request from 26 Aug to 2 Sep 2016', function(done){
+ it('As user B create a holiday request from 26 Aug to 2 Sep 2016', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2016-08-26',
- },{
- selector : 'input#to',
- value : '2016-09-02',
- }],
- message : /New leave request was added/,
- })
- .then(() => done());
- });
-
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then( el => el.click() )
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2016-08-26'
+ },
+ {
+ selector: 'input#to',
+ value: '2016-09-02'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(() => done())
+ })
+
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(el => el.click())
// This is very important line when working with Bootstrap modals!
- .then( el => driver.sleep(1000) )
- .then(() => done());
- });
+ .then(el => driver.sleep(1000))
+ .then(() => done())
+ })
- it('As user B create a sick day request from 18 to 18 Aug 2016', function(done){
+ it('As user B create a sick day request from 18 to 18 Aug 2016', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'select[name="leave_type"]',
- option_selector : 'option:nth-child(2)',
- },{
- selector : 'input#from',
- value : '2016-08-18',
- },{
- selector : 'input#to',
- value : '2016-08-18',
- }],
- message : /New leave request was added/,
- })
- .then(() => done());
- });
-
- it("Logout from user B", function(done){
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="leave_type"]',
+ option_selector: 'option:nth-child(2)'
+ },
+ {
+ selector: 'input#from',
+ value: '2016-08-18'
+ },
+ {
+ selector: 'input#to',
+ value: '2016-08-18'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(() => done())
+ })
+
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as user A (admin)", function(done){
+ it('Login as user A (admin)', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(() => done())
+ })
- it("Open requests page", function( done ){
+ it('Open requests page', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host + 'requests/',
+ driver
+ }).then(() => done())
+ })
- it("Approve newly added leave request", function(done){
- let click_selector = `tr[vpp="pending_for__${email_B}"] .btn-success`;
+ it('Approve newly added leave request', function(done) {
+ const click_selector = `tr[vpp="pending_for__${email_B}"] .btn-success`
driver
- .findElement(By.css( click_selector ))
+ .findElement(By.css(click_selector))
.then(el => el.click())
- .then(() => driver.findElement(By.css( click_selector )))
+ .then(() => driver.findElement(By.css(click_selector)))
.then(el => el.click())
- .then(() => driver.findElement(By.css( click_selector )))
+ .then(() => driver.findElement(By.css(click_selector)))
.then(el => el.click())
- .then(() => driver.findElement(By.css( click_selector )))
+ .then(() => driver.findElement(By.css(click_selector)))
.then(el => el.click())
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Logout from user A (admin)", function(done){
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(() => done())
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then( el => el.click() )
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(el => el.click())
// This is very important line when working with Bootstrap modals!
- .then( el => driver.sleep(1000) )
- .then(() => done());
- });
+ .then(el => driver.sleep(1000))
+ .then(() => done())
+ })
- it('As user B cretae a holiday request from 24 Aug to 24 Aug 2016 (but not approved)', function(done){
+ it('As user B cretae a holiday request from 24 Aug to 24 Aug 2016 (but not approved)', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#from',
- value : '2016-08-24',
- },{
- selector : 'input#to',
- value : '2016-08-24',
- }],
- message : /New leave request was added/,
+ driver,
+ form_params: [
+ {
+ selector: 'input#from',
+ value: '2016-08-24'
+ },
+ {
+ selector: 'input#to',
+ value: '2016-08-24'
+ }
+ ],
+ message: /New leave request was added/
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it("Logout from user B", function(done){
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as user A (admin)", function(done){
+ it('Login as user A (admin)', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_A,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: email_A,
+ driver
+ }).then(() => done())
+ })
- it('Navigate to team view and ensure that it shows 9 days were deducted for Aug 2016', function(done){
+ it('Navigate to team view and ensure that it shows 9 days were deducted for Aug 2016', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?date=2016-08',
- driver : driver,
+ url: application_host + 'calendar/teamview/?date=2016-08',
+ driver
})
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt, 'Ensure that system shows 9 days as deducted')
- .to.be.eql('9');
- done();
- });
- });
-
- it('1.5 days deducted for July 2016', function(done){
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt, 'Ensure that system shows 9 days as deducted').to.be.eql(
+ '9'
+ )
+ done()
+ })
+ })
+
+ it('1.5 days deducted for July 2016', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?date=2016-07',
- driver : driver,
+ url: application_host + 'calendar/teamview/?date=2016-07',
+ driver
})
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt, 'Ensure that system shows 1.5 days as deducted')
- .to.be.eql('1.5');
- done();
- });
- });
-
- it('2 days deducted for Sept 2016', function(done){
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt, 'Ensure that system shows 1.5 days as deducted').to.be.eql(
+ '1.5'
+ )
+ done()
+ })
+ })
+
+ it('2 days deducted for Sept 2016', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/?date=2016-09',
- driver : driver,
+ url: application_host + 'calendar/teamview/?date=2016-09',
+ driver
})
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt, 'Ensure that system shows 2 days as deducted')
- .to.be.eql('2');
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(() => done());
- });
-});
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt, 'Ensure that system shows 2 days as deducted').to.be.eql(
+ '2'
+ )
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/team_view/deducted_column__visibility.js b/t/integration/team_view/deducted_column__visibility.js
index 254319de2..f14d52438 100644
--- a/t/integration/team_view/deducted_column__visibility.js
+++ b/t/integration/team_view/deducted_column__visibility.js
@@ -1,6 +1,4 @@
-
-'use strict';
-
+'use strict'
/*
* Scenario:
@@ -24,321 +22,368 @@
*
* */
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- Promise = require("bluebird"),
- expect = require('chai').expect,
- add_new_user_func = require('../../lib/add_new_user'),
- check_elements_func = require('../../lib/check_elements'),
- config = require('../../lib/config'),
- login_user_func = require('../../lib/login_with_user'),
- logout_user_func = require('../../lib/logout_user'),
- open_page_func = require('../../lib/open_page'),
- register_new_user_func = require('../../lib/register_new_user'),
- submit_form_func = require('../../lib/submit_form'),
- user_info_func = require('../../lib/user_info'),
- application_host = config.get_application_host(),
- new_department_form_id = '#add_new_department_form',
- company_edit_form_id ='#company_edit_form';
-
-describe('Check that values for new columns are shown only for employess currently login user can supervise', function(){
-
- this.timeout( config.get_execution_timeout() );
-
- let driver,
- email_A, user_id_A,
- email_B, user_id_B,
- email_C, user_id_C;
-
- it("Register new company as admin user A", function(done){
+const test = require('selenium-webdriver/testing')
+const By = require('selenium-webdriver').By
+const Promise = require('bluebird')
+const expect = require('chai').expect
+const add_new_user_func = require('../../lib/add_new_user')
+const check_elements_func = require('../../lib/check_elements')
+const config = require('../../lib/config')
+const login_user_func = require('../../lib/login_with_user')
+const logout_user_func = require('../../lib/logout_user')
+const open_page_func = require('../../lib/open_page')
+const register_new_user_func = require('../../lib/register_new_user')
+const submit_form_func = require('../../lib/submit_form')
+const user_info_func = require('../../lib/user_info')
+const application_host = config.get_application_host()
+const new_department_form_id = '#add_new_department_form'
+const company_edit_form_id = '#company_edit_form'
+
+describe('Check that values for new columns are shown only for employess currently login user can supervise', function() {
+ this.timeout(config.get_execution_timeout())
+
+ let driver, email_A, user_id_A, email_B, user_id_B, email_C, user_id_C
+
+ it('Register new company as admin user A', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(data => {
+ driver = data.driver
+ email_A = data.email
+ done()
})
- .then(data => {
- driver = data.driver;
- email_A = data.email;
- done();
- });
- });
-
- it("Create second user B", function(done){
+ })
+
+ it('Create second user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(data => {
+ email_B = data.new_user_email
+ done()
})
- .then(data => {
- email_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Create second user C", function(done){
+ it('Create second user C', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(data => {
+ email_C = data.new_user_email
+ done()
})
- .then(data => {
- email_C = data.new_user_email;
- done();
- });
- });
+ })
- it("Obtain information about user A", function(done){
+ it('Obtain information about user A', function(done) {
user_info_func({
- driver : driver,
- email : email_A,
+ driver,
+ email: email_A
+ }).then(data => {
+ user_id_A = data.user.id
+ done()
})
- .then(data => {
- user_id_A = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user B", function(done){
+ it('Obtain information about user B', function(done) {
user_info_func({
- driver : driver,
- email : email_B,
+ driver,
+ email: email_B
+ }).then(data => {
+ user_id_B = data.user.id
+ done()
})
- .then(data => {
- user_id_B = data.user.id;
- done();
- });
- });
+ })
- it("Obtain information about user C", function(done){
+ it('Obtain information about user C', function(done) {
user_info_func({
- driver : driver,
- email : email_C,
+ driver,
+ email: email_C
+ }).then(data => {
+ user_id_C = data.user.id
+ done()
})
- .then(data => {
- user_id_C = data.user.id;
- done();
- });
- });
+ })
- it("Open page for editing company details", function(done){
+ it('Open page for editing company details', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host + 'settings/general/',
+ driver
+ }).then(() => done())
+ })
- it('Ensure company has "Share absences between all employees" flag OFF', function( done ){
+ it('Ensure company has "Share absences between all employees" flag OFF', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : company_edit_form_id+' input[name="share_all_absences"]',
- value : 'off',
- tick : true,
- }],
- })
- .then(() => done());
- });
-
- it('... and tick that box ON', function(done){
+ driver,
+ elements_to_check: [
+ {
+ selector: company_edit_form_id + ' input[name="share_all_absences"]',
+ value: 'off',
+ tick: true
+ }
+ ]
+ }).then(() => done())
+ })
+
+ it('... and tick that box ON', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : company_edit_form_id+' input[name="share_all_absences"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : company_edit_form_id+' button[type="submit"]',
- message : /successfully/i,
- should_be_successful : true,
- })
- .then(() => done());
- });
-
- it("Open department management page", function(done){
+ driver,
+ form_params: [
+ {
+ selector: company_edit_form_id + ' input[name="share_all_absences"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: company_edit_form_id + ' button[type="submit"]',
+ message: /successfully/i,
+ should_be_successful: true
+ }).then(() => done())
+ })
+
+ it('Open department management page', function(done) {
open_page_func({
- url : application_host + 'settings/departments/',
- driver : driver,
- })
- .then(() => done());
- });
+ url: application_host + 'settings/departments/',
+ driver
+ }).then(() => done())
+ })
- it("Add new department and make its approver to be user B", function(done){
+ it('Add new department and make its approver to be user B', function(done) {
driver
.findElement(By.css('#add_new_department_btn'))
.then(el => el.click())
- .then(function(){
-
+ .then(function() {
// This is very important line when working with Bootstrap modals!
- driver.sleep(1000);
+ driver.sleep(1000)
submit_form_func({
- driver : driver,
- form_params : [{
- selector : `${ new_department_form_id } input[name="name__new"]`,
- // Just to make sure it is always first in the lists
- value : 'AAAAA',
- },{
- selector : `${ new_department_form_id } select[name="allowance__new"]`,
- option_selector : 'option[value="15"]',
- value : '15',
- },{
- selector : `${ new_department_form_id } select[name="boss_id__new"]`,
- option_selector : `select[name="boss_id__new"] option[value="${ user_id_B }"]`,
- }],
- submit_button_selector : `${ new_department_form_id } button[type="submit"]`,
- message : /Changes to departments were saved/,
+ driver,
+ form_params: [
+ {
+ selector: `${new_department_form_id} input[name="name__new"]`,
+ // Just to make sure it is always first in the lists
+ value: 'AAAAA'
+ },
+ {
+ selector: `${new_department_form_id} select[name="allowance__new"]`,
+ option_selector: 'option[value="15"]',
+ value: '15'
+ },
+ {
+ selector: `${new_department_form_id} select[name="manager_id__new"]`,
+ option_selector: `select[name="manager_id__new"] option[value="${user_id_B}"]`
+ }
+ ],
+ submit_button_selector: `${new_department_form_id} button[type="submit"]`,
+ message: /Changes to departments were saved/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
- });
+ })
+ })
- it("Open user editing page for user B", function(done){
+ it('Open user editing page for user B', function(done) {
open_page_func({
- url : `${ application_host }users/edit/${ user_id_C }/`,
- driver : driver,
- })
- .then(() => done());
- });
+ url: `${application_host}users/edit/${user_id_C}/`,
+ driver
+ }).then(() => done())
+ })
- it("And make sure it is part of the newly added department", function(done){
+ it('And make sure it is part of the newly added department', function(done) {
submit_form_func({
- submit_button_selector : 'button#save_changes_btn',
- driver : driver,
- form_params : [{
- selector : 'select[name="department"]',
- // Newly added department should be first in the list as it is
- // sorted by AZ and department started with AA
- option_selector : 'select[name="department"] option:nth-child(1)',
- }],
- message : /Details for .* were updated/,
+ submit_button_selector: 'button#save_changes_btn',
+ driver,
+ form_params: [
+ {
+ selector: 'select[name="department"]',
+ // Newly added department should be first in the list as it is
+ // sorted by AZ and department started with AA
+ option_selector: 'select[name="department"] option:nth-child(1)'
+ }
+ ],
+ message: /Details for .* were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('As user A ensure team view shows deducted values for all three users', function(done){
+ it('As user A ensure team view shows deducted values for all three users', function(done) {
open_page_func({
- url : `${ application_host }calendar/teamview/`,
- driver : driver,
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_A}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('0');
- return Promise.resolve(1);
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('0');
- return Promise.resolve(1);
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_C}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('0');
- return Promise.resolve(1);
+ url: `${application_host}calendar/teamview/`,
+ driver
})
-
- .then(function(){ done() });
- });
-
- it("Logout from user A (admin)", function(done){
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_A}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('0')
+ return Promise.resolve(1)
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('0')
+ return Promise.resolve(1)
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_C}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('0')
+ return Promise.resolve(1)
+ })
+
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Logout from user A (admin)', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_B,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: email_B,
+ driver
+ }).then(() => done())
+ })
- it('Login as user B and ensure she sees deducted days only for user B (self) and user C but not for user A', function(done){
+ it('Login as user B and ensure she sees deducted days only for user B (self) and user C but not for user A', function(done) {
open_page_func({
- url : `${ application_host }calendar/teamview/`,
- driver : driver,
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_A}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('');
- return Promise.resolve(1);
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('0');
- return Promise.resolve(1);
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_C}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('0');
- return Promise.resolve(1);
+ url: `${application_host}calendar/teamview/`,
+ driver
})
-
- .then(function(){ done() });
- });
-
- it("Logout from user B", function(done){
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_A}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('')
+ return Promise.resolve(1)
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('0')
+ return Promise.resolve(1)
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_C}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('0')
+ return Promise.resolve(1)
+ })
+
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Logout from user B', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ driver
+ }).then(() => done())
+ })
- it("Login as user C", function(done){
+ it('Login as user C', function(done) {
login_user_func({
- application_host : application_host,
- user_email : email_C,
- driver : driver,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: email_C,
+ driver
+ }).then(() => done())
+ })
- it('Login as user C and ensure she sees only values for her account', function(done){
+ it('Login as user C and ensure she sees only values for her account', function(done) {
open_page_func({
- url : `${ application_host }calendar/teamview/`,
- driver : driver,
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_A}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('');
- return Promise.resolve(1);
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('');
- return Promise.resolve(1);
- })
-
- .then(() => driver.findElement(By.css(`tr[data-vpp-user-list-row="${user_id_C}"] span.teamview-deducted-days`)))
- .then(el => el.getText())
- .then(txt => {
- expect(txt).to.be.eql('0');
- return Promise.resolve(1);
+ url: `${application_host}calendar/teamview/`,
+ driver
})
-
- .then(function(){ done() });
- });
-
- after(function(done){
- driver.quit().then(() => done());
- });
-});
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_A}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('')
+ return Promise.resolve(1)
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_B}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('')
+ return Promise.resolve(1)
+ })
+
+ .then(() =>
+ driver.findElement(
+ By.css(
+ `tr[data-vpp-user-list-row="${user_id_C}"] span.teamview-deducted-days`
+ )
+ )
+ )
+ .then(el => el.getText())
+ .then(txt => {
+ expect(txt).to.be.eql('0')
+ return Promise.resolve(1)
+ })
+
+ .then(function() {
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/team_view/teamview_cross_links.js b/t/integration/team_view/teamview_cross_links.js
index a7f093f24..27d130252 100644
--- a/t/integration/team_view/teamview_cross_links.js
+++ b/t/integration/team_view/teamview_cross_links.js
@@ -1,18 +1,17 @@
+'use strict'
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird"),
- register_new_user_func = require('../../lib/register_new_user'),
- login_user_func = require('../../lib/login_with_user'),
- open_page_func = require('../../lib/open_page'),
- add_new_user_func = require('../../lib/add_new_user'),
- logout_user_func = require('../../lib/logout_user'),
- check_teamview_func = require('../../lib/teamview_check_user'),
- config = require('../../lib/config'),
- application_host = config.get_application_host();
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const Promise = require('bluebird');
+ const register_new_user_func = require('../../lib/register_new_user');
+ const login_user_func = require('../../lib/login_with_user');
+ const open_page_func = require('../../lib/open_page');
+ const add_new_user_func = require('../../lib/add_new_user');
+ const logout_user_func = require('../../lib/logout_user');
+ const check_teamview_func = require('../../lib/teamview_check_user');
+ const config = require('../../lib/config');
+ const application_host = config.get_application_host()
/*
* Scenario to check in thus test.
@@ -25,72 +24,74 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('Cross linking on Teamview page', function(){
-
- this.timeout( config.get_execution_timeout() );
+describe('Cross linking on Teamview page', function() {
+ this.timeout(config.get_execution_timeout())
- var driver, user_A, user_B;
-
- it('Create new company', function( done ){
+ let driver, user_A, user_B
+ it('Create new company', function(done) {
// Performing registration process
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ user_A = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- user_A = data.email;
- done();
- });
- });
+ })
- it("Create new user B", function(done){
+ it('Create new user B', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ user_B = data.new_user_email
+ done()
})
- .then(function(data){
- user_B = data.new_user_email;
- done();
- });
- });
+ })
- it("Make sure that both users are shown on Team view page", function(done){
+ it('Make sure that both users are shown on Team view page', function(done) {
check_teamview_func({
- driver: driver,
+ driver,
emails: [user_A, user_B],
- is_link : true
+ is_link: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Logout from A account", function(done){
+ it('Logout from A account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Login as user B", function(done){
+ it('Login as user B', function(done) {
login_user_func({
- application_host : application_host,
- user_email : user_B,
- driver : driver,
+ application_host,
+ user_email: user_B,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Make sure that only user A and B are presented", function(done){
+ it('Make sure that only user A and B are presented', function(done) {
check_teamview_func({
- driver: driver,
+ driver,
emails: [user_A, user_B],
is_link: false
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/timezone.js b/t/integration/timezone.js
index 371dd307e..f041a57ad 100644
--- a/t/integration/timezone.js
+++ b/t/integration/timezone.js
@@ -1,20 +1,18 @@
+'use strict'
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- register_new_user_func = require('../lib/register_new_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- check_elements_func = require('../lib/check_elements'),
- By = require('selenium-webdriver').By,
- config = require('../lib/config'),
- application_host = config.get_application_host(),
- expect = require('chai').expect,
- Bluebird = require('bluebird'),
- moment = require('moment'),
- company_edit_form_id ='#company_edit_form',
- userStartsAtTheBeginingOfYear = require('../lib/set_user_to_start_at_the_beginning_of_the_year');
+const test = require('selenium-webdriver/testing');
+ const register_new_user_func = require('../lib/register_new_user');
+ const open_page_func = require('../lib/open_page');
+ const submit_form_func = require('../lib/submit_form');
+ const check_elements_func = require('../lib/check_elements');
+ const By = require('selenium-webdriver').By;
+ const config = require('../lib/config');
+ const application_host = config.get_application_host();
+ const expect = require('chai').expect;
+ const Bluebird = require('bluebird');
+ const moment = require('moment');
+ const company_edit_form_id = '#company_edit_form';
+ const userStartsAtTheBeginingOfYear = require('../lib/set_user_to_start_at_the_beginning_of_the_year')
/*
* Basic scenario for checking time zones:
@@ -35,248 +33,292 @@ const
*
* */
-describe('Check Time zones', function(){
- let
- driver,
- user_email,
- today_usa,
- today_tonga;
+describe('Check Time zones', function() {
+ let driver, user_email, today_usa, today_tonga
- this.timeout( config.get_execution_timeout() );
+ this.timeout(config.get_execution_timeout())
- it("Create a company", function(done){
+ it('Create a company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ user_email = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- user_email = data.email;
- done();
- });
- });
+ })
- it("Ensure user starts at the very beginning of current year", done =>{
- userStartsAtTheBeginingOfYear({driver, email:user_email})
- .then(() => open_page_func({ url:application_host,driver}))
+ it('Ensure user starts at the very beginning of current year', function(done) {
+ userStartsAtTheBeginingOfYear({ driver, email: user_email })
+ .then(() => open_page_func({ url: application_host, driver }))
.then(() => done())
- });
+ })
- it("Open page for editing company details", function(done){
+ it('Open page for editing company details', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
- })
- .then(() => done() );
- });
+ url: application_host + 'settings/general/',
+ driver
+ }).then(() => done())
+ })
- it("Update Time zone to be somethng in Tonga", function(done){
+ it('Update Time zone to be somethng in Tonga', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : company_edit_form_id+' select[name="timezone"]',
- option_selector : 'option[value="Pacific/Tongatapu"]',
- value : 'Pacific/Tongatapu',
- }],
- submit_button_selector : company_edit_form_id+' button[type="submit"]',
- message : /successfully/i,
- should_be_successful : true,
+ driver,
+ form_params: [
+ {
+ selector: company_edit_form_id + ' select[name="timezone"]',
+ option_selector: 'option[value="Pacific/Tongatapu"]',
+ value: 'Pacific/Tongatapu'
+ }
+ ],
+ submit_button_selector: company_edit_form_id + ' button[type="submit"]',
+ message: /successfully/i,
+ should_be_successful: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Get the date from Book leave modal and put it into today_tonga variable", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
+ it('Get the date from Book leave modal and put it into today_tonga variable', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(() => driver.sleep(1000))
- .then(() => driver.findElement(By.css( 'input.book-leave-from-input' )))
+ .then(() => driver.findElement(By.css('input.book-leave-from-input')))
.then(el => el.getAttribute('value'))
.then(today => {
- today_tonga = today;
- done();
- });
- });
+ today_tonga = today
+ done()
+ })
+ })
- it("Get the current date from Calendar page and ensure it is the same as today_tonga", function(done){
+ it('Get the current date from Calendar page and ensure it is the same as today_tonga', function(done) {
open_page_func({
- url : application_host + 'calendar/',
- driver : driver,
+ url: application_host + 'calendar/',
+ driver
})
- .then(() => driver.findElement(By.css(
- 'table.month_'+moment(today_tonga).format('MMMM')
- + ' td.half_1st.day_'+moment(today_tonga).format('D')+'.current_day_cell'
- )))
- .then(el => {
- expect(el, 'Ensure that current date is marked correctly').to.exist;
- done();
- });
- });
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.month_' +
+ moment(today_tonga).format('MMMM') +
+ ' td.half_1st.day_' +
+ moment(today_tonga).format('D') +
+ '.current_day_cell'
+ )
+ )
+ )
+ .then(el => {
+ expect(el, 'Ensure that current date is marked correctly').to.exist
+ done()
+ })
+ })
- it("Get the current date from Team view page and ensure it is the same as today_tonga", function(done){
+ it('Get the current date from Team view page and ensure it is the same as today_tonga', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/',
- driver : driver,
+ url: application_host + 'calendar/teamview/',
+ driver
})
- .then(() => driver.findElement(By.css(
- 'table.team-view-table td.half_1st.day_'+moment(today_tonga).format('D')+'.current_day_cell'
- )))
- .then(el => {
- expect(el, 'Ensure that current date is marked correctly').to.exist;
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table td.half_1st.day_' +
+ moment(today_tonga).format('D') +
+ '.current_day_cell'
+ )
+ )
+ )
+ .then(el => {
+ expect(el, 'Ensure that current date is marked correctly').to.exist
- return driver.findElement(By.css('div.calendar-section-caption'))
- })
- .then(el => el.getText())
- .then(month_caption => {
- expect(month_caption, 'Ensure month is correct').to.be.eql(moment(today_tonga).format('MMMM, YYYY'));
- done();
- })
- });
+ return driver.findElement(By.css('div.calendar-section-caption'))
+ })
+ .then(el => el.getText())
+ .then(month_caption => {
+ expect(month_caption, 'Ensure month is correct').to.be.eql(
+ moment(today_tonga).format('MMMM, YYYY')
+ )
+ done()
+ })
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then( el => el.click() )
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(el => driver.sleep(1000))
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Submit new leave request", function(done){
+ it('Submit new leave request', function(done) {
submit_form_func({
- driver : driver,
- form_params : [],
- message : /New leave request was added/,
- })
- .then(() => done());
- });
+ driver,
+ form_params: [],
+ message: /New leave request was added/
+ }).then(() => done())
+ })
- it('Ensure its "created at" value on My requests page is today_tonga', function( done ){
+ it('Ensure its "created at" value on My requests page is today_tonga', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
})
- .then(() => driver.findElement(By.css('tr[vpp="pending_for__'+user_email+'"] td.date_of_request')))
- .then(el => el.getText())
- .then(text => {
- expect(text).to.be.eql(moment(today_tonga).format('YYYY-MM-DD'));
- done();
- });
- });
+ .then(() =>
+ driver.findElement(
+ By.css('tr[vpp="pending_for__' + user_email + '"] td.date_of_request')
+ )
+ )
+ .then(el => el.getText())
+ .then(text => {
+ expect(text).to.be.eql(moment(today_tonga).format('YYYY-MM-DD'))
+ done()
+ })
+ })
- it('Reject newly added leave', function(done){
+ it('Reject newly added leave', function(done) {
driver
- .findElement(By.css('tr[vpp="pending_for__'+user_email+'"] input[value="Reject"]'))
+ .findElement(
+ By.css(
+ 'tr[vpp="pending_for__' + user_email + '"] input[value="Reject"]'
+ )
+ )
.then(el => el.click())
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Open page for editing company details", function(done){
+ it('Open page for editing company details', function(done) {
open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
- })
- .then(() => done() );
- });
+ url: application_host + 'settings/general/',
+ driver
+ }).then(() => done())
+ })
- it("Update Time zone to be Pacific/Midway", function(done){
+ it('Update Time zone to be Pacific/Midway', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : company_edit_form_id+' select[name="timezone"]',
- option_selector : 'option[value="Pacific/Midway"]',
- value : 'Pacific/Midway',
- }],
- submit_button_selector : company_edit_form_id+' button[type="submit"]',
- message : /successfully/i,
- should_be_successful : true,
+ driver,
+ form_params: [
+ {
+ selector: company_edit_form_id + ' select[name="timezone"]',
+ option_selector: 'option[value="Pacific/Midway"]',
+ value: 'Pacific/Midway'
+ }
+ ],
+ submit_button_selector: company_edit_form_id + ' button[type="submit"]',
+ message: /successfully/i,
+ should_be_successful: true
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Get the date from Book leave modal and put it into today_usa", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
+ it('Get the date from Book leave modal and put it into today_usa', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
.then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(() => driver.sleep(1000))
- .then(() => driver.findElement(By.css( 'input.book-leave-from-input' )))
+ .then(() => driver.findElement(By.css('input.book-leave-from-input')))
.then(el => el.getAttribute('value'))
.then(today => {
- today_usa = today;
- done();
- });
- });
+ today_usa = today
+ done()
+ })
+ })
- it("Ensure that today_usa is one day behind the today_tonga", function(done){
- expect(moment(today_usa).format('YYYY-MM-DD')).to.be.not.eql(moment(today_tonga).format('YYYY-MM-DD'));
- done();
- });
+ it('Ensure that today_usa is one day behind the today_tonga', function(done) {
+ expect(moment(today_usa).format('YYYY-MM-DD')).to.be.not.eql(
+ moment(today_tonga).format('YYYY-MM-DD')
+ )
+ done()
+ })
- it("Get the current date from Calendar page and ensure it is the same as today_usa", function(done){
+ it('Get the current date from Calendar page and ensure it is the same as today_usa', function(done) {
open_page_func({
- url : application_host + 'calendar/',
- driver : driver,
+ url: application_host + 'calendar/',
+ driver
})
- .then(() => driver.findElement(By.css(
- 'table.month_'+moment(today_usa).format('MMMM')
- + ' td.half_1st.day_'+moment(today_usa).format('D')+'.current_day_cell'
- )))
- .then(el => {
- expect(el, 'Ensure that current date is marked correctly').to.exist;
- done();
- });
- });
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.month_' +
+ moment(today_usa).format('MMMM') +
+ ' td.half_1st.day_' +
+ moment(today_usa).format('D') +
+ '.current_day_cell'
+ )
+ )
+ )
+ .then(el => {
+ expect(el, 'Ensure that current date is marked correctly').to.exist
+ done()
+ })
+ })
- it("Get the current date from Team view page and ensure it is the same as today_usa", function(done){
+ it('Get the current date from Team view page and ensure it is the same as today_usa', function(done) {
open_page_func({
- url : application_host + 'calendar/teamview/',
- driver : driver,
+ url: application_host + 'calendar/teamview/',
+ driver
})
- .then(() => driver.findElement(By.css(
- 'table.team-view-table td.half_1st.day_'+moment(today_usa).format('D')+'.current_day_cell'
- )))
- .then(el => {
- expect(el, 'Ensure that current date is marked correctly').to.exist;
+ .then(() =>
+ driver.findElement(
+ By.css(
+ 'table.team-view-table td.half_1st.day_' +
+ moment(today_usa).format('D') +
+ '.current_day_cell'
+ )
+ )
+ )
+ .then(el => {
+ expect(el, 'Ensure that current date is marked correctly').to.exist
- return driver.findElement(By.css('div.calendar-section-caption'))
- })
- .then(el => el.getText())
- .then(month_caption => {
- expect(month_caption, 'Ensure month is correct').to.be.eql(moment(today_usa).format('MMMM, YYYY'));
- done();
- })
- });
+ return driver.findElement(By.css('div.calendar-section-caption'))
+ })
+ .then(el => el.getText())
+ .then(month_caption => {
+ expect(month_caption, 'Ensure month is correct').to.be.eql(
+ moment(today_usa).format('MMMM, YYYY')
+ )
+ done()
+ })
+ })
- it("Open Book leave popup window", function(done){
- driver.findElement(By.css('#book_time_off_btn'))
- .then( el => el.click() )
+ it('Open Book leave popup window', function(done) {
+ driver
+ .findElement(By.css('#book_time_off_btn'))
+ .then(el => el.click())
// This is very important line when working with Bootstrap modals!
.then(el => driver.sleep(1000))
- .then(() => done());
- });
+ .then(() => done())
+ })
- it("Submit new leave request", function(done){
+ it('Submit new leave request', function(done) {
submit_form_func({
- driver : driver,
- form_params : [],
- message : /New leave request was added/,
- })
- .then(() => done());
- });
+ driver,
+ form_params: [],
+ message: /New leave request was added/
+ }).then(() => done())
+ })
- it('Ensure its "created at" value on My requests page is today_usa', function( done ){
+ it('Ensure its "created at" value on My requests page is today_usa', function(done) {
open_page_func({
- url : application_host + 'requests/',
- driver : driver,
+ url: application_host + 'requests/',
+ driver
})
- .then(() => driver.findElement(By.css('tr[vpp="pending_for__'+user_email+'"] td.date_of_request')))
- .then(el => el.getText())
- .then(text => {
- expect(text).to.be.eql(moment(today_usa).format('YYYY-MM-DD'));
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(() => done());
- });
+ .then(() =>
+ driver.findElement(
+ By.css('tr[vpp="pending_for__' + user_email + '"] td.date_of_request')
+ )
+ )
+ .then(el => el.getText())
+ .then(text => {
+ expect(text).to.be.eql(moment(today_usa).format('YYYY-MM-DD'))
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(() => done())
+ })
+})
diff --git a/t/integration/try_to_open_private_pages_with_guest.js b/t/integration/try_to_open_private_pages_with_guest.js
index 8b572c8cc..94d60545e 100644
--- a/t/integration/try_to_open_private_pages_with_guest.js
+++ b/t/integration/try_to_open_private_pages_with_guest.js
@@ -1,143 +1,137 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- config = require('../lib/config'),
- application_host = config.get_application_host(),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- until = require('selenium-webdriver').until,
- login_user_func = require('../lib/login_with_user'),
- register_new_user_func = require('../lib/register_new_user'),
- logout_user_func = require('../lib/logout_user'),
- add_new_user_func = require('../lib/add_new_user'),
- build_driver = require('../lib/build_driver');
-
-
-describe('Try to access private pages with guest user', function(){
-
- this.timeout( config.get_execution_timeout() );
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host();
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const until = require('selenium-webdriver').until;
+ const login_user_func = require('../lib/login_with_user');
+ const register_new_user_func = require('../lib/register_new_user');
+ const logout_user_func = require('../lib/logout_user');
+ const add_new_user_func = require('../lib/add_new_user');
+ const build_driver = require('../lib/build_driver')
+
+describe('Try to access private pages with guest user', function() {
+ this.timeout(config.get_execution_timeout())
it('Check pages', function(done) {
-
- Promise.all(_.map(
- // Add more URLs to check into the array below
- [
- 'logout/', 'settings/general/', 'settings/departments/'
- ],
- function(path) {
-
- var driver = build_driver()
-
- // Open front page
- driver.get( application_host + path);
- driver.getCurrentUrl()
- .then(function(url){
- expect(url).to.be.equal(application_host+'login/');
- });
-
- return driver.quit();
- })
- )
- .then(function(){ done() });
- });
+ Promise.all(
+ _.map(
+ // Add more URLs to check into the array below
+ ['logout/', 'settings/general/', 'settings/departments/'],
+ function(path) {
+ const driver = build_driver()
+
+ // Open front page
+ driver.get(application_host + path)
+ driver.getCurrentUrl().then(function(url) {
+ expect(url).to.be.equal(application_host + 'login/')
+ })
+
+ return driver.quit()
+ }
+ )
+ ).then(function() {
+ done()
+ })
+ })
it('Check main (dashboard) page', function(done) {
- var driver = build_driver();
+ const driver = build_driver()
// Open front page
- driver.get( application_host);
- driver.getTitle()
- .then(function(title){
- expect(title).to.be.equal('Time Off Management');
- });
- driver.quit().then(function(){ done() });
- });
-
-});
-
-
-describe('Try to access admin pages with non-admin user', function(){
-
- this.timeout( config.get_execution_timeout() );
+ driver.get(application_host)
+ driver.getTitle().then(function(title) {
+ expect(title).to.be.equal('Time Off Management')
+ })
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
- var non_admin_user_email, driver;
+describe('Try to access admin pages with non-admin user', function() {
+ this.timeout(config.get_execution_timeout())
- var check_pathes = function(driver, reachable){
+ let non_admin_user_email, driver
- var admin_pages = [
+ const check_pathes = function(driver, reachable) {
+ const admin_pages = [
'users/add/',
'users/',
'settings/general/',
'settings/departments/'
- ];
-
- return Promise.each(admin_pages, function(path){
- driver.get( application_host + path);
- driver.wait(until.elementLocated(By.css('body')), 1000);
- return driver.getCurrentUrl()
- .then(function(url){
- if (reachable) {
- expect(url).to.be.equal(application_host + path);
- } else {
- expect(url).to.be.equal(application_host + 'calendar/');
- }
- });
+ ]
+
+ return Promise.each(admin_pages, function(path) {
+ driver.get(application_host + path)
+ driver.wait(until.elementLocated(By.css('body')), 1000)
+ return driver.getCurrentUrl().then(function(url) {
+ if (reachable) {
+ expect(url).to.be.equal(application_host + path)
+ } else {
+ expect(url).to.be.equal(application_host + 'calendar/')
+ }
+ })
})
- };
+ }
- it("Register new admin user", function(done){
+ it('Register new admin user', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
-
- it("Iterate through admin pages and make sure they are accessible", function(done){
- check_pathes(driver, true)
- .then(function(){ done() });
- });
-
- it("Add new non-admin user", function(done){
+ })
+
+ it('Iterate through admin pages and make sure they are accessible', function(done) {
+ check_pathes(driver, true).then(function() {
+ done()
+ })
+ })
+
+ it('Add new non-admin user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ non_admin_user_email = data.new_user_email
+ done()
})
- .then(function(data){
- non_admin_user_email = data.new_user_email;
- done();
- });
- });
+ })
- it("Logout from admin account", function(done){
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("And login with newly created non-admin account", function(done){
+ it('And login with newly created non-admin account', function(done) {
login_user_func({
- application_host : application_host,
- user_email : non_admin_user_email,
- driver : driver,
+ application_host,
+ user_email: non_admin_user_email,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Iterate throough pathes and make sure they are not reachable", function(done){
- check_pathes(driver, false)
- .then(function(){ done() });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
+ it('Iterate throough pathes and make sure they are not reachable', function(done) {
+ check_pathes(driver, false).then(function() {
+ done()
+ })
+ })
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/try_to_register_with_loggedon_user.js b/t/integration/try_to_register_with_loggedon_user.js
index 6721a1a9d..51128ca32 100644
--- a/t/integration/try_to_register_with_loggedon_user.js
+++ b/t/integration/try_to_register_with_loggedon_user.js
@@ -1,14 +1,12 @@
+'use strict'
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- config = require('../lib/config'),
- application_host = config.get_application_host(),
- expect = require('chai').expect,
- Promise = require("bluebird"),
- register_new_user_func = require('../lib/register_new_user'),
- open_page_func = require('../lib/open_page');
+const test = require('selenium-webdriver/testing');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host();
+ const expect = require('chai').expect;
+ const Promise = require('bluebird');
+ const register_new_user_func = require('../lib/register_new_user');
+ const open_page_func = require('../lib/open_page')
/*
At this moment there is a bug when anyone can hijack acount if primary email
@@ -21,41 +19,39 @@ var test = require('selenium-webdriver/testing'),
*/
-describe('Try to open registeration page with active user in a session', function(){
+describe('Try to open registeration page with active user in a session', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let admin_email, driver
- var admin_email, driver;
-
- it("Create new company", function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it('Try to open Registration page', function(done){
+ it('Try to open Registration page', function(done) {
open_page_func({
- url : application_host + 'register/',
- driver : driver,
+ url: application_host + 'register/',
+ driver
+ }).then(function() {
+ done()
+ })
+ })
+
+ it('Make sure that user is landed on calendar page', function(done) {
+ driver.getCurrentUrl().then(function(url) {
+ expect(url).to.be.equal(application_host + 'calendar/')
+ done()
+ })
+ })
+
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
})
- .then(function(){ done() });
- });
-
- it("Make sure that user is landed on calendar page", function(done){
- driver
- .getCurrentUrl()
- .then(function(url){
- expect(url).to.be.equal(application_host+'calendar/')
- done();
- });
- });
-
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ })
+})
diff --git a/t/integration/try_to_revoke_admin_rights_from_last_admin.js b/t/integration/try_to_revoke_admin_rights_from_last_admin.js
index 440c4d566..cd022f1f1 100644
--- a/t/integration/try_to_revoke_admin_rights_from_last_admin.js
+++ b/t/integration/try_to_revoke_admin_rights_from_last_admin.js
@@ -1,20 +1,19 @@
-
-'use strict';
-
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- check_elements_func = require('../lib/check_elements'),
- add_new_user_func = require('../lib/add_new_user'),
- config = require('../lib/config'),
- user_info_func = require('../lib/user_info'),
- application_host = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const register_new_user_func = require('../lib/register_new_user');
+ const login_user_func = require('../lib/login_with_user');
+ const open_page_func = require('../lib/open_page');
+ const submit_form_func = require('../lib/submit_form');
+ const check_elements_func = require('../lib/check_elements');
+ const add_new_user_func = require('../lib/add_new_user');
+ const config = require('../lib/config');
+ const user_info_func = require('../lib/user_info');
+ const application_host = config.get_application_host()
/*
* Scenario to ensure system prevent revocking admin rights from very last admin within company.
@@ -27,141 +26,161 @@ var test = require('selenium-webdriver/testing'),
*
* */
-describe('System prevent revoking admin rights from very last admin within company', function(){
+describe('System prevent revoking admin rights from very last admin within company', function() {
+ this.timeout(config.get_execution_timeout())
- this.timeout( config.get_execution_timeout() );
+ let email_admin, secondary_user, driver
- var email_admin, secondary_user, driver;
-
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(function(data) {
+ driver = data.driver
+ email_admin = data.email
+ done()
})
- .then(function(data){
- driver = data.driver;
- email_admin = data.email;
- done();
- });
- });
+ })
- it("Create second user", function(done){
+ it('Create second user', function(done) {
add_new_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function(data) {
+ ;(secondary_user = data.new_user_email), done()
})
- .then(function(data){
- secondary_user = data.new_user_email,
- done();
- });
- });
+ })
- it('Open Admin user edit details page', function(done){
+ it('Open Admin user edit details page', function(done) {
user_info_func({
- driver : driver,
- email : email_admin,
- })
- .then(function(data){
- return open_page_func({
- driver : driver,
- url : application_host + 'users/edit/'+data.user.id+'/',
- });
+ driver,
+ email: email_admin
})
- .then(function(){done()});
- });
-
- it('Ensure that Admin tickbox is checked', function(done){
+ .then(function(data) {
+ return open_page_func({
+ driver,
+ url: application_host + 'users/edit/' + data.user.id + '/'
+ })
+ })
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that Admin tickbox is checked', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'on',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'on'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Try to untick the Is Admin flag and make sure system prevent from doing it', function(done){
+ it('Try to untick the Is Admin flag and make sure system prevent from doing it', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message: /This is last admin within company. Cannot revoke admin rights./,
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /This is last admin within company. Cannot revoke admin rights./
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Open detail page for second employee', function(done){
+ it('Open detail page for second employee', function(done) {
user_info_func({
- driver : driver,
- email : secondary_user,
- })
- .then(function(data){
- return open_page_func({
- driver : driver,
- url : application_host + 'users/edit/'+data.user.id+'/',
- });
+ driver,
+ email: secondary_user
})
- .then(function(){ done() });
- });
-
- it('Ensure that Admin tickbox is not checked', function(done){
+ .then(function(data) {
+ return open_page_func({
+ driver,
+ url: application_host + 'users/edit/' + data.user.id + '/'
+ })
+ })
+ .then(function() {
+ done()
+ })
+ })
+
+ it('Ensure that Admin tickbox is not checked', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'off',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'off'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Make secondary user to be admin', function(done){
+ it('Make secondary user to be admin', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'on',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message: /Details for .* were updated/,
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'on'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Ensure that secondary user bacame admin', function(done){
+ it('Ensure that secondary user bacame admin', function(done) {
check_elements_func({
- driver : driver,
- elements_to_check : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'on',
- }],
+ driver,
+ elements_to_check: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'on'
+ }
+ ]
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Revoke admin rights from secondary user', function(done){
+ it('Revoke admin rights from secondary user', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="admin"]',
- tick : true,
- value : 'off',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message: /Details for .* were updated/,
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="admin"]',
+ tick: true,
+ value: 'off'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/user_edit_non_default_dates.js b/t/integration/user_edit_non_default_dates.js
index e57a7f6ad..5982f83fc 100644
--- a/t/integration/user_edit_non_default_dates.js
+++ b/t/integration/user_edit_non_default_dates.js
@@ -1,69 +1,73 @@
+'use strict'
-'use strict';
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const register_new_user_func = require('../lib/register_new_user');
+ const login_user_func = require('../lib/login_with_user');
+ const open_page_func = require('../lib/open_page');
+ const submit_form_func = require('../lib/submit_form');
+ const add_new_user_func = require('../lib/add_new_user');
+ const config = require('../lib/config');
+ const application_host = config.get_application_host()
-var test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- add_new_user_func = require('../lib/add_new_user'),
- config = require('../lib/config'),
- application_host = config.get_application_host();
+describe('Try to use non defaul date formats for editing employee details', function() {
+ this.timeout(config.get_execution_timeout())
-describe("Try to use non defaul date formats for editing employee details", function(){
+ let driver
- this.timeout( config.get_execution_timeout() );
-
- var driver;
-
- it("Register new company with default date to be DD/MM/YY", function(done){
+ it('Register new company with default date to be DD/MM/YY', function(done) {
register_new_user_func({
- application_host : application_host,
- default_date_format : 'DD/MM/YY',
+ application_host,
+ default_date_format: 'DD/MM/YY'
+ }).then(function(data) {
+ driver = data.driver
+ done()
})
- .then(function(data){
- driver = data.driver;
- done();
- });
- });
+ })
- it("Open employee list page", function(done){
+ it('Open employee list page', function(done) {
open_page_func({
- url : application_host + 'users/',
- driver : driver,
+ url: application_host + 'users/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it("Open employee details page", function(done){
+ it('Open employee details page', function(done) {
driver
- .findElement(By.css( 'td.user-link-cell a' ))
- .then(function(element){
+ .findElement(By.css('td.user-link-cell a'))
+ .then(function(element) {
return element.click()
})
- .then(function(){ done() });
- });
+ .then(function() {
+ done()
+ })
+ })
- it("Update Start date to be date that was reportedly problematic", function(done){
+ it('Update Start date to be date that was reportedly problematic', function(done) {
submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input#start_date_inp',
- value : '22/08/17',
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .* were updated/,
-// should_be_successful : true,
+ driver,
+ form_params: [
+ {
+ selector: 'input#start_date_inp',
+ value: '22/08/17'
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ // should_be_successful : true,
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- after(function(done){
- driver.quit().then(function(){ done(); });
- });
-
-});
+ after(function(done) {
+ driver.quit().then(function() {
+ done()
+ })
+ })
+})
diff --git a/t/integration/users_import.js b/t/integration/users_import.js
index 07e8dceb1..e0ff5b0ac 100644
--- a/t/integration/users_import.js
+++ b/t/integration/users_import.js
@@ -1,23 +1,21 @@
-
-'use strict';
-
-const
- test = require('selenium-webdriver/testing'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird"),
- fs = Promise.promisifyAll(require('fs')),
- csv = Promise.promisifyAll(require('csv')),
- register_new_user_func = require('../lib/register_new_user'),
- login_user_func = require('../lib/login_with_user'),
- logout_user_func = require('../lib/logout_user'),
- open_page_func = require('../lib/open_page'),
- submit_form_func = require('../lib/submit_form'),
- add_new_user_func = require('../lib/add_new_user'),
- config = require('../lib/config'),
- user_info_func = require('../lib/user_info'),
- application_host = config.get_application_host();
+'use strict'
+
+const test = require('selenium-webdriver/testing');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const fs = Promise.promisifyAll(require('fs'));
+ const csv = Promise.promisifyAll(require('csv'));
+ const register_new_user_func = require('../lib/register_new_user');
+ const login_user_func = require('../lib/login_with_user');
+ const logout_user_func = require('../lib/logout_user');
+ const open_page_func = require('../lib/open_page');
+ const submit_form_func = require('../lib/submit_form');
+ const add_new_user_func = require('../lib/add_new_user');
+ const config = require('../lib/config');
+ const user_info_func = require('../lib/user_info');
+ const application_host = config.get_application_host()
/*
* Scenario to check:
@@ -32,135 +30,142 @@ const
*
* */
+describe('Bulk import of users', function() {
+ this.timeout(config.get_execution_timeout())
-describe('Bulk import of users', function(){
-
- this.timeout( config.get_execution_timeout() );
-
- let email_admin,
- driver,
- csv_data,
- sample_email,
- test_users_filename = __dirname +'/test.csv';
+ let email_admin;
+ let driver;
+ let csv_data;
+ let sample_email;
+ const test_users_filename = __dirname + '/test.csv'
- it('Create new company', function(done){
+ it('Create new company', function(done) {
register_new_user_func({
- application_host : application_host,
+ application_host
+ }).then(data => {
+ driver = data.driver
+ done()
})
- .then(data => {
- driver = data.driver;
- done();
- });
- });
+ })
- it('Navigate to bulk upload page', function(done){
+ it('Navigate to bulk upload page', function(done) {
open_page_func({
- url : application_host + 'users/import/',
- driver : driver,
+ url: application_host + 'users/import/',
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){ done() });
- });
+ })
- it('Create test .CSV file for the test', function(done){
- csv_data = [['email', 'name', 'lastname', 'department']];
+ it('Create test .CSV file for the test', function(done) {
+ csv_data = [['email', 'name', 'lastname', 'department']]
- let token = (new Date()).getTime();
- for (let i=0; i<10; i++){
+ const token = new Date().getTime()
+ for (let i = 0; i < 10; i++) {
csv_data.push([
- 'test_csv_'+i+'_'+token+'@test.com',
- 'name_csv_'+i+'_'+token+'@test.com',
- 'lastname_csv_'+i+'_'+token+'@test.com',
+ 'test_csv_' + i + '_' + token + '@test.com',
+ 'name_csv_' + i + '_' + token + '@test.com',
+ 'lastname_csv_' + i + '_' + token + '@test.com',
'Sales'
- ]);
+ ])
}
// Safe one of the emails
- sample_email = csv_data[1][0];
+ sample_email = csv_data[1][0]
Promise.resolve()
.then(() => fs.unlinkAsync(test_users_filename))
.catch(err => Promise.resolve())
- .then(() => csv.stringifyAsync( csv_data ))
+ .then(() => csv.stringifyAsync(csv_data))
.then(data => fs.writeFileAsync(test_users_filename, data))
- .then(() => done());
- });
-
- it('Upload user import file', function(done){
- let regex = new RegExp(
- 'Successfully imported users with following emails: '
- + csv_data.slice(1).map(it => it[0]).sort().join(', ')
- );
+ .then(() => done())
+ })
+
+ it('Upload user import file', function(done) {
+ const regex = new RegExp(
+ 'Successfully imported users with following emails: ' +
+ csv_data
+ .slice(1)
+ .map(it => it[0])
+ .sort()
+ .join(', ')
+ )
submit_form_func({
- submit_button_selector : '#submit_users_btn',
- driver : driver,
- form_params : [{
- selector : '#users_input_inp',
- value : test_users_filename,
- file : true,
- }],
- message : regex,
- })
- .then(() => done());
- });
-
- it('Ensure that imported users are in the system', function(done){
- let users_ids;
+ submit_button_selector: '#submit_users_btn',
+ driver,
+ form_params: [
+ {
+ selector: '#users_input_inp',
+ value: test_users_filename,
+ file: true
+ }
+ ],
+ message: regex
+ }).then(() => done())
+ })
+
+ it('Ensure that imported users are in the system', function(done) {
+ let users_ids
// Get IDs of newly added users
- Promise.map(csv_data.slice(1).map(it => it[0]), email => {
- return user_info_func({
- driver : driver,
- email : email,
+ Promise.map(csv_data.slice(1).map(it => it[0]), email => user_info_func({
+ driver,
+ email
+ }).then(data => data.user.id))
+ // Open users page
+ .then(ids => {
+ users_ids = ids
+
+ return open_page_func({
+ url: application_host + 'users/',
+ driver
+ })
})
- .then(data => data.user.id);
- })
- // Open users page
- .then(ids => {
- users_ids = ids;
-
- return open_page_func({
- url : application_host + 'users/',
- driver : driver,
- });
- })
-
- // Ensure that IDs of newly added users are on th Users page
- .then(() => Promise.map(users_ids, id => driver
- .findElement(By.css('[data-vpp-user-row="'+id+'"]'))
- .then(el => {
- expect(el, 'Ensure that newly added user ID '+id+' exists on Users page')
- .to.exists;
- return Promise.resolve();
- })
- ))
- .then(() => done());
- });
-
- it("Logout from admin account", function(done){
+ // Ensure that IDs of newly added users are on th Users page
+ .then(() =>
+ Promise.map(users_ids, id =>
+ driver
+ .findElement(By.css('[data-vpp-user-row="' + id + '"]'))
+ .then(el => {
+ expect(
+ el,
+ 'Ensure that newly added user ID ' +
+ id +
+ ' exists on Users page'
+ ).to.exists
+ return Promise.resolve()
+ })
+ )
+ )
+
+ .then(() => done())
+ })
+
+ it('Logout from admin account', function(done) {
logout_user_func({
- application_host : application_host,
- driver : driver,
+ application_host,
+ driver
+ }).then(function() {
+ done()
})
- .then(function(){done()});
- });
+ })
- it('Now try to login as newly added employee using "undefined" as password..', done => {
+ it('Now try to login as newly added employee using "undefined" as password..', function(done) {
login_user_func({
- application_host : application_host,
- user_email : sample_email,
- driver : driver,
- password : 'undefined',
- should_fail : true,
- })
- .then(() => done());
- });
+ application_host,
+ user_email: sample_email,
+ driver,
+ password: 'undefined',
+ should_fail: true
+ }).then(() => done())
+ })
- after(function(done){
+ after(function(done) {
Promise.resolve()
.then(() => driver.quit())
.then(() => fs.unlinkAsync(test_users_filename))
.catch(err => Promise.resolve())
- .then(() => done());
- });
-});
+ .then(() => done())
+ })
+})
diff --git a/t/lib/add_new_user.js b/t/lib/add_new_user.js
index 89b0f89a1..cfda5eba4 100644
--- a/t/lib/add_new_user.js
+++ b/t/lib/add_new_user.js
@@ -1,89 +1,83 @@
-
-'use strict';
-
-var By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- until = require('selenium-webdriver').until,
- Promise = require("bluebird"),
- uuid = require('node-uuid'),
- submit_form_func = require('./submit_form'),
- build_driver = require('./build_driver'),
- add_new_user_form_id = '#add_new_user_form',
- driver;
-
-
-module.exports = Promise.promisify(function(args, callback){
-
- var application_host = args.application_host,
- result_callback = callback,
- department_index = args.department_index,
- // optional parameter, if provided the user adding action is expected to fail
- // with that error
- error_message = args.error_message,
-
- driver = args.driver || build_driver();
-
- var random_token = (new Date()).getTime();
- var new_user_email = args.email || random_token + '@test.com';
+'use strict'
+
+const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const until = require('selenium-webdriver').until;
+ const Promise = require('bluebird');
+ const uuid = require('node-uuid');
+ const submit_form_func = require('./submit_form');
+ const build_driver = require('./build_driver');
+ const add_new_user_form_id = '#add_new_user_form';
+ let driver
+
+module.exports = Promise.promisify(function(args, callback) {
+ const application_host = args.application_host;
+ const result_callback = callback;
+ const department_index = args.department_index;
+ // optional parameter, if provided the user adding action is expected to fail
+ // with that error
+ const error_message = args.error_message;
+ const driver = args.driver || build_driver()
+
+ const random_token = new Date().getTime()
+ const new_user_email = args.email || random_token + '@test.com'
// Open front page
- driver.get( application_host + 'users/add/');
-
+ driver.get(application_host + 'users/add/')
driver.call(() => {
-
- var select_department = {};
+ let select_department = {}
if (typeof department_index !== 'undefined') {
-
select_department = {
- selector : 'select[name="department"]',
- option_selector : 'option[data-vpp="'+department_index+'"]',
- };
+ selector: 'select[name="department"]',
+ option_selector: 'option[data-vpp="' + department_index + '"]'
+ }
}
return submit_form_func({
- driver : driver,
- form_params : [{
- selector : add_new_user_form_id+' input[name="name"]',
- value : 'name'+random_token,
- },{
- selector : add_new_user_form_id+' input[name="lastname"]',
- value : 'lastname'+random_token,
- },{
- selector : add_new_user_form_id+' input[name="email_address"]',
- value : new_user_email,
- },{
- selector : add_new_user_form_id+' input[name="password_one"]',
- value : '123456',
- },{
- selector : add_new_user_form_id+' input[name="password_confirm"]',
- value : '123456',
+ driver,
+ form_params: [
+ {
+ selector: add_new_user_form_id + ' input[name="name"]',
+ value: 'name' + random_token
+ },
+ {
+ selector: add_new_user_form_id + ' input[name="lastname"]',
+ value: 'lastname' + random_token
+ },
+ {
+ selector: add_new_user_form_id + ' input[name="email_address"]',
+ value: new_user_email
+ },
+ {
+ selector: add_new_user_form_id + ' input[name="password_one"]',
+ value: '123456'
},
- select_department, {
- selector : add_new_user_form_id+' input[name="start_date"]',
- value : '2015-06-01',
+ {
+ selector: add_new_user_form_id + ' input[name="password_confirm"]',
+ value: '123456'
},
- ],
- submit_button_selector : add_new_user_form_id+' #add_new_user_btn',
- should_be_successful : error_message ? false : true,
- elements_to_check : [],
- message : error_message ?
- new RegExp(error_message) :
- /New user account successfully added/,
- });
+ select_department,
+ {
+ selector: add_new_user_form_id + ' input[name="start_date"]',
+ value: '2015-06-01'
+ }
+ ],
+ submit_button_selector: add_new_user_form_id + ' #add_new_user_btn',
+ should_be_successful: !error_message,
+ elements_to_check: [],
+ message: error_message
+ ? new RegExp(error_message)
+ : /New user account successfully added/
+ })
})
- driver.call(function(){
+ driver.call(function() {
// "export"
- result_callback(
- null,
- {
- driver : driver,
- new_user_email : new_user_email,
- }
- );
- });
-});
-
-
+ result_callback(null, {
+ driver,
+ new_user_email
+ })
+ })
+})
diff --git a/t/lib/build_driver.js b/t/lib/build_driver.js
index 7a2333194..f85344279 100644
--- a/t/lib/build_driver.js
+++ b/t/lib/build_driver.js
@@ -1,22 +1,22 @@
-var webdriver = require('selenium-webdriver'),
- chrome = require('selenium-webdriver/chrome')
- capabilities = process.env.USE_CHROME ? 'chrome' : 'phantomjs';
+const webdriver = require('selenium-webdriver')
+const chrome = require('selenium-webdriver/chrome')
+const capabilities = process.env.USE_CHROME ? 'chrome' : 'phantomjs'
module.exports = function() {
if (capabilities === 'phantomjs') {
return new webdriver.Builder()
.withCapabilities(webdriver.Capabilities[capabilities]())
- .build();
+ .build()
}
- var options = new chrome.Options();
+ const options = new chrome.Options()
if (!process.env.SHOW_CHROME) {
- options.addArguments('headless');
+ options.addArguments('headless')
options.addArguments('disable-gpu')
}
return new webdriver.Builder()
.withCapabilities(webdriver.Capabilities[capabilities]())
.setChromeOptions(options)
- .build();
+ .build()
}
diff --git a/t/lib/check_booking_on_calendar.js b/t/lib/check_booking_on_calendar.js
index 7a80d72a8..96af3023a 100644
--- a/t/lib/check_booking_on_calendar.js
+++ b/t/lib/check_booking_on_calendar.js
@@ -1,64 +1,70 @@
-'use strict';
+'use strict'
-var webdriver = require('selenium-webdriver'),
- _ = require('underscore'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- Promise = require("bluebird");
+const webdriver = require('selenium-webdriver');
+ const _ = require('underscore');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const Promise = require('bluebird')
-var check_booking_func = Promise.promisify( function(args, callback){
-
- var driver = args.driver,
- type = args.type,
- full_days = args.full_days,
- halfs_1st_days = args.halfs_1st_days || [],
- halfs_2nd_days = args.halfs_2nd_days || [],
- result_callback = callback,
- type_css_re;
+const check_booking_func = Promise.promisify(function(args, callback) {
+ const driver = args.driver;
+ const type = args.type;
+ const full_days = args.full_days;
+ const halfs_1st_days = args.halfs_1st_days || [];
+ const halfs_2nd_days = args.halfs_2nd_days || [];
+ const result_callback = callback;
+ let type_css_re
if (type === 'pended') {
- type_css_re = /\bleave_cell_pended\b/;
+ type_css_re = /\bleave_cell_pended\b/
} else if (type === 'approved') {
- type_css_re = /\bleave_cell\b/;
+ type_css_re = /\bleave_cell\b/
} else {
- throw new Error('Mandatory type parameter was not provided');
+ throw new Error('Mandatory type parameter was not provided')
}
Promise.all([
- _.map([
- {days : full_days , halfs : ['half_1st' , 'half_2nd']},
- {days : halfs_1st_days , halfs : ['half_1st']},
- {days : halfs_2nd_days , halfs : ['half_2nd']},
- ], function(option) {
- return _.map(option.days, function(day){
+ _.map(
+ [
+ { days: full_days, halfs: ['half_1st', 'half_2nd'] },
+ { days: halfs_1st_days, halfs: ['half_1st'] },
+ { days: halfs_2nd_days, halfs: ['half_2nd'] }
+ ],
+ function(option) {
+ return _.map(option.days, function(day) {
return Promise.all([
- _.map(option.halfs, function(half){
-
- var selector = 'table.month_'+day.format('MMMM')+' td.day_'
- +day.format('D')+'.'+half;
+ _.map(option.halfs, function(half) {
+ const selector =
+ 'table.month_' +
+ day.format('MMMM') +
+ ' td.day_' +
+ day.format('D') +
+ '.' +
+ half
- return driver.findElement( By.css(selector) )
- .then(function(el){ return el.getAttribute('class'); })
- .then(function(css){
- expect(css).to.match(type_css_re);
+ return driver
+ .findElement(By.css(selector))
+ .then(function(el) {
+ return el.getAttribute('class')
+ })
+ .then(function(css) {
+ expect(css).to.match(type_css_re)
})
})
- ]);
- });
- })
- ])
- .then(function(){
- // "export" current driver
- result_callback(
- null,
- {
- driver : driver,
+ ])
+ })
}
- );
- });
-
-});
+ )
+ ]).then(function() {
+ // "export" current driver
+ result_callback(null, {
+ driver
+ })
+ })
+})
-module.exports = function(args){
- return args.driver.call(function(){return check_booking_func(args)});
+module.exports = function(args) {
+ return args.driver.call(function() {
+ return check_booking_func(args)
+ })
}
diff --git a/t/lib/check_elements.js b/t/lib/check_elements.js
index a3d8a8000..eb02b5654 100644
--- a/t/lib/check_elements.js
+++ b/t/lib/check_elements.js
@@ -1,52 +1,43 @@
-'use strict';
-
-var webdriver = require('selenium-webdriver'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- _ = require('underscore'),
- Promise = require("bluebird");
-
-
-var check_elements_func = Promise.promisify( function(args, callback){
-
- var driver = args.driver,
- result_callback = callback,
- elements_to_check = args.elements_to_check || [];
-
-
- Promise.all([
- _.map(
- elements_to_check,
- function( test_case ){
- driver
- .findElement(By.css( test_case.selector ))
- .then(function(el){
- if (test_case.hasOwnProperty('tick')) {
- return el.isSelected().then(function(yes){
- return Promise.resolve( yes ? 'on' : 'off');
- });
- } else {
- return el.getAttribute('value');
- }
- })
- .then(function(text){
- expect(text).to.be.equal( test_case.value );
- });
+'use strict'
+
+const webdriver = require('selenium-webdriver');
+ const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird')
+
+const check_elements_func = Promise.promisify(function(args, callback) {
+ const driver = args.driver;
+ const result_callback = callback;
+ const elements_to_check = args.elements_to_check || []
+
+ Promise.all([
+ _.map(elements_to_check, function(test_case) {
+ driver
+ .findElement(By.css(test_case.selector))
+ .then(function(el) {
+ if (test_case.hasOwnProperty('tick')) {
+ return el.isSelected().then(function(yes) {
+ return Promise.resolve(yes ? 'on' : 'off')
})
- ])
-
- .then(function(){
-
- // "export" current driver
- result_callback(
- null,
- {
- driver : driver,
- }
- );
- });
-});
-
-module.exports = function(args){
- return args.driver.call(function(){return check_elements_func(args)});
+ } else {
+ return el.getAttribute('value')
+ }
+ })
+ .then(function(text) {
+ expect(text).to.be.equal(test_case.value)
+ })
+ })
+ ]).then(function() {
+ // "export" current driver
+ result_callback(null, {
+ driver
+ })
+ })
+})
+
+module.exports = function(args) {
+ return args.driver.call(function() {
+ return check_elements_func(args)
+ })
}
diff --git a/t/lib/config.js b/t/lib/config.js
index 60d5827d5..b7b77f905 100644
--- a/t/lib/config.js
+++ b/t/lib/config.js
@@ -5,18 +5,18 @@
*
* */
-"use strict";
+'use strict'
module.exports = {
- get_application_host : function(){
- return `http://localhost:${ process.env.PORT || 3000}/`;
+ get_application_host: function() {
+ return `http://localhost:${process.env.PORT || 3000}/`
},
/*
* Default timeout each integration test needs to be completed in
*
* */
- get_execution_timeout : function(){
- return 3 * 60 * 1000;
- },
+ get_execution_timeout: function() {
+ return 10 * 1000
+ }
}
diff --git a/t/lib/login_with_user.js b/t/lib/login_with_user.js
index 5fb224034..6a3e0e8cb 100644
--- a/t/lib/login_with_user.js
+++ b/t/lib/login_with_user.js
@@ -1,136 +1,125 @@
-
-'use strict';
-
-var By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- until = require('selenium-webdriver').until,
- _ = require('underscore'),
- Promise = require("bluebird"),
- build_driver = require('./build_driver'),
- driver;
-
-
-var login_with_user_func = Promise.promisify(function(args, callback){
-
- var application_host = args.application_host,
- user_email = args.user_email,
- result_callback = callback,
- password = args.password || '123456',
- should_fail = args.should_fail || false;
+'use strict'
+
+const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const until = require('selenium-webdriver').until;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const build_driver = require('./build_driver');
+ let driver
+
+const login_with_user_func = Promise.promisify(function(args, callback) {
+ const application_host = args.application_host;
+ const user_email = args.user_email;
+ const result_callback = callback;
+ const password = args.password || '123456';
+ const should_fail = args.should_fail || false
// Create new instance of driver
- driver = args.driver || build_driver();
+ driver = args.driver || build_driver()
// Make sure we are in desktop version
- driver.manage().window().setSize(1024, 768);
+ driver
+ .manage()
+ .window()
+ .setSize(1024, 768)
// Open front page
- driver.get( application_host );
+ driver.get(application_host)
- driver.wait(until.elementLocated(By.css('h1')), 1000);
+ driver.wait(until.elementLocated(By.css('h1')), 1000)
// Check that there is a login button
- driver.findElement( By.css('a[href="/login/"]') )
- .then(function(el){
- return el.getText();
+ driver
+ .findElement(By.css('a[href="/login/"]'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.equal('Login')
})
- .then(function(text){
- expect(text).to.be.equal('Login');
- });
// Click on Login button
- driver.findElement( By.css('a[href="/login/"]') )
- .then(function(el){
- return el.click();
- });
+ driver.findElement(By.css('a[href="/login/"]')).then(function(el) {
+ return el.click()
+ })
- driver.wait(until.elementLocated(By.css('h1')), 1000);
+ driver.wait(until.elementLocated(By.css('h1')), 1000)
// Check that it is actually login page
- driver.findElement( By.css('h1') )
- .then(function(el){
- return el.getText();
+ driver
+ .findElement(By.css('h1'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.equal('Login')
})
- .then(function(text){
- expect(text).to.be.equal('Login');
- });
// Fill login form
Promise.all([
_.map(
[
{
- selector : 'input[name="username"]',
- value : user_email,
+ selector: 'input[name="username"]',
+ value: user_email
},
{
- selector : 'input[name="password"]',
- value : password,
- },
+ selector: 'input[name="password"]',
+ value: password
+ }
],
- function( test_case ){
- driver
- .findElement(By.css( test_case.selector ))
- .then(function(el){
- el.sendKeys( test_case.value );
- });
- })
- ]);
+ function(test_case) {
+ driver.findElement(By.css(test_case.selector)).then(function(el) {
+ el.sendKeys(test_case.value)
+ })
+ }
+ )
+ ])
// Submit login button
- driver.findElement( By.css('#submit_login') )
- .then(function(el){
- el.click();
- });
+ driver.findElement(By.css('#submit_login')).then(function(el) {
+ el.click()
+ })
if (should_fail) {
-
driver
- .findElement(
- By.css('div.alert-danger')
- )
- .then(function(el){
- return el.getText();
+ .findElement(By.css('div.alert-danger'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.match(/Incorrect credentials/)
})
- .then(function(text){
- expect(text).to.match(/Incorrect credentials/);
- });
-
} else {
- driver.wait(until.elementLocated(By.css('div.alert-success')), 1000);
+ driver.wait(until.elementLocated(By.css('div.alert-success')), 1000)
// Make sure login was successful, check that we landed on user account page
- driver.getTitle()
- .then(function(title){
- expect(title).to.match(/Calendar/);
- });
+ driver.getTitle().then(function(title) {
+ expect(title).to.match(/Calendar/)
+ })
driver
- .findElement(
- By.css('div.alert-success')
- )
- .then(function(el){
- return el.getText();
+ .findElement(By.css('div.alert-success'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.match(/Welcome back/)
})
- .then(function(text){
- expect(text).to.match(/Welcome back/);
- });
}
-
// Go back to the front page and pass data to the caller
- driver.get( application_host )
- .then(function(){
- // "export" current driver
- result_callback(
- null,
- {
- driver : driver,
- }
- );
- });
-});
+ driver.get(application_host).then(function() {
+ // "export" current driver
+ result_callback(null, {
+ driver
+ })
+ })
+})
-module.exports = function(args){
- return args.driver.call(function(){return login_with_user_func(args)});
+module.exports = function(args) {
+ return args.driver.call(function() {
+ return login_with_user_func(args)
+ })
}
diff --git a/t/lib/logout_user.js b/t/lib/logout_user.js
index c8046f626..b051b203d 100644
--- a/t/lib/logout_user.js
+++ b/t/lib/logout_user.js
@@ -1,64 +1,61 @@
-'use strict';
+'use strict'
-var webdriver = require('selenium-webdriver'),
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- until = require('selenium-webdriver').until,
- Promise = require("bluebird");
+const By = require('selenium-webdriver').By
+const expect = require('chai').expect
+const until = require('selenium-webdriver').until
+const Promise = require('bluebird')
-
-var logout_user_func = Promise.promisify( function(args, callback){
-
- var application_host = args.application_host,
- driver = args.driver,
- result_callback = callback,
- logout_link_css_selector = 'li.hidden-xs a[href="/logout/"]';
+const logout_user_func = Promise.promisify(function(args, callback) {
+ const application_host = args.application_host
+ const driver = args.driver
+ const result_callback = callback
+ const logout_link_css_selector =
+ 'li.hidden-xs > ul.dropdown-menu li > a[href="/logout/"]'
// Open front page
- driver
- .get( application_host );
+ driver.get(application_host)
driver
- .findElement( By.css('a#me_menu') )
- .then(function(el){ return el.click(); })
+ .findElement(By.css('a#me_menu'))
+ .then(function(el) {
+ return el.click()
+ })
// Make sure that Logout link exists
- .then(function(){
- return driver.isElementPresent( By.css( logout_link_css_selector ) );
+ .then(function() {
+ return driver
+ .findElements(By.css(logout_link_css_selector))
+ .then(found => !!found.length)
+ })
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(true)
})
- .then(function(is_present){
- expect(is_present).to.be.equal(true);
- });
// Click logout link
driver
- .findElement( By.css(logout_link_css_selector) )
- .then(function(el){
- return el.click();
+ .findElement(By.css(logout_link_css_selector))
+ .then(function(el) {
+ return el.click()
})
- .then(function(){
-
- driver.wait(until.elementLocated(By.css('body')), 1000);
+ .then(function() {
+ driver.wait(until.elementLocated(By.css('body')), 1000)
- return driver.isElementPresent( By.css( logout_link_css_selector ) );
+ return driver
+ .findElements(By.css(logout_link_css_selector))
+ .then(found => !!found.length)
})
// Check that there is no more Logout link
- .then(function(is_present){
-
- expect(is_present).to.be.equal(false);
+ .then(function(is_present) {
+ expect(is_present).to.be.equal(false)
// "export" current driver
- result_callback(
- null,
- {
- driver : driver,
- }
- );
- });
-
-});
-
+ result_callback(null, {
+ driver
+ })
+ })
+})
-module.exports = function(args){
- return args.driver.call(function(){return logout_user_func(args)});
+module.exports = function(args) {
+ return args.driver.call(function() {
+ return logout_user_func(args)
+ })
}
-
diff --git a/t/lib/mock_express_request.js b/t/lib/mock_express_request.js
index fa6362a03..97c9d298e 100644
--- a/t/lib/mock_express_request.js
+++ b/t/lib/mock_express_request.js
@@ -2,28 +2,39 @@
* Class whose instances are mocked ExpressJS request objects.
*
* */
-'use strict';
+'use strict'
-module.exports = function(args){
+module.exports = function(args) {
+ if (!args) args = {}
- if (! args ) args = {};
+ const params = args.params || {};
+ const error_messages = []
- var params = args.params || {},
- error_messages = [];
-
- var req = {
- session : {},
- user : {
- company : {
- get_default_date_format : function() {'YYYY-MM-DD'},
- normalise_date : function(date) { return date; },
- },
+ const req = {
+ session: {},
+ user: {
+ company: {
+ get_default_date_format: function() {
+ 'YYYY-MM-DD'
},
- body : params,
- };
+ normalise_date: function(date) {
+ return date
+ }
+ }
+ },
+ body: params,
+ query: params,
+ param: function(key) {
+ return params[key]
+ }
+ }
- // Make request be aware of flash messages
- require('../../lib/middleware/flash_messages')(req,{locals:{}},function(){});
+ // Make request be aware of flash messages
+ require('../../lib/middleware/flash_messages')(
+ req,
+ { locals: {} },
+ function() {}
+ )
- return req;
-};
+ return req
+}
diff --git a/t/lib/open_page.js b/t/lib/open_page.js
index 5f1bc6aca..b32f19673 100644
--- a/t/lib/open_page.js
+++ b/t/lib/open_page.js
@@ -1,26 +1,13 @@
-'use strict';
+'use strict'
-var webdriver = require('selenium-webdriver'),
- Promise = require("bluebird");
-
-module.exports = Promise.promisify( function(args, callback){
-
- var url = args.url,
- driver = args.driver,
- result_callback = callback;
+const Promise = require('bluebird')
+module.exports = Promise.promisify(({ url, driver }, callback) => {
// Open front page
- driver
- .get( url )
- .then(function(){
- // "export" current driver
- result_callback(
- null,
- {
- driver : driver,
- }
- );
- });
-
-});
-
+ driver.get(url).then(() => {
+ // "export" current driver
+ callback(null, {
+ driver
+ })
+ })
+})
diff --git a/t/lib/register_new_user.js b/t/lib/register_new_user.js
index 802aff50a..d94ac149f 100644
--- a/t/lib/register_new_user.js
+++ b/t/lib/register_new_user.js
@@ -2,171 +2,165 @@
*/
-'use strict';
-
-var By = require('selenium-webdriver').By,
- until = require('selenium-webdriver').until,
- expect = require('chai').expect,
- _ = require('underscore'),
- uuid = require('node-uuid'),
- Promise = require("bluebird"),
- open_page_func = require('./open_page'),
- build_driver = require('./build_driver'),
- company_edit_form_id = '#company_edit_form',
- submit_form_func = require('./submit_form');
-
-
-var register_new_user_func = Promise.promisify( function(args, callback){
-
- var
- application_host = args.application_host || args.applicationHost,
- failing_error_message = args.failing_error_message,
- default_date_format = args.default_date_format,
- random_token = (new Date()).getTime(),
- new_user_email = args.user_email || random_token + '@test.com';
+'use strict'
+
+const By = require('selenium-webdriver').By
+const until = require('selenium-webdriver').until
+const expect = require('chai').expect
+const Promise = require('bluebird')
+const open_page_func = require('./open_page')
+const build_driver = require('./build_driver')
+const company_edit_form_id = '#company_edit_form'
+const submit_form_func = require('./submit_form')
+
+const register_new_user_func = Promise.promisify(function(args, callback) {
+ const application_host = args.application_host || args.applicationHost
+ const failing_error_message = args.failing_error_message
+ const default_date_format = args.default_date_format
+ const random_token = new Date().getTime()
+ const new_user_email = args.user_email || random_token + '@test.com'
// Instantiate new driver object if it not provided as paramater
- var driver = args.driver || build_driver()
-
+ const driver = args.driver || build_driver()
// Make sure we are in desktop version
- driver.manage().window().setSize(1024, 768);
+ // driver.manage().window().setSize(1024, 768);
// Go to front page
- driver.get( application_host );
+ driver.get(application_host)
- driver.wait(until.elementLocated(By.css('h1')), 1000);
+ driver.wait(until.elementLocated(By.css('h1')), 1000)
// Check if there is a registration link
- driver.findElement( By.css('a[href="/register/"]') )
- .then(function(el){
- return el.getText();
+ driver
+ .findElement(By.css('a[href="/register/"]'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.match(/Register new company/i)
})
- .then(function(text){
- expect(text).to.match(/Register new company/i);
- });
// Click on registration link
- driver
- .findElement(By.css('a[href="/register/"]'))
- .then(function(el){
- el.click();
- });
+ driver.findElement(By.css('a[href="/register/"]')).then(function(el) {
+ el.click()
+ })
- driver.wait(until.elementLocated(By.css('h1')), 1000);
+ driver.wait(until.elementLocated(By.css('h1')), 1000)
// Make sure that new page is a registration page
- driver.findElement(By.css('h1'))
- .then(function(el){
- return el.getText();
+ driver
+ .findElement(By.css('h1'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(ee) {
+ expect(ee).to.be.equal('New company')
})
- .then(function(ee){
- expect(ee).to.be.equal('New company');
- });
-
- driver.call(() => submit_form_func({
- driver : driver,
- form_params : [{
- selector : 'input[name="company_name"]',
- value : 'Company '+(new Date()).getTime(),
- },{
- selector : 'input[name="name"]',
- value : 'name' + random_token,
- },{
- selector : 'input[name="lastname"]',
- value : 'lastname' + random_token,
- },{
- selector : 'input[name="email"]',
- value : new_user_email,
- },{
- selector : 'input[name="password"]',
- value : '123456',
- },{
- selector : 'input[name="password_confirmed"]',
- value : '123456',
- },{
- selector : 'select[name="country"]',
- option_selector : 'option[value="ZZ"]',
- }],
- submit_button_selector : '#submit_registration',
- }));
-
- driver.wait(until.elementLocated(By.css('div')), 1000);
- if (failing_error_message) {
+ driver.call(() =>
+ submit_form_func({
+ driver,
+ form_params: [
+ {
+ selector: 'input[name="company_name"]',
+ value: 'Company ' + new Date().getTime()
+ },
+ {
+ selector: 'input[name="name"]',
+ value: 'name' + random_token
+ },
+ {
+ selector: 'input[name="lastname"]',
+ value: 'lastname' + random_token
+ },
+ {
+ selector: 'input[name="email"]',
+ value: new_user_email
+ },
+ {
+ selector: 'input[name="password"]',
+ value: '123456'
+ },
+ {
+ selector: 'input[name="password_confirmed"]',
+ value: '123456'
+ },
+ {
+ selector: 'select[name="country"]',
+ option_selector: 'option[value="ZZ"]'
+ }
+ ],
+ submit_button_selector: '#submit_registration'
+ })
+ )
+
+ driver.wait(until.elementLocated(By.css('div')), 1000)
+ if (failing_error_message) {
driver
- .findElement(
- By.css('div.alert-danger')
- )
- .then(function(el){
- return el.getText();
+ .findElement(By.css('div.alert-danger'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.equal(failing_error_message)
})
- .then(function(text){
- expect(text).to.be.equal(failing_error_message);
- });
-
} else {
-
// Make sure registration completed successfully
driver
- .findElement(
- By.css('div.alert-success')
- )
- .then(function(el){
- return el.getText();
+ .findElement(By.css('div.alert-success'))
+ .then(function(el) {
+ return el.getText()
+ })
+ .then(function(text) {
+ expect(text).to.be.equal('Registration is complete.')
})
- .then(function(text){
- expect(text).to.be.equal('Registration is complete.');
- });
}
if (default_date_format) {
-
// open company general configuration page and set the default format to be as requested
- driver.call(function(){
+ driver.call(function() {
return open_page_func({
- url : application_host + 'settings/general/',
- driver : driver,
+ url: application_host + 'settings/general/',
+ driver
})
- });
+ })
// update company to use provided date format as a default
- driver.call(function(){
-
+ driver.call(function() {
return submit_form_func({
- driver : driver,
- form_params : [{
- selector : company_edit_form_id+' select[name="date_format"]',
- option_selector : 'option[value="'+default_date_format+'"]',
- value : default_date_format,
- }],
- submit_button_selector : company_edit_form_id+' button[type="submit"]',
- message : /successfully/i,
- should_be_successful : true,
- });
- });
-
+ driver,
+ form_params: [
+ {
+ selector: company_edit_form_id + ' select[name="date_format"]',
+ option_selector: 'option[value="' + default_date_format + '"]',
+ value: default_date_format
+ }
+ ],
+ submit_button_selector: company_edit_form_id + ' button[type="submit"]',
+ message: /successfully/i,
+ should_be_successful: true
+ })
+ })
}
// Pass data back to the caller
- driver.get( application_host )
- .then(function(){
- callback(
- null,
- {
- driver : driver,
- email : new_user_email,
- }
- );
- });
-
-});
+ driver.get(application_host).then(function() {
+ callback(null, {
+ driver,
+ email: new_user_email
+ })
+ })
+})
-module.exports = function(args){
- if (args.hasOwnProperty('driver')) {
- return args.driver.call(function(){return register_new_user_func(args)});
- } else {
- return register_new_user_func(args);
+module.exports = function(args) {
+ if (args.driver) {
+ return args.driver.call(function() {
+ return register_new_user_func(args)
+ })
}
+
+ const result = register_new_user_func(args)
+ return result
}
diff --git a/t/lib/set_user_to_start_at_the_beginning_of_the_year.js b/t/lib/set_user_to_start_at_the_beginning_of_the_year.js
index ded87ea5d..fc5460204 100644
--- a/t/lib/set_user_to_start_at_the_beginning_of_the_year.js
+++ b/t/lib/set_user_to_start_at_the_beginning_of_the_year.js
@@ -1,38 +1,45 @@
+'use strict'
-'use strict';
+const openPageFunc = require('./open_page');
+ const userInfoFunc = require('./user_info');
+ const submitFormFunc = require('./submit_form');
+ const config = require('./config');
+ const bluebird = require('bluebird');
+ const moment = require('moment')
-const
- openPageFunc = require('./open_page'),
- userInfoFunc = require('./user_info'),
- submitFormFunc = require('./submit_form'),
- config = require('./config'),
- bluebird = require('bluebird'),
- moment = require('moment');
-
-const getUserId = ({userId,email,driver}) => (!!userId)
- ? bluebird.resolve(userId)
- : userInfoFunc({email,driver})
- .then(({user : {id}}) => bluebird.resolve(id));
+const getUserId = ({ userId, email, driver }) =>
+ userId
+ ? bluebird.resolve(userId)
+ : userInfoFunc({ email, driver }).then(({ user: { id } }) =>
+ bluebird.resolve(id)
+ )
module.exports = ({
driver,
email,
- userId=null,
- year=moment.utc().year(),
- applicationHost=config.get_application_host(),
- overwriteDate=null,
+ userId = null,
+ year = moment.utc().year(),
+ applicationHost = config.get_application_host(),
+ overwriteDate = null
}) =>
- getUserId({userId,email,driver})
- .then(userId => openPageFunc({driver, url:`${applicationHost}users/edit/${userId}/`}))
- .then(() => submitFormFunc({
- driver,
- form_params : [{
- selector: 'input#start_date_inp',
- value: (overwriteDate ? overwriteDate.format('YYYY-MM-DD') : `${year}-01-01`),
- }],
- submit_button_selector : 'button#save_changes_btn',
- message : /Details for .* were updated/,
- }))
- .then(() => openPageFunc({driver, url:applicationHost}))
- .then(() => bluebird.resolve({driver}));
-
+ getUserId({ userId, email, driver })
+ .then(userId =>
+ openPageFunc({ driver, url: `${applicationHost}users/edit/${userId}/` })
+ )
+ .then(() =>
+ submitFormFunc({
+ driver,
+ form_params: [
+ {
+ selector: 'input#start_date_inp',
+ value: overwriteDate
+ ? overwriteDate.format('YYYY-MM-DD')
+ : `${year}-01-01`
+ }
+ ],
+ submit_button_selector: 'button#save_changes_btn',
+ message: /Details for .* were updated/
+ })
+ )
+ .then(() => openPageFunc({ driver, url: applicationHost }))
+ .then(() => bluebird.resolve({ driver }))
diff --git a/t/lib/submit_form.js b/t/lib/submit_form.js
index f41138c11..5178ed929 100644
--- a/t/lib/submit_form.js
+++ b/t/lib/submit_form.js
@@ -1,166 +1,146 @@
-'use strict';
-
-var webdriver = require('selenium-webdriver'),
-By = require('selenium-webdriver').By,
-Key = require('selenium-webdriver').Key,
-expect = require('chai').expect,
-_ = require('underscore'),
-Promise = require("bluebird"),
-until = require('selenium-webdriver').until,
-check_elements = require('./check_elements');
-
-
-var submit_form_func = Promise.promisify( function(args, callback){
-
- var driver = args.driver,
- result_callback = callback,
- // Regex to check the message that is shown after form is submitted
- message = args.message || /.*/,
- // Array of object that have at least two keys: selector - css selector
- // and value - value to be entered
- form_params = args.form_params || [],
-
- // Defined how elemts are going to be checked in case of success,
- // if that parameter is omitted - 'form_params' is used instead
- elements_to_check = args.elements_to_check || form_params,
-
- // Indicates whether form submission is going to be successful
- should_be_successful = args.should_be_successful || false,
-
- // Indicate if message to be searched through all messages shown,
- // bu defaul it looks into firts message only
- multi_line_message = args.multi_line_message || false,
-
- // Indicates if there is a confirmation dialog
- confirm_dialog = args.confirm_dialog || false,
-
- // CSS selecetor for form submition button
- submit_button_selector = args.submit_button_selector ||'button[type="submit"]';
-
-
- driver.call(function(){
- // Enter form parameters
- Promise.all([
- _.map(
- form_params,
- function( test_case ){
-
- // Handle case when test case is empty
- if (Object.keys(test_case).length === 0 ){
- return Promise.resolve(1);
- }
-
- driver
- .findElement(By.css( test_case.selector ))
- .then(function(el){
- if ( test_case.hasOwnProperty('option_selector') ) {
- el.click();
- return el.findElement(By.css( test_case.option_selector ))
- .then(function(el){ return el.click(); });
- } else if ( test_case.hasOwnProperty('tick')) {
- return el.click();
- } else if (test_case.file) {
- return Promise.resolve()
- .then(() => el.sendKeys( test_case.value ));
- } else if (test_case.hasOwnProperty('dropdown_option')) {
- return el.click()
- .then(() => driver.findElement(By.css(test_case.dropdown_option)))
- .then(dd => dd.click())
- } else {
- // Prevent the browser validations to allow backend validations to occur
- if (test_case.change_step) {
- driver.executeScript("return arguments[0].step = '0.1'", el);
- }
-
- return el.clear().then(function(){
- el.sendKeys( test_case.value );
- // Tabs to trigger the calendars overlays
- // to close so the modal submit button can be clicked
- el.sendKeys(Key.TAB)
- });
- }
- });
+'use strict'
+
+const webdriver = require('selenium-webdriver');
+ const By = require('selenium-webdriver').By;
+ const Key = require('selenium-webdriver').Key;
+ const expect = require('chai').expect;
+ const _ = require('underscore');
+ const Promise = require('bluebird');
+ const until = require('selenium-webdriver').until;
+ const check_elements = require('./check_elements')
+
+const submit_form_func = Promise.promisify(function(args, callback) {
+ let driver = args.driver;
+ const result_callback = callback;
+ // Regex to check the message that is shown after form is submitted
+ const message = args.message || /.*/;
+ // Array of object that have at least two keys: selector - css selector
+ // and value - value to be entered
+ const form_params = args.form_params || [];
+ // Defined how elemts are going to be checked in case of success,
+ // if that parameter is omitted - 'form_params' is used instead
+ const elements_to_check = args.elements_to_check || form_params;
+ // Indicates whether form submission is going to be successful
+ const should_be_successful = args.should_be_successful || false;
+ // Indicate if message to be searched through all messages shown,
+ // bu defaul it looks into firts message only
+ const multi_line_message = args.multi_line_message || false;
+ // Indicates if there is a confirmation dialog
+ const confirm_dialog = args.confirm_dialog || false;
+ // CSS selecetor for form submition button
+ const submit_button_selector =
+ args.submit_button_selector || 'button[type="submit"]'
+
+ driver.call(function() {
+ // Enter form parameters
+ Promise.all([
+ _.map(form_params, function(test_case) {
+ // Handle case when test case is empty
+ if (Object.keys(test_case).length === 0) {
+ return Promise.resolve(1)
+ }
+
+ driver.findElement(By.css(test_case.selector)).then(function(el) {
+ if (test_case.hasOwnProperty('option_selector')) {
+ el.click()
+ return el
+ .findElement(By.css(test_case.option_selector))
+ .then(function(el) {
+ return el.click()
})
- ]);
- });
-
- // Accept the confirm dialog
- if (confirm_dialog) {
- driver.executeScript('window.confirm = function(msg) { return true; }');
- }
-
- // Submit the form
- driver
- .findElement( By.css( submit_button_selector ) )
- .then(function(el){
- el.click();
-
- driver.wait(until.elementLocated(By.css('title')), 1000);
- });
-
- // TODO this is not doing what it supposed to be doing
- if ( should_be_successful ) {
+ } else if (test_case.hasOwnProperty('tick')) {
+ return el.click()
+ } else if (test_case.file) {
+ return Promise.resolve().then(() => el.sendKeys(test_case.value))
+ } else if (test_case.hasOwnProperty('dropdown_option')) {
+ return el
+ .click()
+ .then(() => driver.findElement(By.css(test_case.dropdown_option)))
+ .then(dd => dd.click())
+ } else {
+ // Prevent the browser validations to allow backend validations to occur
+ if (test_case.change_step) {
+ driver.executeScript("return arguments[0].step = '0.1'", el)
+ }
- driver.call(function(){
- Promise.resolve(
- check_elements({
- driver : driver,
- elements_to_check : elements_to_check,
- })
- .then(function(data){
- driver = data.driver;
+ return el.clear().then(function() {
+ el.sendKeys(test_case.value)
+ // Tabs to trigger the calendars overlays
+ // to close so the modal submit button can be clicked
+ el.sendKeys(Key.TAB)
})
- );
- });
-
- }
-
- // Check that message is as expected
- if (multi_line_message) {
- driver.findElements( By.css('div.alert') )
- .then(function(els){
-
- return Promise.all(
- _.map(els, function(el){ return el.getText(); })
- )
- .then(function(texts){
- expect(
- _.any(texts, function(text){ return message.test(text); })
- ).to.be.equal(true);
-
- // "export" current driver
- result_callback(
- null,
- {
- driver : driver,
- }
- );
- });
- });
-
- } else {
-
- driver
- .findElement( By.css('div.alert') )
- .then(function(el){
- return el.getText();
+ }
})
+ })
+ ])
+ })
+
+ // Accept the confirm dialog
+ if (confirm_dialog) {
+ driver.executeScript('window.confirm = function(msg) { return true; }')
+ }
+
+ // Submit the form
+ driver.findElement(By.css(submit_button_selector)).then(function(el) {
+ el.click()
+
+ driver.wait(until.elementLocated(By.css('title')), 1000)
+ })
+
+ // TODO this is not doing what it supposed to be doing
+ if (should_be_successful) {
+ driver.call(function() {
+ Promise.resolve(
+ check_elements({
+ driver,
+ elements_to_check
+ }).then(function(data) {
+ driver = data.driver
+ })
+ )
+ })
+ }
+
+ // Check that message is as expected
+ if (multi_line_message) {
+ driver.findElements(By.css('div.alert')).then(function(els) {
+ return Promise.all(
+ _.map(els, function(el) {
+ return el.getText()
+ })
+ ).then(function(texts) {
+ expect(
+ _.any(texts, function(text) {
+ return message.test(text)
+ })
+ ).to.be.equal(true)
+
+ // "export" current driver
+ result_callback(null, {
+ driver
+ })
+ })
+ })
+ } else {
+ driver
+ .findElement(By.css('div.alert'))
+ .then(function(el) {
+ return el.getText()
+ })
- .then(function(text){
- expect(text).to.match(message);
-
- // "export" current driver
- result_callback(
- null,
- {
- driver : driver,
- }
- );
- });
- }
-});
-
+ .then(function(text) {
+ expect(text).to.match(message)
-module.exports = function(args){
- return args.driver.call(function(){return submit_form_func(args)});
+ // "export" current driver
+ result_callback(null, {
+ driver
+ })
+ })
+ }
+})
+
+module.exports = function(args) {
+ return args.driver.call(function() {
+ return submit_form_func(args)
+ })
}
diff --git a/t/lib/teamview_check_user.js b/t/lib/teamview_check_user.js
index 3fc478d72..ad7aa2ea1 100644
--- a/t/lib/teamview_check_user.js
+++ b/t/lib/teamview_check_user.js
@@ -1,4 +1,3 @@
-
/*
* Exports function that checks if given emails of users are shown
* on the Teamview page. And if so how they are rendered: as text or link.
@@ -7,51 +6,47 @@
*
* */
-'use strict';
-
-var
- By = require('selenium-webdriver').By,
- expect = require('chai').expect,
- open_page_func = require('./open_page'),
- config = require('./config'),
- bluebird = require("bluebird");
+'use strict'
-module.exports = bluebird.promisify( function(args, callback){
+const By = require('selenium-webdriver').By;
+ const expect = require('chai').expect;
+ const open_page_func = require('./open_page');
+ const config = require('./config');
+ const bluebird = require('bluebird')
- var
- result_callback = callback,
- driver = args.driver,
- emails = args.emails || [],
- is_link = args.is_link || false,
- application_host = args.application_host || config.get_application_host();
+module.exports = bluebird.promisify(function(args, callback) {
+ const result_callback = callback;
+ const driver = args.driver;
+ const emails = args.emails || [];
+ const is_link = args.is_link || false;
+ const application_host = args.application_host || config.get_application_host()
- if ( ! driver ) {
- throw "'driver' was not passed into the teamview_check_user!";
+ if (!driver) {
+ throw "'driver' was not passed into the teamview_check_user!"
}
return open_page_func({
- url : application_host + 'calendar/teamview/',
- driver : driver,
- })
-
- .then(function(data){
- return data.driver
- .findElements(By.css( 'tr.teamview-user-list-row > td.cross-link > ' + (is_link ? 'a' : 'span') ))
- .then(function(elements){
- expect(elements.length).to.be.equal( emails.length );
- return bluebird.resolve(data);
- });
+ url: application_host + 'calendar/teamview/',
+ driver
})
-
- .then(function(data){
- // "export" current driver
- result_callback(
- null,
- {
- driver : data.driver,
- }
- );
- });
-
-});
-
+ .then(function(data) {
+ return data.driver
+ .findElements(
+ By.css(
+ 'tr.teamview-user-list-row > td.cross-link > ' +
+ (is_link ? 'a' : 'span')
+ )
+ )
+ .then(function(elements) {
+ expect(elements.length).to.be.equal(emails.length)
+ return bluebird.resolve(data)
+ })
+ })
+
+ .then(function(data) {
+ // "export" current driver
+ result_callback(null, {
+ driver: data.driver
+ })
+ })
+})
diff --git a/t/lib/user_info.js b/t/lib/user_info.js
index 651fb09a2..a88ae18a1 100644
--- a/t/lib/user_info.js
+++ b/t/lib/user_info.js
@@ -1,4 +1,3 @@
-
/*
* For given email fetch user account info using provided driver
* where an client side JS is used to trigger AJAX request to
@@ -6,83 +5,74 @@
*
* */
-'use strict';
+'use strict'
-var
- bluebird = require("bluebird");
+const bluebird = require('bluebird')
// Function that is executed on the client,
// it relies on presence of jQuery and window.VPP_email
-var func_to_inject = function() {
- var callback = arguments[arguments.length - 1];
+const func_to_inject = function() {
+ const callback = arguments[arguments.length - 1]
$.ajax({
url: '/users/search/',
type: 'post',
data: {
- email : window.VPP_email,
+ email: window.VPP_email
},
headers: {
- Accept : "application/json",
+ Accept: 'application/json'
},
dataType: 'json',
- success: function (data) {
- callback(data);
+ success: function(data) {
+ callback(data)
}
- });
-};
-
-
-var user_info_func = bluebird.promisify( function(args, callback){
+ })
+}
- var
- result_callback = callback,
- driver = args.driver,
- email = args.email;
+const user_info_func = bluebird.promisify(function(args, callback) {
+ const result_callback = callback;
+ const driver = args.driver;
+ const email = args.email
- if ( ! driver ) {
- throw "'driver' was not passed into the user_info!";
+ if (!driver) {
+ throw "'driver' was not passed into the user_info!"
}
- if ( ! email ) {
- throw "'email' was not passed into the user_info!";
+ if (!email) {
+ throw "'email' was not passed into the user_info!"
}
- return bluebird.resolve()
-
- .then(function(data){
-
- // Inject email we are using to identify user into the tested page
- driver
- .executeScript('window.VPP_email = "'+email+'";');
-
- var user;
-
- // execute AJAX request on the client that fetchs user info by email
- driver
- .executeAsyncScript(func_to_inject)
- .then(function(users){
- user = users.length > 0 ? users[0] : {};
- });
-
- return driver.call(function(){
- return bluebird.resolve(user);
- });
+ return bluebird
+ .resolve()
+
+ .then(function(data) {
+ // Inject email we are using to identify user into the tested page
+ driver.executeScript('window.VPP_email = "' + email + '";')
+
+ let user
+
+ // execute AJAX request on the client that fetchs user info by email
+ driver.executeAsyncScript(func_to_inject).then(function(users) {
+ user = users.length > 0 ? users[0] : {}
+ })
+
+ return driver.call(function() {
+ return bluebird.resolve(user)
+ })
+ })
+
+ .then(function(user) {
+ // "export" current driver
+ result_callback(null, {
+ driver,
+ user
+ })
+ })
+})
+
+module.exports = function(args) {
+ return args.driver.call(function() {
+ return user_info_func(args)
})
-
- .then(function(user){
- // "export" current driver
- result_callback(
- null,
- {
- driver : driver,
- user : user,
- }
- );
- });
-
-});
-
-module.exports = function(args){
- return args.driver.call(function(){return user_info_func(args)});
}
diff --git a/t/unit/calendar.js b/t/unit/calendar.js
index b2c375a4a..8af0207d0 100644
--- a/t/unit/calendar.js
+++ b/t/unit/calendar.js
@@ -1,95 +1,220 @@
-
-'use strict';
-
-var expect = require('chai').expect,
- _ = require('underscore'),
- model = require('../../lib/model/db'),
- moment = require('moment'),
- schedule= model.Schedule.build({ company_id : 1 }),
- CalendarMonth = require('../../lib/model/calendar_month');
-
-
-describe('Check calendar month object', function(){
-
- it('Normalize provided date to be at the begining of the month',function(){
- var january = new CalendarMonth('2015-01-10', {schedule : schedule, today : moment.utc()});
-
- expect(
- january.get_base_date().date()
- ).to.be.equal(1);
- });
-
- it('Knows on which week day month starts', function(){
- var january = new CalendarMonth('2015-01-21', {schedule : schedule, today : moment.utc()});
- expect( january.week_day() ).to.be.equal(4);
-
- var feb = new CalendarMonth('2015-02-21', {schedule : schedule, today : moment.utc()});
- expect( feb.week_day() ).to.be.equal(7);
- });
-
- it('Knows how many blanks to put before first day of the month', function(){
- var january = new CalendarMonth('2015-01-11', {schedule : schedule, today : moment.utc()});
- expect( january.how_many_blanks_at_the_start() ).to.be.equal(3);
-
- var feb = new CalendarMonth('2015-02-11', {schedule : schedule, today : moment.utc()});
- expect( feb.how_many_blanks_at_the_start() ).to.be.equal(6);
- });
-
- it('Knows how many blanks to put after the last day of the month', function(){
- var january = new CalendarMonth('2015-01-11', {schedule : schedule, today : moment.utc()});
- expect( january.how_many_blanks_at_the_end() ).to.be.equal(1);
-
- var feb = new CalendarMonth('2015-02-11', {schedule : schedule, today : moment.utc()});
- expect( feb.how_many_blanks_at_the_end() ).to.be.equal(1);
- });
-
- it('Knows whether day is weekend', function(){
- var feb = new CalendarMonth('2015-02-12', {schedule : schedule, today : moment.utc()});
- expect(feb.is_weekend(12)).not.to.be.ok;
- expect(feb.is_weekend(21)).to.be.ok;
- expect(feb.is_weekend(22)).to.be.ok;
- expect(feb.is_weekend(23)).not.to.be.ok;
- });
-
- it('Knows how to generate data structure for template', function(){
- var january = new CalendarMonth('2015-01-11', { schedule : schedule, today : moment.utc() }),
- object_to_test = january.as_for_template();
- delete object_to_test['moment'];
- object_to_test.weeks.forEach(function(week){
- week.forEach(function(day){ delete day.leave_obj });
- });
- expect( object_to_test ).to.be.eql(
- {"month":"January","weeks":[[{"val":""},{"val":""},{"val":""},{"val":1},{"val":2},{"val":3,"is_weekend":true},{"val":4,"is_weekend":true}],[{"val":5},{"val":6},{"val":7},{"val":8},{"val":9},{"val":10,"is_weekend":true},{"val":11,"is_weekend":true}],[{"val":12},{"val":13},{"val":14},{"val":15},{"val":16},{"val":17,"is_weekend":true},{"val":18,"is_weekend":true}],[{"val":19},{"val":20},{"val":21},{"val":22},{"val":23},{"val":24,"is_weekend":true},{"val":25,"is_weekend":true}],[{"val":26},{"val":27},{"val":28},{"val":29},{"val":30},{"val":31,"is_weekend":true},{"val":""}]]}
- );
-
-
- var apr = new CalendarMonth('2015-04-11', { schedule : schedule, today : moment.utc() });
- object_to_test = apr.as_for_template();
- delete object_to_test['moment'];
- object_to_test.weeks.forEach(function(week){
- week.forEach(function(day){ delete day.leave_obj });
- });
- expect( object_to_test ).to.be.eql(
- {"month":"April","weeks":[[{"val":""},{"val":""},{"val":1},{"val":2},{"val":3},{"val":4,"is_weekend":true},{"val":5,"is_weekend":true}],[{"val":6},{"val":7},{"val":8},{"val":9},{"val":10},{"val":11,"is_weekend":true},{"val":12,"is_weekend":true}],[{"val":13},{"val":14},{"val":15},{"val":16},{"val":17},{"val":18,"is_weekend":true},{"val":19,"is_weekend":true}],[{"val":20},{"val":21},{"val":22},{"val":23},{"val":24},{"val":25,"is_weekend":true},{"val":26,"is_weekend":true}],[{"val":27},{"val":28},{"val":29},{"val":30},{"val":""},{"val":""},{"val":""}]]}
- );
-
- });
-
-
- it('Sanity checks pass', function(){
-
- var apr = new CalendarMonth('2015-04-01', { schedule : schedule, today : moment.utc() });
-
- expect(apr).to.be.a('object');
-
- expect(apr.how_many_days()).to.be.equal(30);
- });
-
- it('It knows whether day is bank holiday', function(){
- var mar = new CalendarMonth('2015-03-19', { bank_holidays : [{date : '2015-03-08'}], schedule : schedule, today : moment.utc() });
-
- expect(mar.is_bank_holiday(8)).to.be.ok;
- expect(mar.is_bank_holiday(10)).not.to.be.ok;
- });
-
-});
+'use strict'
+
+const expect = require('chai').expect;
+ const _ = require('underscore');
+ const model = require('../../lib/model/db');
+ const moment = require('moment');
+ const schedule = model.Schedule.build({ company_id: 1 });
+ const CalendarMonth = require('../../lib/model/calendar_month')
+
+describe('Check calendar month object', function() {
+ it('Normalize provided date to be at the begining of the month', function() {
+ const january = new CalendarMonth('2015-01-10', {
+ schedule,
+ today: moment.utc()
+ })
+
+ expect(january.get_base_date().date()).to.be.equal(1)
+ })
+
+ it('Knows on which week day month starts', function() {
+ const january = new CalendarMonth('2015-01-21', {
+ schedule,
+ today: moment.utc()
+ })
+ expect(january.week_day()).to.be.equal(4)
+
+ const feb = new CalendarMonth('2015-02-21', {
+ schedule,
+ today: moment.utc()
+ })
+ expect(feb.week_day()).to.be.equal(7)
+ })
+
+ it('Knows how many blanks to put before first day of the month', function() {
+ const january = new CalendarMonth('2015-01-11', {
+ schedule,
+ today: moment.utc()
+ })
+ expect(january.how_many_blanks_at_the_start()).to.be.equal(3)
+
+ const feb = new CalendarMonth('2015-02-11', {
+ schedule,
+ today: moment.utc()
+ })
+ expect(feb.how_many_blanks_at_the_start()).to.be.equal(6)
+ })
+
+ it('Knows how many blanks to put after the last day of the month', function() {
+ const january = new CalendarMonth('2015-01-11', {
+ schedule,
+ today: moment.utc()
+ })
+ expect(january.how_many_blanks_at_the_end()).to.be.equal(1)
+
+ const feb = new CalendarMonth('2015-02-11', {
+ schedule,
+ today: moment.utc()
+ })
+ expect(feb.how_many_blanks_at_the_end()).to.be.equal(1)
+ })
+
+ it('Knows whether day is weekend', function() {
+ const feb = new CalendarMonth('2015-02-12', {
+ schedule,
+ today: moment.utc()
+ })
+ expect(feb.is_weekend(12)).not.to.be.ok
+ expect(feb.is_weekend(21)).to.be.ok
+ expect(feb.is_weekend(22)).to.be.ok
+ expect(feb.is_weekend(23)).not.to.be.ok
+ })
+
+ it('Knows how to generate data structure for template', function() {
+ const january = new CalendarMonth('2015-01-11', {
+ schedule,
+ today: moment.utc()
+ });
+ let object_to_test = january.as_for_template()
+ delete object_to_test.moment
+ object_to_test.weeks.forEach(function(week) {
+ week.forEach(function(day) {
+ delete day.leave_obj
+ })
+ })
+ expect(object_to_test).to.be.eql({
+ month: 'January',
+ weeks: [
+ [
+ { val: '' },
+ { val: '' },
+ { val: '' },
+ { val: 1 },
+ { val: 2 },
+ { val: 3, is_weekend: true },
+ { val: 4, is_weekend: true }
+ ],
+ [
+ { val: 5 },
+ { val: 6 },
+ { val: 7 },
+ { val: 8 },
+ { val: 9 },
+ { val: 10, is_weekend: true },
+ { val: 11, is_weekend: true }
+ ],
+ [
+ { val: 12 },
+ { val: 13 },
+ { val: 14 },
+ { val: 15 },
+ { val: 16 },
+ { val: 17, is_weekend: true },
+ { val: 18, is_weekend: true }
+ ],
+ [
+ { val: 19 },
+ { val: 20 },
+ { val: 21 },
+ { val: 22 },
+ { val: 23 },
+ { val: 24, is_weekend: true },
+ { val: 25, is_weekend: true }
+ ],
+ [
+ { val: 26 },
+ { val: 27 },
+ { val: 28 },
+ { val: 29 },
+ { val: 30 },
+ { val: 31, is_weekend: true },
+ { val: '' }
+ ]
+ ]
+ })
+
+ const apr = new CalendarMonth('2015-04-11', {
+ schedule,
+ today: moment.utc()
+ })
+ object_to_test = apr.as_for_template()
+ delete object_to_test.moment
+ object_to_test.weeks.forEach(function(week) {
+ week.forEach(function(day) {
+ delete day.leave_obj
+ })
+ })
+ expect(object_to_test).to.be.eql({
+ month: 'April',
+ weeks: [
+ [
+ { val: '' },
+ { val: '' },
+ { val: 1 },
+ { val: 2 },
+ { val: 3 },
+ { val: 4, is_weekend: true },
+ { val: 5, is_weekend: true }
+ ],
+ [
+ { val: 6 },
+ { val: 7 },
+ { val: 8 },
+ { val: 9 },
+ { val: 10 },
+ { val: 11, is_weekend: true },
+ { val: 12, is_weekend: true }
+ ],
+ [
+ { val: 13 },
+ { val: 14 },
+ { val: 15 },
+ { val: 16 },
+ { val: 17 },
+ { val: 18, is_weekend: true },
+ { val: 19, is_weekend: true }
+ ],
+ [
+ { val: 20 },
+ { val: 21 },
+ { val: 22 },
+ { val: 23 },
+ { val: 24 },
+ { val: 25, is_weekend: true },
+ { val: 26, is_weekend: true }
+ ],
+ [
+ { val: 27 },
+ { val: 28 },
+ { val: 29 },
+ { val: 30 },
+ { val: '' },
+ { val: '' },
+ { val: '' }
+ ]
+ ]
+ })
+ })
+
+ it('Sanity checks pass', function() {
+ const apr = new CalendarMonth('2015-04-01', {
+ schedule,
+ today: moment.utc()
+ })
+
+ expect(apr).to.be.a('object')
+
+ expect(apr.how_many_days()).to.be.equal(30)
+ })
+
+ it('It knows whether day is bank holiday', function() {
+ const mar = new CalendarMonth('2015-03-19', {
+ bank_holidays: [{ date: '2015-03-08' }],
+ schedule,
+ today: moment.utc()
+ })
+
+ expect(mar.is_bank_holiday(8)).to.be.ok
+ expect(mar.is_bank_holiday(10)).not.to.be.ok
+ })
+})
diff --git a/t/unit/email.js b/t/unit/email.js
index 9614533d1..01cf7f31f 100644
--- a/t/unit/email.js
+++ b/t/unit/email.js
@@ -1,34 +1,33 @@
-
-'use strict';
-
-var expect = require('chai').expect,
-_ = require('underscore'),
-bluebird = require('bluebird'),
-Email = require('../../lib/email');
-
-describe('Check Email', function(){
-
- it('Knows how to render and parse template', function(done){
-
- var email = new Email();
-
- bluebird.resolve(email.promise_rendered_email_template({
- template_name : 'foobar',
- context : {
- user : {
- name : 'FOO',
- reload_with_session_details : function(){ bluebird.resolve(1); },
- },
- },
- }))
- .then(function(email){
-
- expect(email.subject).to.be.equal('Email subject goes here');
- expect(email.body).to.match(/Hello FOO\./);
-
- done();
- });
-
- });
-});
-
+'use strict'
+
+const expect = require('chai').expect;
+ const _ = require('underscore');
+ const bluebird = require('bluebird');
+ const Email = require('../../lib/email')
+
+describe('Check Email', function() {
+ it('Knows how to render and parse template', function(done) {
+ const email = new Email()
+
+ bluebird
+ .resolve(
+ email.promise_rendered_email_template({
+ template_name: 'foobar',
+ context: {
+ user: {
+ name: 'FOO',
+ reload_with_session_details: function() {
+ bluebird.resolve(1)
+ }
+ }
+ }
+ })
+ )
+ .then(function(email) {
+ expect(email.subject).to.be.equal('Email subject goes here')
+ expect(email.body).to.match(/Hello FOO\./)
+
+ done()
+ })
+ })
+})
diff --git a/t/unit/model/db/leave.js b/t/unit/model/db/leave.js
index b60885642..1dbe66876 100644
--- a/t/unit/model/db/leave.js
+++ b/t/unit/model/db/leave.js
@@ -1,263 +1,260 @@
+'use strict'
-'use strict';
+const expect = require('chai').expect;
+ const _ = require('underscore');
+ const model = require('../../../../lib/model/db');
+ const LeaveRequestParameters = require('../../../../lib/model/leave_request_parameters')
-var expect = require('chai').expect,
- _ = require('underscore'),
- model = require('../../../../lib/model/db'),
- LeaveRequestParameters = require('../../../../lib/model/leave_request_parameters');
+describe('Check bug when type mismatch happenned', function() {
+ const leave = model.Leave.build({
+ status: '1',
+ date_start: '2015-05-07 00:00:00.000 +00:00',
+ day_part_start: 2,
+ date_end: '2015-05-07 00:00:00.000 +00:00',
+ day_part_end: 2
+ })
-describe('Check bug when type mismatch happenned', function(){
- var leave = model.Leave.build({
- status : '1',
- date_start : '2015-05-07 00:00:00.000 +00:00',
- day_part_start : 2,
- date_end : '2015-05-07 00:00:00.000 +00:00',
- day_part_end : 2,
- });
+ it('String value of 2 properly used', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-05-07',
+ from_date_part: '2',
+ to_date: '2015-05-07',
+ // do not care about following parameters
+ to_date_part: 2,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.be.equal(false)
+ })
+})
- it('String value of 2 properly used', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-05-07',
- from_date_part : '2',
- to_date : '2015-05-07',
- // do not care about following parameters
- to_date_part : 2,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.be.equal(false);
- });
-});
+describe('leave request half a day with existing booking of half a day', function() {
+ const leave = model.Leave.build({
+ status: '1',
+ date_start: '2015-04-09',
+ date_end: '2015-04-09',
+ day_part_start: 2,
+ day_part_end: 2
+ })
-describe('leave request half a day with existing booking of half a day', function(){
- var leave = model.Leave.build({
- status : '1',
- date_start : '2015-04-09',
- date_end : '2015-04-09',
- day_part_start : 2,
- day_part_end : 2,
- });
+ it('clash', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-09',
+ from_date_part: 2,
+ to_date: '2015-04-09',
+ // do not care about following parameters
+ to_date_part: 1,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
- it('clash', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-09',
- from_date_part : 2,
- to_date : '2015-04-09',
- // do not care about following parameters
- to_date_part : 1,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
+ it('fit', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-09',
+ from_date_part: 3,
+ to_date: '2015-04-09',
+ // do not care about following parameters
+ to_date_part: 1,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.be.ok
+ })
+})
- it('fit', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-09',
- from_date_part : 3,
- to_date : '2015-04-09',
- // do not care about following parameters
- to_date_part : 1,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.be.ok;
- });
-});
+describe('Leave request is spread through more then one day', function() {
+ const leave = model.Leave.build({
+ status: '1',
-describe('Leave request is spread through more then one day', function(){
- var leave = model.Leave.build({
- status : '1',
+ date_start: '2015-04-09',
+ date_end: '2015-04-10',
+ day_part_start: 2,
+ day_part_end: 1
+ })
- date_start : '2015-04-09',
- date_end : '2015-04-10',
- day_part_start : 2,
- day_part_end : 1,
- });
+ it('leave object is instanciated', function() {
+ expect(leave).to.be.ok
+ })
- it('leave object is instanciated', function(){
- expect( leave ).to.be.ok;
- });
+ it('both ends are full, stick to the start', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-08',
+ from_date_part: 1,
+ to_date: '2015-04-09',
+ to_date_part: 1,
+ // do not care about following parameters
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
- it('both ends are full, stick to the start', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-08',
- from_date_part : 1,
- to_date : '2015-04-09',
- to_date_part : 1,
- // do not care about following parameters
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
+ it('both ends are full, stick to the end', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-10',
+ from_date_part: 1,
+ to_date: '2015-04-11',
+ to_date_part: 1,
+ // do not care about following parameters
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
- it('both ends are full, stick to the end', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-10',
- from_date_part : 1,
- to_date : '2015-04-11',
- to_date_part : 1,
- // do not care about following parameters
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
+ it('ends with part stick to the part start - should fit', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-08',
+ from_date_part: 1,
+ to_date: '2015-04-09',
+ to_date_part: 3,
+ // do not care about following parameters
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.be.ok
+ })
- it('ends with part stick to the part start - should fit', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-08',
- from_date_part : 1,
- to_date : '2015-04-09',
- to_date_part : 3,
- // do not care about following parameters
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.be.ok;
- });
+ it('ends with part, stick to the part start - with clashes', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-08',
+ from_date_part: 1,
+ to_date: '2015-04-09',
+ to_date_part: 2,
+ // do not care about following parameters
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
- it('ends with part, stick to the part start - with clashes', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-08',
- from_date_part : 1,
- to_date : '2015-04-09',
- to_date_part : 2,
- // do not care about following parameters
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
+ it('start with with part, stick to the full end', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-10',
+ from_date_part: 2,
+ to_date: '2015-04-11',
+ to_date_part: 1,
+ // do not care about following parameters
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
+})
- it('start with with part, stick to the full end', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-10',
- from_date_part : 2,
- to_date : '2015-04-11',
- to_date_part : 1,
- // do not care about following parameters
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
-});
+describe('Case when leave request is within one day', function() {
+ const leave = model.Leave.build({
+ status: '1',
-describe('Case when leave request is within one day', function(){
+ date_start: '2015-04-09',
+ date_end: '2015-04-10',
+ day_part_start: 2,
+ day_part_end: 1
+ })
- var leave = model.Leave.build({
- status : '1',
+ it('Is half and attempt to stick to the half day part so they fit', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-09',
+ from_date_part: 3,
+ to_date: '2015-04-09',
+ // do not care about following parameters
+ to_date_part: 1,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.be.ok
+ })
- date_start : '2015-04-09',
- date_end : '2015-04-10',
- day_part_start : 2,
- day_part_end : 1,
- });
+ it('Is half and attempt to stick to the half day part with clashes', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-09',
+ from_date_part: 2,
+ to_date: '2015-04-09',
+ // do not care about following parameters
+ to_date_part: 1,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
- it('Is half and attempt to stick to the half day part so they fit', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-09',
- from_date_part : 3,
- to_date : '2015-04-09',
- // do not care about following parameters
- to_date_part : 1,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.be.ok;
- });
+ it('Is half and attempt to stick to the full day part', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-10',
+ from_date_part: 2,
+ to_date: '2015-04-10',
+ // do not care about following parameters
+ to_date_part: 1,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
- it('Is half and attempt to stick to the half day part with clashes', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-09',
- from_date_part : 2,
- to_date : '2015-04-09',
- // do not care about following parameters
- to_date_part : 1,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
+ it('Is full day and attempt to stick it to the half day part', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-09',
+ from_date_part: 1,
+ to_date: '2015-04-09',
+ // do not care about following parameters
+ to_date_part: 1,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
- it('Is half and attempt to stick to the full day part', function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-10',
- from_date_part : 2,
- to_date : '2015-04-10',
- // do not care about following parameters
- to_date_part : 1,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
-
- it('Is full day and attempt to stick it to the half day part',function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-09',
- from_date_part : 1,
- to_date : '2015-04-09',
- // do not care about following parameters
- to_date_part : 1,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
-
- it('Is full day and attempt to stick it to the full day part',function(){
- expect(
- leave.fit_with_leave_request(
- new LeaveRequestParameters( {
- from_date : '2015-04-10',
- from_date_part : 1,
- to_date : '2015-04-10',
- // do not care about following parameters
- to_date_part : 1,
- leave_type : 1,
- reason : 1,
- })
- )
- ).to.not.be.ok;
- });
-
-});
+ it('Is full day and attempt to stick it to the full day part', function() {
+ expect(
+ leave.fit_with_leave_request(
+ new LeaveRequestParameters({
+ from_date: '2015-04-10',
+ from_date_part: 1,
+ to_date: '2015-04-10',
+ // do not care about following parameters
+ to_date_part: 1,
+ leave_type: 1,
+ reason: 1
+ })
+ )
+ ).to.not.be.ok
+ })
+})
diff --git a/t/unit/model/db/leave_day.js b/t/unit/model/db/leave_day.js
index 2138b86ef..db19d9daa 100644
--- a/t/unit/model/db/leave_day.js
+++ b/t/unit/model/db/leave_day.js
@@ -1,102 +1,103 @@
-
-'use strict';
-
-var expect = require('chai').expect,
- _ = require('underscore'),
- model = require('../../../../lib/model/db');
-
-var default_params = {
- date_start : '2015-04-09',
- date_end : '2015-04-10',
- status : 1,
- day_part_start : 1,
- day_part_end : 1,
-};
-
-
-describe('Check get_objects_for_bulk_create', function(){
-
- it('Check case when start and finish dates are the same', function(){
-
- var params = _.clone(default_params);
- params.date_start = '2015-04-09';
- params.date_end = '2015-04-09';
-
- var leave = model.Leave.build(params);
-
- expect(
- _.map(
- leave.get_days(),
- function(d){return { date : d.date, day_part : d.day_part };}
- )
- ).to.be.eql([{
- date : '2015-04-09',
- day_part : 1,
- }]);
- });
-
- it('Start and end dates are the same, and half day', function(){
-
- var params = _.clone(default_params);
- params.date_start = '2015-04-09';
- params.date_end = '2015-04-09';
- params.day_part_start = 3;
- // finish date part setting is ignored if both dates are the sane
- params.day_part_end = 1;
-
- var leave = model.Leave.build(params);
-
- expect(
- _.map(
- leave.get_days(),
- function(d){return { date : d.date, day_part : d.day_part };}
- )
- ).to.be.eql([{
- date : '2015-04-09',
- day_part : 3,
- }]);
- });
-
- it('Two days in a row', function(){
- var params = _.clone(default_params);
- var leave = model.Leave.build(params);
-
- expect(
- _.map(
- leave.get_days(),
- function(d){return { date : d.date, day_part : d.day_part };}
- )
- ).to.be.eql([{
- date : '2015-04-09',
- day_part : 1,
- },{
- date : '2015-04-10',
- day_part : 1,
- }]);
- });
-
- it('Three days in a row with first half day', function(){
- var params = _.clone( default_params );
- params.date_end = '2015-04-11';
- params.day_part_start = 3;
-
- var leave = model.Leave.build(params);
-
- expect(
- _.map(
- leave.get_days(),
- function(d){return { date : d.date, day_part : d.day_part };}
- )
- ).to.be.eql([{
- date : '2015-04-09',
- day_part : 3,
- },{
- date : '2015-04-10',
- day_part : 1,
- },{
- date : '2015-04-11',
- day_part : 1,
- }]);
- });
-
-});
+'use strict'
+
+const expect = require('chai').expect;
+ const _ = require('underscore');
+ const model = require('../../../../lib/model/db')
+
+const default_params = {
+ date_start: '2015-04-09',
+ date_end: '2015-04-10',
+ status: 1,
+ day_part_start: 1,
+ day_part_end: 1
+}
+
+describe('Check get_objects_for_bulk_create', function() {
+ it('Check case when start and finish dates are the same', function() {
+ const params = _.clone(default_params)
+ params.date_start = '2015-04-09'
+ params.date_end = '2015-04-09'
+
+ const leave = model.Leave.build(params)
+
+ expect(
+ _.map(leave.get_days(), function(d) {
+ return { date: d.date, day_part: d.day_part }
+ })
+ ).to.be.eql([
+ {
+ date: '2015-04-09',
+ day_part: 1
+ }
+ ])
+ })
+
+ it('Start and end dates are the same, and half day', function() {
+ const params = _.clone(default_params)
+ params.date_start = '2015-04-09'
+ params.date_end = '2015-04-09'
+ params.day_part_start = 3
+ // finish date part setting is ignored if both dates are the sane
+ params.day_part_end = 1
+
+ const leave = model.Leave.build(params)
+
+ expect(
+ _.map(leave.get_days(), function(d) {
+ return { date: d.date, day_part: d.day_part }
+ })
+ ).to.be.eql([
+ {
+ date: '2015-04-09',
+ day_part: 3
+ }
+ ])
+ })
+
+ it('Two days in a row', function() {
+ const params = _.clone(default_params)
+ const leave = model.Leave.build(params)
+
+ expect(
+ _.map(leave.get_days(), function(d) {
+ return { date: d.date, day_part: d.day_part }
+ })
+ ).to.be.eql([
+ {
+ date: '2015-04-09',
+ day_part: 1
+ },
+ {
+ date: '2015-04-10',
+ day_part: 1
+ }
+ ])
+ })
+
+ it('Three days in a row with first half day', function() {
+ const params = _.clone(default_params)
+ params.date_end = '2015-04-11'
+ params.day_part_start = 3
+
+ const leave = model.Leave.build(params)
+
+ expect(
+ _.map(leave.get_days(), function(d) {
+ return { date: d.date, day_part: d.day_part }
+ })
+ ).to.be.eql([
+ {
+ date: '2015-04-09',
+ day_part: 3
+ },
+ {
+ date: '2015-04-10',
+ day_part: 1
+ },
+ {
+ date: '2015-04-11',
+ day_part: 1
+ }
+ ])
+ })
+})
diff --git a/t/unit/model/user_allowance.js b/t/unit/model/user_allowance.js
index 13d8c6343..4dfd37e8b 100644
--- a/t/unit/model/user_allowance.js
+++ b/t/unit/model/user_allowance.js
@@ -1,429 +1,423 @@
+'use strict'
-'use strict';
+const expect = require('chai').expect;
+ const moment = require('moment');
+ const UserAllowance = require('../../../lib/model/user_allowance');
+ const model = require('../../../lib/model/db')
-const
- expect = require('chai').expect,
- moment = require('moment'),
- UserAllowance = require('../../../lib/model/user_allowance'),
- model = require('../../../lib/model/db');
+describe('employement_range_adjustment attribute', function() {
+ describe('Employee start day is in previouse year and no end date', function() {
+ const employee = model.User.build({
+ start_date: moment('2015-07-14')
+ })
-describe('employement_range_adjustment attribute', function(){
+ it('no automatic adjustment', function() {
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-20'),
- describe('Employee start day is in previouse year and no end date',function(){
- let employee = model.User.build({
- start_date : moment('2015-07-14'),
- });
+ // Rest of parameters do not really matter
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
- it('no automatic adjustment', function(){
+ expect(ul.employement_range_adjustment).to.be.equal(0)
+ })
+ })
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-20'),
+ describe('Employee start date is in prevouse year but end date is in current year', function() {
+ const employee = model.User.build({
+ start_date: moment('2015-04-23'),
+ end_date: moment('2016-04-01')
+ })
- // Rest of parameters do not really matter
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- expect( ul.employement_range_adjustment ).to.be.equal(0);
- });
- });
-
- describe('Employee start date is in prevouse year but end date is in current year', function(){
- let employee = model.User.build({
- start_date : moment('2015-04-23'),
- end_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-02-20'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('ajustment is made based on end date', function(){
- expect( ul.employement_range_adjustment ).to.be.equal(-15);
- });
- });
-
- describe('Employee start date is in previouse year and end date is in next year', function(){
- let employee = model.User.build({
- start_date : moment('2015-04-23'),
- end_date : moment('2017-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-20'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('ajustment is made based on end date', function(){
- expect( ul.employement_range_adjustment ).to.be.equal(0);
- });
- });
-
- describe('Start date is in current year, no end date', function(){
- let employee = model.User.build({
- start_date : moment('2018-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2018-07-20'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('adjustment is made based on start date', function(){
- expect( ul.employement_range_adjustment ).to.be.equal(-5);
- });
- });
-
- describe('Start date is in current year, end date is in current year either',function(){
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- end_date : moment('2016-10-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-20'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('adjustment is made based on start and end dates', function(){
- expect( ul.employement_range_adjustment ).to.be.equal(-10);
- });
- });
-
- describe('Start date is in current year, end date is in next year', function(){
- let employee = model.User.build({
- start_date : moment('2018-04-01'),
- end_date : moment('2019-10-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2018-07-20'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('adjustment is made based on start date', function(){
- expect( ul.employement_range_adjustment ).to.be.equal(-5);
- });
- });
-
- describe('Start date is in next year, no end date', function(){
- let employee = model.User.build({
- start_date : moment('2018-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-20'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('No adjustment is needed', function(){
- expect( ul.employement_range_adjustment ).to.be.equal(0);
- });
- });
-
- describe('Start date is in next year, end date is defined',function(){
- let employee = model.User.build({
- start_date : moment('2017-04-01'),
- end_date : moment('2017-10-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-20'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('No adjustment is needed', function(){
- expect( ul.employement_range_adjustment ).to.be.equal(0);
- });
- });
-});
-
-
-describe('accrued_adjustment attribute', function(){
-
- describe('Employee started last year, today is is beginning of Feb', () => {
- let employee = model.User.build({
- start_date : moment('2016-10-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2017-02-01'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24,
- });
-
- it('Ensure year total alloance is correct', () => {
- expect( ul.total_number_of_days_in_allowance ).to.be.eql(24);
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-22);
- });
- });
-
- describe('Started in Apr, today is Jul', () => {
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-01'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24,
- });
-
- it('Ensure year total alloance is correct', () => {
- expect( ul.total_number_of_days_in_allowance ).to.be.eql(18);
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-12);
- });
- });
-
- describe('Started in Apr, today is Jul: carry over is ignored in accrual adjustment', () => {
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-01'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 10,
- nominal_allowance : 24,
- });
-
- it('Ensure year total alloance is correct', () => {
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-02-20'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('ajustment is made based on end date', function() {
+ expect(ul.employement_range_adjustment).to.be.equal(-15)
+ })
+ })
+
+ describe('Employee start date is in previouse year and end date is in next year', function() {
+ const employee = model.User.build({
+ start_date: moment('2015-04-23'),
+ end_date: moment('2017-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-20'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('ajustment is made based on end date', function() {
+ expect(ul.employement_range_adjustment).to.be.equal(0)
+ })
+ })
+
+ describe('Start date is in current year, no end date', function() {
+ const employee = model.User.build({
+ start_date: moment('2018-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2018-07-20'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('adjustment is made based on start date', function() {
+ expect(ul.employement_range_adjustment).to.be.equal(-5)
+ })
+ })
+
+ describe('Start date is in current year, end date is in current year either', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01'),
+ end_date: moment('2016-10-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-20'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('adjustment is made based on start and end dates', function() {
+ expect(ul.employement_range_adjustment).to.be.equal(-10)
+ })
+ })
+
+ describe('Start date is in current year, end date is in next year', function() {
+ const employee = model.User.build({
+ start_date: moment('2018-04-01'),
+ end_date: moment('2019-10-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2018-07-20'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('adjustment is made based on start date', function() {
+ expect(ul.employement_range_adjustment).to.be.equal(-5)
+ })
+ })
+
+ describe('Start date is in next year, no end date', function() {
+ const employee = model.User.build({
+ start_date: moment('2018-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-20'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('No adjustment is needed', function() {
+ expect(ul.employement_range_adjustment).to.be.equal(0)
+ })
+ })
+
+ describe('Start date is in next year, end date is defined', function() {
+ const employee = model.User.build({
+ start_date: moment('2017-04-01'),
+ end_date: moment('2017-10-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-20'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('No adjustment is needed', function() {
+ expect(ul.employement_range_adjustment).to.be.equal(0)
+ })
+ })
+})
+
+describe('accrued_adjustment attribute', function() {
+ describe('Employee started last year, today is is beginning of Feb', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-10-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2017-02-01'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
+
+ it('Ensure year total alloance is correct', function() {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(24)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-22)
+ })
+ })
+
+ describe('Started in Apr, today is Jul', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-01'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
+
+ it('Ensure year total alloance is correct', function() {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(18)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-12)
+ })
+ })
+
+ describe('Started in Apr, today is Jul: carry over is ignored in accrual adjustment', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-01'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 10,
+ nominal_allowance: 24
+ })
+
+ it('Ensure year total alloance is correct', function() {
// 18, because start/end adjustment affects only nominal allowance
// but not manula adjuatements
// so 18 = 24 * .75 + 10
- expect( ul.total_number_of_days_in_allowance ).to.be.eql(28);
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-12);
- });
- });
-
- describe('Started in Apr, today is Jul: manual adjustments is taked into consideration', () => {
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2016-07-01'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 4,
- carry_over : 0,
- nominal_allowance : 20,
- });
-
- it('Ensure year total alloance is correct', () => {
- expect( ul.total_number_of_days_in_allowance ).to.be.eql( 20 * 0.75 + 4);
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-12.5);
- });
- });
-
- describe('Started last year, today is 1 of January', () => {
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2017-01-01'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24,
- });
-
- it('Ensure year total allowance is correct', () => {
- expect( ul.total_number_of_days_in_allowance ).to.be.eql( 24 );
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-24);
- });
- });
-
- describe('Started last year, today is 14th of January', () => {
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2017-01-14'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24
- });
-
- it('Ensure year total allowance is correct', () => {
- expect( ul.total_number_of_days_in_allowance ).to.be.eql( 24 );
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-23);
- });
- });
-
- describe('Started last year, today is 31th of December', () => {
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2017-12-31'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24
- });
-
- it('Ensure year total allowance is correct', () => {
- expect( ul.total_number_of_days_in_allowance ).to.be.eql( 24 );
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-0);
- });
- });
-
- describe('Started last year, today is 15th of December', () => {
- let employee = model.User.build({
- start_date : moment('2016-04-01'),
- });
-
- let ul = new UserAllowance({
- user : employee,
- now : moment('2017-12-15'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24
- });
-
- it('Ensure year total allowance is correct', () => {
- expect( ul.total_number_of_days_in_allowance ).to.be.eql( 24 );
- });
-
- it('Check accrued_adjustment', () => {
- expect( ul.accrued_adjustment ).to.be.eql(-1);
- });
- });
-
- describe('Started this year, calculate available allowance for previous year', () => {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(28)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-12)
+ })
+ })
+
+ describe('Started in Apr, today is Jul: manual adjustments is taked into consideration', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2016-07-01'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 4,
+ carry_over: 0,
+ nominal_allowance: 20
+ })
+
+ it('Ensure year total alloance is correct', function() {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(20 * 0.75 + 4)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-12.5)
+ })
+ })
+
+ describe('Started last year, today is 1 of January', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2017-01-01'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
+
+ it('Ensure year total allowance is correct', function() {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(24)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-24)
+ })
+ })
+
+ describe('Started last year, today is 14th of January', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2017-01-14'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
+
+ it('Ensure year total allowance is correct', function() {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(24)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-23)
+ })
+ })
+
+ describe('Started last year, today is 31th of December', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2017-12-31'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
+
+ it('Ensure year total allowance is correct', function() {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(24)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-0)
+ })
+ })
+
+ describe('Started last year, today is 15th of December', function() {
+ const employee = model.User.build({
+ start_date: moment('2016-04-01')
+ })
+
+ const ul = new UserAllowance({
+ user: employee,
+ now: moment('2017-12-15'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
+
+ it('Ensure year total allowance is correct', function() {
+ expect(ul.total_number_of_days_in_allowance).to.be.eql(24)
+ })
+
+ it('Check accrued_adjustment', function() {
+ expect(ul.accrued_adjustment).to.be.eql(-1)
+ })
+ })
+
+ describe('Started this year, calculate available allowance for previous year', function() {
const employee = model.User.build({
- start_date: moment.utc('2019-01-01'),
- });
+ start_date: moment.utc('2019-01-01')
+ })
const department = model.Department.build({
- is_accrued_allowance: false,
- });
+ is_accrued_allowance: false
+ })
- employee.department = department;
+ employee.department = department
const ul = new UserAllowance({
- user : employee,
- now : moment('2018-01-01'),
+ user: employee,
+ now: moment('2018-01-01'),
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24
- });
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
- it('Ensure available allowance is correct', () => {
- expect( ul.number_of_days_available_in_allowance ).to.be.eql(0);
- });
- });
+ it('Ensure available allowance is correct', function() {
+ expect(ul.number_of_days_available_in_allowance).to.be.eql(0)
+ })
+ })
- describe('Started this year, calculate available allowance for current year', () => {
+ describe('Started this year, calculate available allowance for current year', function() {
const employee = model.User.build({
- start_date: moment.utc('2019-01-01'),
- });
+ start_date: moment.utc('2019-01-01')
+ })
const department = model.Department.build({
- is_accrued_allowance: false,
- });
+ is_accrued_allowance: false
+ })
- employee.department = department;
+ employee.department = department
const ul = new UserAllowance({
- user : employee,
- now : moment('2019-06-01'),
-
- number_of_days_taken_from_allowance : 0,
- manual_adjustment : 0,
- carry_over : 0,
- nominal_allowance : 24
- });
-
- it('Ensure available allowance is correct', () => {
- expect( ul.number_of_days_available_in_allowance ).to.be.eql(24);
- });
- });
-});
+ user: employee,
+ now: moment('2019-06-01'),
+
+ number_of_days_taken_from_allowance: 0,
+ manual_adjustment: 0,
+ carry_over: 0,
+ nominal_allowance: 24
+ })
+
+ it('Ensure available allowance is correct', function() {
+ expect(ul.number_of_days_available_in_allowance).to.be.eql(24)
+ })
+ })
+})
diff --git a/t/unit/slack.js b/t/unit/slack.js
new file mode 100644
index 000000000..27d203842
--- /dev/null
+++ b/t/unit/slack.js
@@ -0,0 +1,32 @@
+'use strict'
+
+const expect = require('chai').expect;
+ const _ = require('underscore');
+ const bluebird = require('bluebird');
+ const Slack = require('../../lib/email')
+
+describe('Check Slack', function() {
+ it('Knows how to render and parse template', function(done) {
+ var Slack = new Slack()
+
+ bluebird
+ .resolve(
+ Slack.promise_rendered_slack_template({
+ template_name: 'foobar',
+ context: {
+ user: {
+ name: 'FOO',
+ reload_with_session_details: function() {
+ bluebird.resolve(1)
+ }
+ }
+ }
+ })
+ )
+ .then(function(email) {
+ expect(Slack.text).to.match(/Hello FOO\./)
+
+ done()
+ })
+ })
+})
diff --git a/t/unit/validator/leave_request.js b/t/unit/validator/leave_request.js
index ab3b51ae2..99e8be303 100644
--- a/t/unit/validator/leave_request.js
+++ b/t/unit/validator/leave_request.js
@@ -1,155 +1,139 @@
-
-'use strict';
-
-var expect = require('chai').expect,
- _ = require('underscore'),
- MockExpressReq = require('../../lib/mock_express_request'),
- leave_request_validator = require('../../../lib/route/validator/leave_request');
-
-
-describe('Check validation for leave request', function(){
-
- it('No parameters provided', function(){
- var req = new MockExpressReq();
-
- expect(function(){
- leave_request_validator({req : req})
- }).to.throw('Got validation errors');
-
- expect( req.session.flash.errors.length ).to.be.equal( 4 );
- });
-
-
- it('User index is invalid', function(){
- var req = new MockExpressReq({
- params : {user : 'foo'},
- });
-
- expect(function(){
- leave_request_validator({req : req})
- }).to.throw('Got validation errors');
-
- expect(
- _.findIndex(
- req.session.flash.errors, function(msg){
- return msg === 'Incorrect employee';
- })
- ).to.be.greaterThan( -1 );
-
- expect( req.session.flash.errors.length ).to.be.equal( 5 );
- });
-
- var valid_params = {
- user : '1',
- leave_type : '1',
- from_date : '2015-05-10',
- from_date_part : '1',
- to_date : '2015-05-12',
- to_date_part : '2',
- reason : 'some reason',
- };
-
-
- it('Successfull scenario', function(){
-
- var req = new MockExpressReq({
- params : valid_params,
- });
-
- expect(
- leave_request_validator({req : req}).as_data_object()
- ).to.be.eql(valid_params);
-
- expect( req.session ).not.to.have.property( 'flash' );
- });
-
-
- it('from_date_part has invalid value', function(){
- var params = _.clone(valid_params);
- params.from_date_part = "11";
- var req = new MockExpressReq({params : params});
- expect(function(){
- leave_request_validator({req : req})
- }).to.throw('Got validation errors');
-
- expect(
- _.findIndex(
- req.session.flash.errors, function(msg){
- return msg === 'Incorrect day part';
- })
- ).to.be.greaterThan( -1 );
-
- expect( req.session.flash.errors.length ).to.be.equal( 1 );
- });
-
-
- it('from_date has invalid value', function(){
- var params = _.clone(valid_params);
- params.from_date = "some horrible date";
- var req = new MockExpressReq({
- params : params,
- });
- expect(function(){
- leave_request_validator({req : req})
- }).to.throw('Got validation errors');
-
- expect(
- _.findIndex(
- req.session.flash.errors, function(msg){
- return msg === 'From date should be a date';
- })
- ).to.be.greaterThan( -1 );
- });
-
-
- it('start dates is greater than end one', function(){
- var params = _.clone(valid_params);
- params.from_date = '2015-04-12';
- params.to_date = '2015-04-02';
- var req = new MockExpressReq({
- params : params,
- });
- expect(function(){
- leave_request_validator({req : req})
- }).to.throw('From date should be before To date');
-
- expect( req.session ).not.to.have.property( 'flash' );
- });
-
-
- it('inter_year leave request', function(){
- var params = _.clone(valid_params);
- params.from_date = '2014-04-12';
- params.to_date = '2015-04-02';
- var req = new MockExpressReq({params : params});
- expect(function(){
- leave_request_validator({req : req})
- }).to.throw('Got validation errors');
-
- expect(
- _.findIndex(
- req.session.flash.errors, function(msg){
- return msg === 'Current implementation does not allow inter year leaves. Please split your request into two parts';
- })
- ).to.be.greaterThan( -1 );
-
- expect( req.session.flash.errors.length ).to.be.equal( 1 );
- });
-
-
- it('Reason is optional', function(){
-
- var params = _.clone( valid_params );
- delete params.reason;
- var vp = _.clone( valid_params );
- vp.reason = '';
- var req = new MockExpressReq({params : params});
-
- expect(
- leave_request_validator({req : req}).as_data_object()
- ).to.be.eql(vp);
-
- expect( req.session ).not.to.have.property( 'flash' );
- });
-
-});
+'use strict'
+
+const expect = require('chai').expect;
+ const _ = require('underscore');
+ const MockExpressReq = require('../../lib/mock_express_request');
+ const leave_request_validator = require('../../../lib/route/validator/leave_request')
+
+describe('Check validation for leave request', function() {
+ it('No parameters provided', function() {
+ const req = new MockExpressReq()
+
+ expect(function() {
+ leave_request_validator({ req, params: req.body })
+ }).to.throw('Got validation errors')
+
+ expect(req.session.flash.errors.length).to.be.equal(4)
+ })
+
+ it('User index is invalid', function() {
+ const req = new MockExpressReq({
+ params: { user: 'foo' }
+ })
+
+ expect(function() {
+ leave_request_validator({ req })
+ }).to.throw('Got validation errors')
+
+ expect(
+ _.findIndex(req.session.flash.errors, function(msg) {
+ return msg === 'Incorrect employee'
+ })
+ ).to.be.greaterThan(-1)
+
+ expect(req.session.flash.errors.length).to.be.equal(5)
+ })
+
+ const valid_params = {
+ user: '1',
+ leave_type: '1',
+ from_date: '2015-05-10',
+ from_date_part: '1',
+ to_date: '2015-05-12',
+ to_date_part: '2',
+ reason: 'some reason'
+ }
+
+ it('Successfull scenario', function() {
+ const req = new MockExpressReq({
+ params: valid_params
+ })
+
+ expect(leave_request_validator({ req }).as_data_object()).to.be.eql(
+ valid_params
+ )
+
+ expect(req.session).not.to.have.property('flash')
+ })
+
+ it('from_date_part has invalid value', function() {
+ const params = _.clone(valid_params)
+ params.from_date_part = '11'
+ const req = new MockExpressReq({ params })
+ expect(function() {
+ leave_request_validator({ req })
+ }).to.throw('Got validation errors')
+
+ expect(
+ _.findIndex(req.session.flash.errors, function(msg) {
+ return msg === 'Incorrect day part'
+ })
+ ).to.be.greaterThan(-1)
+
+ expect(req.session.flash.errors.length).to.be.equal(1)
+ })
+
+ it('from_date has invalid value', function() {
+ const params = _.clone(valid_params)
+ params.from_date = 'some horrible date'
+ const req = new MockExpressReq({
+ params
+ })
+ expect(function() {
+ leave_request_validator({ req })
+ }).to.throw('Got validation errors')
+
+ expect(
+ _.findIndex(req.session.flash.errors, function(msg) {
+ return msg === 'From date should be a date'
+ })
+ ).to.be.greaterThan(-1)
+ })
+
+ it('start dates is greater than end one', function() {
+ const params = _.clone(valid_params)
+ params.from_date = '2015-04-12'
+ params.to_date = '2015-04-02'
+ const req = new MockExpressReq({
+ params
+ })
+ expect(function() {
+ leave_request_validator({ req })
+ }).to.throw('From date should be before To date')
+
+ expect(req.session).not.to.have.property('flash')
+ })
+
+ it('inter_year leave request', function() {
+ const params = _.clone(valid_params)
+ params.from_date = '2014-04-12'
+ params.to_date = '2015-04-02'
+ const req = new MockExpressReq({ params })
+ expect(function() {
+ leave_request_validator({ req })
+ }).to.throw('Got validation errors')
+
+ expect(
+ _.findIndex(req.session.flash.errors, function(msg) {
+ return (
+ msg ===
+ 'Current implementation does not allow inter year leaves. Please split your request into two parts'
+ )
+ })
+ ).to.be.greaterThan(-1)
+
+ expect(req.session.flash.errors.length).to.be.equal(1)
+ })
+
+ it('Reason is optional', function() {
+ const params = _.clone(valid_params)
+ delete params.reason
+ const vp = _.clone(valid_params)
+ vp.reason = ''
+ const req = new MockExpressReq({ params })
+
+ expect(leave_request_validator({ req }).as_data_object()).to.be.eql(vp)
+
+ expect(req.session).not.to.have.property('flash')
+ })
+})
diff --git a/views/departments_bulk_update.hbs b/views/departments_bulk_update.hbs
index 0ae3f75db..937d54626 100644
--- a/views/departments_bulk_update.hbs
+++ b/views/departments_bulk_update.hbs
@@ -56,9 +56,9 @@
-
+
{{#each ../company.users}}
- {{this.full_name}}
+ {{this.full_name}}
{{/each}}
diff --git a/views/departments_overview.hbs b/views/departments_overview.hbs
index 93f4f727d..3dce2f15f 100644
--- a/views/departments_overview.hbs
+++ b/views/departments_overview.hbs
@@ -61,7 +61,7 @@
{{#each departments}}
{{this.name}}
- {{# with this.boss }}{{this.full_name }}{{/with}}
+ {{# with this.manager }}{{this.full_name }}{{/with}}
{{#each ../allowance_options}}{{#if_equal this.value ../allowance}}{{caption}}{{/if_equal}}{{/each}}
diff --git a/views/feeds_list.hbs b/views/feeds_list.hbs
index 3e8233f83..bdf405c03 100644
--- a/views/feeds_list.hbs
+++ b/views/feeds_list.hbs
@@ -50,6 +50,8 @@
+
+ {{/if}}
+
+ {{#if login.google}}
+
+ {{/if}}
diff --git a/views/partials/add_new_bank_holiday_modal.hbs b/views/partials/add_new_bank_holiday_modal.hbs
index 7dd575a5e..9d3256246 100644
--- a/views/partials/add_new_bank_holiday_modal.hbs
+++ b/views/partials/add_new_bank_holiday_modal.hbs
@@ -9,7 +9,7 @@
- {{#each company.bank_holidays}}
+ {{#each bankholidays}}
{{/each}}
diff --git a/views/partials/add_new_department_modal.hbs b/views/partials/add_new_department_modal.hbs
index 67fb0ac44..1faccf495 100644
--- a/views/partials/add_new_department_modal.hbs
+++ b/views/partials/add_new_department_modal.hbs
@@ -36,7 +36,7 @@
+
+ Slack Username
+
+ Slack Username used by this user
+
+
diff --git a/views/partials/user_requests.hbs b/views/partials/user_requests.hbs
index e59e8a07c..30030dffc 100644
--- a/views/partials/user_requests.hbs
+++ b/views/partials/user_requests.hbs
@@ -41,7 +41,7 @@
{{/unless}}
{{else}}
- {{#if_equal this.userId ../logged_user.id }}
+ {{#if_equal this.user_id ../logged_user.id }}
+
+
+
+
In order to prevent a situation where a company account locks itself out, the current administrator ({{# with logged_user}}{{this.full_name}}{{/with}} ) has to enter the password associated with her/his email on the LDAP server.
diff --git a/views/slack/add_new_user_slack.hbs b/views/slack/add_new_user_slack.hbs
new file mode 100644
index 000000000..c3bd82271
--- /dev/null
+++ b/views/slack/add_new_user_slack.hbs
@@ -0,0 +1,11 @@
+Hello *{{new_user.name}}*
+
+*{{#with admin_user}}{{this.full_name}}{{/with}}* just registered new account for you as an employee of *{{company.name}}*.
+
+Follow link below to set new password:
+
+{{# with new_user ~}}
+http://{{get_application_domain}}/reset-password/?t={{this.get_reset_password_token}}
+{{/ with }}
+
+Thanks
diff --git a/views/slack/forgot_password_slack.hbs b/views/slack/forgot_password_slack.hbs
new file mode 100644
index 000000000..230666564
--- /dev/null
+++ b/views/slack/forgot_password_slack.hbs
@@ -0,0 +1,22 @@
+{{# with user ~}}
+Hello *{{this.name}}*,
+
+Somebody just requested a reset password link for your account at TimeOff.
+
+{{# if company.ldap_auth_enabled }}
+The company your account belongs to uses LDAP authentication so we cannot reset
+password for you.
+
+Please contact your system administrator in order to reset the password in Active directory server.
+
+{{ else }}
+
+ Please follow link below to proceed further:
+
+ http://{{get_application_domain}}/reset-password/?t={{this.get_reset_password_token}}
+
+{{/if}}
+
+{{~/ with}}
+
+Thanks
diff --git a/views/slack/leave_request_cancel_to_requestor_slack.hbs b/views/slack/leave_request_cancel_to_requestor_slack.hbs
new file mode 100644
index 000000000..d2aa8d746
--- /dev/null
+++ b/views/slack/leave_request_cancel_to_requestor_slack.hbs
@@ -0,0 +1,5 @@
+Hello *{{#with requester}}{{this.full_name}}{{/with}}*.
+
+Your leave request *{{>leave_request_detail leave=leave }}* was *cancelled*.
+
+Thanks
diff --git a/views/slack/leave_request_cancel_to_supervisor_slack.hbs b/views/slack/leave_request_cancel_to_supervisor_slack.hbs
new file mode 100644
index 000000000..73e17a5b8
--- /dev/null
+++ b/views/slack/leave_request_cancel_to_supervisor_slack.hbs
@@ -0,0 +1,7 @@
+Hello {{#with approver }}{{this.full_name}}{{/with}},
+
+*{{#with requester}}{{this.full_name}}{{/with}} cancelled* leave request *{{>leave_request_detail leave=leave }}*.
+
+No actions are needed.
+
+Thanks
diff --git a/views/slack/leave_request_decision_to_requestor_slack.hbs b/views/slack/leave_request_decision_to_requestor_slack.hbs
new file mode 100644
index 000000000..10472902d
--- /dev/null
+++ b/views/slack/leave_request_decision_to_requestor_slack.hbs
@@ -0,0 +1,5 @@
+Hello *{{#with requester}}{{this.full_name}}{{/with}}*,
+
+{{#with approver }}{{this.full_name}}{{/with}} decided to *{{action}}* your {{#if was_pended_revoke}}cancellation of {{/if}}leave request *{{>leave_request_detail leave=leave }}*.
+
+Thanks
diff --git a/views/slack/leave_request_decision_to_supervisor_slack.hbs b/views/slack/leave_request_decision_to_supervisor_slack.hbs
new file mode 100644
index 000000000..b1db59523
--- /dev/null
+++ b/views/slack/leave_request_decision_to_supervisor_slack.hbs
@@ -0,0 +1,5 @@
+Hello *{{#with approver }}{{this.full_name}}{{/with}}*,
+
+You just processed {{#if was_pended_revoke}}cancellation of {{/if}}leave request {{>leave_request_detail leave=leave }} for {{#with requester}}{{this.full_name}}{{/with}}: to {{action}}.
+
+Thanks
diff --git a/views/slack/leave_request_revoke_to_requestor_autoapprove.hbs b/views/slack/leave_request_revoke_to_requestor_autoapprove.hbs
new file mode 100644
index 000000000..cdec7e108
--- /dev/null
+++ b/views/slack/leave_request_revoke_to_requestor_autoapprove.hbs
@@ -0,0 +1,5 @@
+Hello *{{#with requester}}{{this.full_name}}{{/with}}*,
+
+Your leave *{{>leave_request_detail leave=leave }}* was successfully revoked.
+
+Thanks
diff --git a/views/slack/leave_request_revoke_to_requestor_slack.hbs b/views/slack/leave_request_revoke_to_requestor_slack.hbs
new file mode 100644
index 000000000..173be4e8e
--- /dev/null
+++ b/views/slack/leave_request_revoke_to_requestor_slack.hbs
@@ -0,0 +1,7 @@
+Hello *{{#with requester}}{{this.full_name}}{{/with}}*,
+
+Your leave request *{{>leave_request_detail leave=leave }} cancellation* was sent to *{{#with approver }}{{this.full_name}}{{/with}}*.
+
+There will be another email upon decision.
+
+Thanks
diff --git a/views/slack/leave_request_revoke_to_supervisor_autoapprove.hbs b/views/slack/leave_request_revoke_to_supervisor_autoapprove.hbs
new file mode 100644
index 000000000..489524d14
--- /dev/null
+++ b/views/slack/leave_request_revoke_to_supervisor_autoapprove.hbs
@@ -0,0 +1,7 @@
+Hello {{#with approver }}{{this.full_name}}{{/with}},
+
+*{{#with requester}}{{this.full_name}}{{/with}} cancelled* leave request *{{>leave_request_detail leave=leave }}*.
+
+There is no need to perform any actions regarding this leave.
+
+Thanks
diff --git a/views/slack/leave_request_revoke_to_supervisor_slack.hbs b/views/slack/leave_request_revoke_to_supervisor_slack.hbs
new file mode 100644
index 000000000..591fe3085
--- /dev/null
+++ b/views/slack/leave_request_revoke_to_supervisor_slack.hbs
@@ -0,0 +1,7 @@
+Hello {{#with approver }}{{this.full_name}}{{/with}},
+
+*{{#with requester}}{{this.full_name}}{{/with}} cancelled* leave request *{{>leave_request_detail leave=leave }}*.
+
+Please visit http://{{get_application_domain}}/requests/ page to approve or reject outstanding requests.
+
+Thanks
diff --git a/views/slack/leave_request_to_requestor_autoapprove_slack.hbs b/views/slack/leave_request_to_requestor_autoapprove_slack.hbs
new file mode 100644
index 000000000..e3881da94
--- /dev/null
+++ b/views/slack/leave_request_to_requestor_autoapprove_slack.hbs
@@ -0,0 +1,5 @@
+Hello *{{#with requester}}{{this.full_name}}{{/with}}*
+
+Your new leave *{{>leave_request_detail leave=leave }}* was added and auto approved.
+
+Thanks
diff --git a/views/slack/leave_request_to_requestor_slack.hbs b/views/slack/leave_request_to_requestor_slack.hbs
new file mode 100644
index 000000000..8ce2e62a5
--- /dev/null
+++ b/views/slack/leave_request_to_requestor_slack.hbs
@@ -0,0 +1,7 @@
+Hello *{{#with requester}}{{this.full_name}}{{/with}},*
+
+Your leave request *{{>leave_request_detail leave=leave }} was sent* to {{#with approver }}{{this.full_name}}{{/with}}.
+
+There will be another email upon decision.
+
+Thanks
diff --git a/views/slack/leave_request_to_supervisor_autoapprove_slack.hbs b/views/slack/leave_request_to_supervisor_autoapprove_slack.hbs
new file mode 100644
index 000000000..d1a0d7348
--- /dev/null
+++ b/views/slack/leave_request_to_supervisor_autoapprove_slack.hbs
@@ -0,0 +1,7 @@
+Hello *{{#with approver }}{{this.full_name}}{{/with}}*,
+
+*{{#with requester}}{{this.full_name}}{{/with}}* added new leave *{{>leave_request_detail leave=leave }}*.
+
+There is no need to approve/reject leaves from {{#with requester}}{{this.full_name}}{{/with}}.
+
+Thanks
diff --git a/views/slack/leave_request_to_supervisor_slack.hbs b/views/slack/leave_request_to_supervisor_slack.hbs
new file mode 100644
index 000000000..a24378838
--- /dev/null
+++ b/views/slack/leave_request_to_supervisor_slack.hbs
@@ -0,0 +1,7 @@
+Hello *{{#with approver }}{{this.full_name}}{{/with}}*,
+
+*{{#with requester}}{{this.full_name}}{{/with}}* sent new leave request *{{>leave_request_detail leave=leave }}*.
+
+Please visit http://{{get_application_domain}}/requests/ to approve or reject outstanding requests.
+
+Thanks
diff --git a/views/slack/registration_complete_slack.hbs b/views/slack/registration_complete_slack.hbs
new file mode 100644
index 000000000..0a86ee9fa
--- /dev/null
+++ b/views/slack/registration_complete_slack.hbs
@@ -0,0 +1,5 @@
+Hello *{{user.name}}*,
+
+Thank you for registering new account on TimeOff - {{get_application_domain}}
+
+Thanks
diff --git a/views/slack/reset_password_slack.hbs b/views/slack/reset_password_slack.hbs
new file mode 100644
index 000000000..cc0269f65
--- /dev/null
+++ b/views/slack/reset_password_slack.hbs
@@ -0,0 +1,8 @@
+{{# with user ~}}
+Hello *{{this.name}}*,
+
+Your password for TimeOff was successfully changed.
+
+{{~/ with }}
+
+Thanks
diff --git a/views/user_add.hbs b/views/user_add.hbs
index ecd793c0b..ac1a096a9 100644
--- a/views/user_add.hbs
+++ b/views/user_add.hbs
@@ -52,6 +52,14 @@
Email address used by employee
+
+