@ukhomeoffice/cop-react-form-renderer 5.51.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/CheckYourAnswers/CheckYourAnswers.scss +2 -2
- package/dist/components/CollectionPage/CollectionPage.js +11 -1
- package/dist/components/CollectionPage/CollectionPage.test.js +84 -61
- package/dist/components/CollectionSummary/BannerStrip.scss +2 -2
- package/dist/components/CollectionSummary/CollectionSummary.scss +1 -1
- package/dist/components/CollectionSummary/Confirmation.scss +1 -1
- package/dist/components/CollectionSummary/RenderListView.scss +1 -1
- package/dist/components/CollectionSummary/SummaryCard.js +6 -1
- package/dist/components/CollectionSummary/SummaryCard.scss +1 -1
- package/dist/components/CollectionSummary/SummaryCard.test.js +288 -130
- package/dist/components/FormPage/FormPage.scss +1 -1
- package/dist/components/FormRenderer/FormRenderer.scss +1 -1
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +2 -1
- package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +20 -0
- package/dist/components/SummaryList/SummaryList.scss +2 -2
- package/dist/components/TaskList/TaskList.scss +1 -1
- package/package.json +4 -4
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
3
|
var _react = require("@testing-library/react");
|
|
5
4
|
var _react2 = _interopRequireDefault(require("react"));
|
|
6
5
|
var _copReactComponents = require("@ukhomeoffice/cop-react-components");
|
|
@@ -12,14 +11,15 @@ var _SummaryCardValidationContext = _interopRequireDefault(require("./SummaryCar
|
|
|
12
11
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
13
12
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
14
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
15
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
17
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
15
18
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
16
19
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
17
20
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
18
21
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
19
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
20
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
21
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
22
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } // Global imports.
|
|
22
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } // Global imports.
|
|
23
23
|
// Local imports.
|
|
24
24
|
describe('components.CollectionSummary.SummaryCard', function () {
|
|
25
25
|
var classes = _copReactComponents.Utils.classBuilder(_SummaryCard.DEFAULT_CLASS, [], '');
|
|
@@ -174,13 +174,53 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
174
174
|
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
175
175
|
expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
|
|
176
176
|
});
|
|
177
|
+
it('should show the correct conditional title', function () {
|
|
178
|
+
var CONFIG = {
|
|
179
|
+
title: [{
|
|
180
|
+
title: 'Title A',
|
|
181
|
+
show_when: {
|
|
182
|
+
field: 'testField',
|
|
183
|
+
op: '=',
|
|
184
|
+
value: '123'
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
// eslint-disable-next-line no-template-curly-in-string
|
|
188
|
+
title: '${titleText} that is interpolated',
|
|
189
|
+
show_when: {
|
|
190
|
+
field: 'testField',
|
|
191
|
+
op: '=',
|
|
192
|
+
value: '456'
|
|
193
|
+
}
|
|
194
|
+
}]
|
|
195
|
+
};
|
|
196
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
197
|
+
testField: '456'
|
|
198
|
+
});
|
|
199
|
+
var _renderWithValidation5 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
200
|
+
id: ID,
|
|
201
|
+
entryData: CUSTOM_ENTRY,
|
|
202
|
+
config: CONFIG,
|
|
203
|
+
parentCollectionName: "parent",
|
|
204
|
+
formData: {},
|
|
205
|
+
masterPage: {
|
|
206
|
+
childPages: []
|
|
207
|
+
}
|
|
208
|
+
})),
|
|
209
|
+
container = _renderWithValidation5.container;
|
|
210
|
+
var _checkSetup5 = checkSetup(container),
|
|
211
|
+
headerContentDiv = _checkSetup5.headerContentDiv;
|
|
212
|
+
var headerTitle = headerContentDiv.children[0];
|
|
213
|
+
expect(headerTitle.tagName).toEqual('DIV');
|
|
214
|
+
expect(headerTitle.classList).toContain(classes('header-content-title'));
|
|
215
|
+
expect(headerTitle.textContent).toEqual("".concat(ENTRY.titleText, " that is interpolated"));
|
|
216
|
+
});
|
|
177
217
|
it('should correctly interpolate the details', function () {
|
|
178
218
|
var CONFIG = {
|
|
179
219
|
title: 'Title',
|
|
180
220
|
// eslint-disable-next-line no-template-curly-in-string
|
|
181
221
|
details: '${detailsText} that are interpolated'
|
|
182
222
|
};
|
|
183
|
-
var
|
|
223
|
+
var _renderWithValidation6 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
184
224
|
id: ID,
|
|
185
225
|
entryData: ENTRY,
|
|
186
226
|
config: CONFIG,
|
|
@@ -190,9 +230,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
190
230
|
childPages: []
|
|
191
231
|
}
|
|
192
232
|
})),
|
|
193
|
-
container =
|
|
194
|
-
var
|
|
195
|
-
headerContentDiv =
|
|
233
|
+
container = _renderWithValidation6.container;
|
|
234
|
+
var _checkSetup6 = checkSetup(container),
|
|
235
|
+
headerContentDiv = _checkSetup6.headerContentDiv;
|
|
196
236
|
var headerDetails = headerContentDiv.children[1];
|
|
197
237
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
198
238
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
@@ -221,7 +261,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
221
261
|
page: 'testPage'
|
|
222
262
|
}
|
|
223
263
|
};
|
|
224
|
-
var
|
|
264
|
+
var _renderWithValidation7 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
225
265
|
id: ID,
|
|
226
266
|
entryData: ENTRY,
|
|
227
267
|
config: CONFIG,
|
|
@@ -232,9 +272,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
232
272
|
childPages: []
|
|
233
273
|
}
|
|
234
274
|
})),
|
|
235
|
-
container =
|
|
236
|
-
var
|
|
237
|
-
headerActionDiv =
|
|
275
|
+
container = _renderWithValidation7.container;
|
|
276
|
+
var _checkSetup7 = checkSetup(container),
|
|
277
|
+
headerActionDiv = _checkSetup7.headerActionDiv;
|
|
238
278
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
239
279
|
var changeButton = headerActionDiv.children[0];
|
|
240
280
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
@@ -253,7 +293,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
253
293
|
page: 'testPage'
|
|
254
294
|
}
|
|
255
295
|
};
|
|
256
|
-
var
|
|
296
|
+
var _renderWithValidation8 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
257
297
|
id: ID,
|
|
258
298
|
entryData: ENTRY,
|
|
259
299
|
config: CONFIG,
|
|
@@ -265,9 +305,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
265
305
|
},
|
|
266
306
|
inError: inErrorValue
|
|
267
307
|
})),
|
|
268
|
-
container =
|
|
269
|
-
var
|
|
270
|
-
headerActionDiv =
|
|
308
|
+
container = _renderWithValidation8.container;
|
|
309
|
+
var _checkSetup8 = checkSetup(container),
|
|
310
|
+
headerActionDiv = _checkSetup8.headerActionDiv;
|
|
271
311
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
272
312
|
var changeButton = headerActionDiv.children[0];
|
|
273
313
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
@@ -288,7 +328,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
288
328
|
page: 'testPage'
|
|
289
329
|
}
|
|
290
330
|
};
|
|
291
|
-
var
|
|
331
|
+
var _renderWithValidation9 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
292
332
|
id: ID,
|
|
293
333
|
entryData: ENTRY,
|
|
294
334
|
config: CONFIG,
|
|
@@ -299,16 +339,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
299
339
|
childPages: []
|
|
300
340
|
}
|
|
301
341
|
})),
|
|
302
|
-
container =
|
|
303
|
-
var
|
|
304
|
-
headerActionDiv =
|
|
342
|
+
container = _renderWithValidation9.container;
|
|
343
|
+
var _checkSetup9 = checkSetup(container),
|
|
344
|
+
headerActionDiv = _checkSetup9.headerActionDiv;
|
|
305
345
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
306
346
|
var changeButton = headerActionDiv.children[0];
|
|
307
347
|
expect(changeButton.tagName).toEqual('BUTTON');
|
|
308
348
|
expect(changeButton.textContent).toEqual(_SummaryCard.DEFAULT_CHANGE_BUTTON_LABEL);
|
|
309
349
|
});
|
|
310
350
|
it('should not render when no config is provided for it', function () {
|
|
311
|
-
var
|
|
351
|
+
var _renderWithValidation10 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
312
352
|
id: ID,
|
|
313
353
|
entryData: ENTRY,
|
|
314
354
|
config: {},
|
|
@@ -319,9 +359,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
319
359
|
childPages: []
|
|
320
360
|
}
|
|
321
361
|
})),
|
|
322
|
-
container =
|
|
323
|
-
var
|
|
324
|
-
headerActionDiv =
|
|
362
|
+
container = _renderWithValidation10.container;
|
|
363
|
+
var _checkSetup10 = checkSetup(container),
|
|
364
|
+
headerActionDiv = _checkSetup10.headerActionDiv;
|
|
325
365
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
326
366
|
});
|
|
327
367
|
it('should not render when onChange is not supplied', function () {
|
|
@@ -331,7 +371,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
331
371
|
page: 'testPage'
|
|
332
372
|
}
|
|
333
373
|
};
|
|
334
|
-
var
|
|
374
|
+
var _renderWithValidation11 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
335
375
|
id: ID,
|
|
336
376
|
entryData: ENTRY,
|
|
337
377
|
config: CONFIG,
|
|
@@ -341,9 +381,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
341
381
|
childPages: []
|
|
342
382
|
}
|
|
343
383
|
})),
|
|
344
|
-
container =
|
|
345
|
-
var
|
|
346
|
-
headerActionDiv =
|
|
384
|
+
container = _renderWithValidation11.container;
|
|
385
|
+
var _checkSetup11 = checkSetup(container),
|
|
386
|
+
headerActionDiv = _checkSetup11.headerActionDiv;
|
|
347
387
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
348
388
|
});
|
|
349
389
|
});
|
|
@@ -364,7 +404,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
364
404
|
label: 'Delete label'
|
|
365
405
|
}
|
|
366
406
|
};
|
|
367
|
-
var
|
|
407
|
+
var _renderWithValidation12 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
368
408
|
id: ID,
|
|
369
409
|
entryData: ENTRY,
|
|
370
410
|
config: CONFIG,
|
|
@@ -375,9 +415,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
375
415
|
childPages: []
|
|
376
416
|
}
|
|
377
417
|
})),
|
|
378
|
-
container =
|
|
379
|
-
var
|
|
380
|
-
headerActionDiv =
|
|
418
|
+
container = _renderWithValidation12.container;
|
|
419
|
+
var _checkSetup12 = checkSetup(container),
|
|
420
|
+
headerActionDiv = _checkSetup12.headerActionDiv;
|
|
381
421
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
382
422
|
var deleteButton = headerActionDiv.children[0];
|
|
383
423
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
@@ -390,7 +430,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
390
430
|
var CONFIG = {
|
|
391
431
|
deleteAction: {}
|
|
392
432
|
};
|
|
393
|
-
var
|
|
433
|
+
var _renderWithValidation13 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
394
434
|
id: ID,
|
|
395
435
|
entryData: ENTRY,
|
|
396
436
|
config: CONFIG,
|
|
@@ -401,16 +441,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
401
441
|
childPages: []
|
|
402
442
|
}
|
|
403
443
|
})),
|
|
404
|
-
container =
|
|
405
|
-
var
|
|
406
|
-
headerActionDiv =
|
|
444
|
+
container = _renderWithValidation13.container;
|
|
445
|
+
var _checkSetup13 = checkSetup(container),
|
|
446
|
+
headerActionDiv = _checkSetup13.headerActionDiv;
|
|
407
447
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
408
448
|
var deleteButton = headerActionDiv.children[0];
|
|
409
449
|
expect(deleteButton.tagName).toEqual('BUTTON');
|
|
410
450
|
expect(deleteButton.textContent).toEqual(_SummaryCard.DEFAULT_DELETE_BUTTON_LABEL);
|
|
411
451
|
});
|
|
412
452
|
it('should not render when no config is provided for it', function () {
|
|
413
|
-
var
|
|
453
|
+
var _renderWithValidation14 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
414
454
|
id: ID,
|
|
415
455
|
entryData: ENTRY,
|
|
416
456
|
config: {},
|
|
@@ -421,9 +461,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
421
461
|
childPages: []
|
|
422
462
|
}
|
|
423
463
|
})),
|
|
424
|
-
container =
|
|
425
|
-
var
|
|
426
|
-
headerActionDiv =
|
|
464
|
+
container = _renderWithValidation14.container;
|
|
465
|
+
var _checkSetup14 = checkSetup(container),
|
|
466
|
+
headerActionDiv = _checkSetup14.headerActionDiv;
|
|
427
467
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
428
468
|
});
|
|
429
469
|
it('should not render when onDelete is not supplied', function () {
|
|
@@ -432,7 +472,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
432
472
|
label: 'Delete label'
|
|
433
473
|
}
|
|
434
474
|
};
|
|
435
|
-
var
|
|
475
|
+
var _renderWithValidation15 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
436
476
|
id: ID,
|
|
437
477
|
entryData: ENTRY,
|
|
438
478
|
config: CONFIG,
|
|
@@ -442,9 +482,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
442
482
|
childPages: []
|
|
443
483
|
}
|
|
444
484
|
})),
|
|
445
|
-
container =
|
|
446
|
-
var
|
|
447
|
-
headerActionDiv =
|
|
485
|
+
container = _renderWithValidation15.container;
|
|
486
|
+
var _checkSetup15 = checkSetup(container),
|
|
487
|
+
headerActionDiv = _checkSetup15.headerActionDiv;
|
|
448
488
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
449
489
|
});
|
|
450
490
|
it('should correctly render the Details section with entry data', function () {
|
|
@@ -453,7 +493,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
453
493
|
label: 'Delete label'
|
|
454
494
|
}
|
|
455
495
|
};
|
|
456
|
-
var
|
|
496
|
+
var _renderWithValidation16 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
457
497
|
id: ID,
|
|
458
498
|
entryData: ENTRY,
|
|
459
499
|
config: CONFIG,
|
|
@@ -463,7 +503,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
463
503
|
childPages: []
|
|
464
504
|
}
|
|
465
505
|
})),
|
|
466
|
-
container =
|
|
506
|
+
container = _renderWithValidation16.container;
|
|
467
507
|
var detailsSection = container.querySelector('.details');
|
|
468
508
|
expect(detailsSection).not.toBeNull();
|
|
469
509
|
expect(detailsSection.textContent).toContain(ENTRY.summaryText);
|
|
@@ -486,7 +526,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
486
526
|
label: 'Duplicate label'
|
|
487
527
|
}
|
|
488
528
|
};
|
|
489
|
-
var
|
|
529
|
+
var _renderWithValidation17 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
490
530
|
id: ID,
|
|
491
531
|
entryData: ENTRY,
|
|
492
532
|
config: CONFIG,
|
|
@@ -497,9 +537,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
497
537
|
childPages: []
|
|
498
538
|
}
|
|
499
539
|
})),
|
|
500
|
-
container =
|
|
501
|
-
var
|
|
502
|
-
headerActionDiv =
|
|
540
|
+
container = _renderWithValidation17.container;
|
|
541
|
+
var _checkSetup16 = checkSetup(container),
|
|
542
|
+
headerActionDiv = _checkSetup16.headerActionDiv;
|
|
503
543
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
504
544
|
var duplicateButton = headerActionDiv.children[0];
|
|
505
545
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
@@ -512,7 +552,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
512
552
|
var CONFIG = {
|
|
513
553
|
duplicateAction: {}
|
|
514
554
|
};
|
|
515
|
-
var
|
|
555
|
+
var _renderWithValidation18 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
516
556
|
id: ID,
|
|
517
557
|
entryData: ENTRY,
|
|
518
558
|
config: CONFIG,
|
|
@@ -523,16 +563,16 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
523
563
|
childPages: []
|
|
524
564
|
}
|
|
525
565
|
})),
|
|
526
|
-
container =
|
|
527
|
-
var
|
|
528
|
-
headerActionDiv =
|
|
566
|
+
container = _renderWithValidation18.container;
|
|
567
|
+
var _checkSetup17 = checkSetup(container),
|
|
568
|
+
headerActionDiv = _checkSetup17.headerActionDiv;
|
|
529
569
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
530
570
|
var duplicateButton = headerActionDiv.children[0];
|
|
531
571
|
expect(duplicateButton.tagName).toEqual('BUTTON');
|
|
532
572
|
expect(duplicateButton.textContent).toEqual(_SummaryCard.DEFAULT_DUPLICATE_BUTTON_LABEL);
|
|
533
573
|
});
|
|
534
574
|
it('should not render when no config is provided for it', function () {
|
|
535
|
-
var
|
|
575
|
+
var _renderWithValidation19 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
536
576
|
id: ID,
|
|
537
577
|
entryData: ENTRY,
|
|
538
578
|
config: {},
|
|
@@ -543,9 +583,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
543
583
|
childPages: []
|
|
544
584
|
}
|
|
545
585
|
})),
|
|
546
|
-
container =
|
|
547
|
-
var
|
|
548
|
-
headerActionDiv =
|
|
586
|
+
container = _renderWithValidation19.container;
|
|
587
|
+
var _checkSetup18 = checkSetup(container),
|
|
588
|
+
headerActionDiv = _checkSetup18.headerActionDiv;
|
|
549
589
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
550
590
|
});
|
|
551
591
|
it('should not render when onDuplicate is not supplied', function () {
|
|
@@ -554,7 +594,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
554
594
|
label: 'Duplicate label'
|
|
555
595
|
}
|
|
556
596
|
};
|
|
557
|
-
var
|
|
597
|
+
var _renderWithValidation20 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
558
598
|
id: ID,
|
|
559
599
|
entryData: ENTRY,
|
|
560
600
|
config: CONFIG,
|
|
@@ -564,9 +604,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
564
604
|
childPages: []
|
|
565
605
|
}
|
|
566
606
|
})),
|
|
567
|
-
container =
|
|
568
|
-
var
|
|
569
|
-
headerActionDiv =
|
|
607
|
+
container = _renderWithValidation20.container;
|
|
608
|
+
var _checkSetup19 = checkSetup(container),
|
|
609
|
+
headerActionDiv = _checkSetup19.headerActionDiv;
|
|
570
610
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
571
611
|
});
|
|
572
612
|
});
|
|
@@ -598,7 +638,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
598
638
|
}
|
|
599
639
|
}];
|
|
600
640
|
it('should render correctly', function () {
|
|
601
|
-
var
|
|
641
|
+
var _renderWithValidation21 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
602
642
|
id: ID,
|
|
603
643
|
entryData: ENTRY,
|
|
604
644
|
config: CONFIG,
|
|
@@ -609,9 +649,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
609
649
|
},
|
|
610
650
|
inError: true
|
|
611
651
|
})),
|
|
612
|
-
container =
|
|
613
|
-
var
|
|
614
|
-
headerActionDiv =
|
|
652
|
+
container = _renderWithValidation21.container;
|
|
653
|
+
var _checkSetup20 = checkSetup(container),
|
|
654
|
+
headerActionDiv = _checkSetup20.headerActionDiv;
|
|
615
655
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
616
656
|
|
|
617
657
|
// Shows edit button but no quick edit
|
|
@@ -639,7 +679,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
639
679
|
});
|
|
640
680
|
|
|
641
681
|
it('should not render when no config is provided for it', function () {
|
|
642
|
-
var
|
|
682
|
+
var _renderWithValidation22 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
643
683
|
id: ID,
|
|
644
684
|
entryData: ENTRY,
|
|
645
685
|
config: {},
|
|
@@ -650,9 +690,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
650
690
|
},
|
|
651
691
|
inError: true
|
|
652
692
|
})),
|
|
653
|
-
container =
|
|
654
|
-
var
|
|
655
|
-
headerActionDiv =
|
|
693
|
+
container = _renderWithValidation22.container;
|
|
694
|
+
var _checkSetup21 = checkSetup(container),
|
|
695
|
+
headerActionDiv = _checkSetup21.headerActionDiv;
|
|
656
696
|
expect(headerActionDiv.children.length).toEqual(0);
|
|
657
697
|
});
|
|
658
698
|
});
|
|
@@ -695,7 +735,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
695
735
|
entryId: '123',
|
|
696
736
|
error: 'top-level error message'
|
|
697
737
|
}];
|
|
698
|
-
var
|
|
738
|
+
var _renderWithValidation23 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
699
739
|
entryId: CUSTOM_ENTRY.id,
|
|
700
740
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
701
741
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -709,9 +749,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
709
749
|
},
|
|
710
750
|
inError: true
|
|
711
751
|
}))),
|
|
712
|
-
container =
|
|
713
|
-
var
|
|
714
|
-
headerActionDiv =
|
|
752
|
+
container = _renderWithValidation23.container;
|
|
753
|
+
var _checkSetup22 = checkSetup(container),
|
|
754
|
+
headerActionDiv = _checkSetup22.headerActionDiv;
|
|
715
755
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
716
756
|
|
|
717
757
|
// Shows edit button but no quick edit
|
|
@@ -731,7 +771,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
731
771
|
expect(errorSummary.textContent).toContain(TOP_LEVEL_ERRORS[0].error);
|
|
732
772
|
});
|
|
733
773
|
it('should only show errors from validation when it happens, ignoring top-level errors', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
734
|
-
var TOP_LEVEL_ERRORS,
|
|
774
|
+
var TOP_LEVEL_ERRORS, _renderWithValidation24, container, _checkSetup23, headerActionDiv, editButton, quickEdit, errorSummary, component, componentInput, quickEditButtons, saveButton;
|
|
735
775
|
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
736
776
|
while (1) switch (_context3.prev = _context3.next) {
|
|
737
777
|
case 0:
|
|
@@ -740,7 +780,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
740
780
|
entryId: '123',
|
|
741
781
|
error: 'top-level error message'
|
|
742
782
|
}];
|
|
743
|
-
|
|
783
|
+
_renderWithValidation24 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCardValidationContext.default, {
|
|
744
784
|
entryId: CUSTOM_ENTRY.id,
|
|
745
785
|
topLevelErrors: TOP_LEVEL_ERRORS
|
|
746
786
|
}, /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
@@ -754,8 +794,8 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
754
794
|
},
|
|
755
795
|
onQuickEdit: function onQuickEdit() {},
|
|
756
796
|
inError: true
|
|
757
|
-
}))), container =
|
|
758
|
-
|
|
797
|
+
}))), container = _renderWithValidation24.container;
|
|
798
|
+
_checkSetup23 = checkSetup(container), headerActionDiv = _checkSetup23.headerActionDiv;
|
|
759
799
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
760
800
|
|
|
761
801
|
// Shows edit button but no quick edit
|
|
@@ -854,7 +894,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
854
894
|
}
|
|
855
895
|
}];
|
|
856
896
|
it('should render correctly', function () {
|
|
857
|
-
var
|
|
897
|
+
var _renderWithValidation25 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
858
898
|
id: ID,
|
|
859
899
|
entryData: ENTRY,
|
|
860
900
|
config: CONFIG,
|
|
@@ -865,9 +905,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
865
905
|
},
|
|
866
906
|
inError: true
|
|
867
907
|
})),
|
|
868
|
-
container =
|
|
869
|
-
var
|
|
870
|
-
headerActionDiv =
|
|
908
|
+
container = _renderWithValidation25.container;
|
|
909
|
+
var _checkSetup24 = checkSetup(container),
|
|
910
|
+
headerActionDiv = _checkSetup24.headerActionDiv;
|
|
871
911
|
expect(headerActionDiv.children.length).toEqual(1);
|
|
872
912
|
|
|
873
913
|
// Shows edit button but no quick edit
|
|
@@ -901,7 +941,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
901
941
|
return ON_SUBMIT_CALLS.push(patch);
|
|
902
942
|
}
|
|
903
943
|
};
|
|
904
|
-
var
|
|
944
|
+
var _renderWithValidation26 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
905
945
|
id: ID,
|
|
906
946
|
entryData: ENTRY,
|
|
907
947
|
config: CONFIG,
|
|
@@ -914,9 +954,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
914
954
|
}), {
|
|
915
955
|
hooks: hooks
|
|
916
956
|
}),
|
|
917
|
-
container =
|
|
918
|
-
var
|
|
919
|
-
headerActionDiv =
|
|
957
|
+
container = _renderWithValidation26.container;
|
|
958
|
+
var _checkSetup25 = checkSetup(container),
|
|
959
|
+
headerActionDiv = _checkSetup25.headerActionDiv;
|
|
920
960
|
|
|
921
961
|
// Shows edit button but no quick edit
|
|
922
962
|
var editButton = headerActionDiv.children[0];
|
|
@@ -930,7 +970,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
930
970
|
expect(ON_SUBMIT_CALLS.length).toEqual(0);
|
|
931
971
|
});
|
|
932
972
|
it('should return after local validation if errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
933
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
973
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation27, container, _checkSetup26, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
934
974
|
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
935
975
|
while (1) switch (_context6.prev = _context6.next) {
|
|
936
976
|
case 0:
|
|
@@ -945,7 +985,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
945
985
|
var target = _ref5.target;
|
|
946
986
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
947
987
|
};
|
|
948
|
-
|
|
988
|
+
_renderWithValidation27 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
949
989
|
id: ID,
|
|
950
990
|
entryData: _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
951
991
|
index: 0
|
|
@@ -964,8 +1004,8 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
964
1004
|
inError: true
|
|
965
1005
|
}), {
|
|
966
1006
|
hooks: hooks
|
|
967
|
-
}), container =
|
|
968
|
-
|
|
1007
|
+
}), container = _renderWithValidation27.container;
|
|
1008
|
+
_checkSetup26 = checkSetup(container), headerActionDiv = _checkSetup26.headerActionDiv;
|
|
969
1009
|
editButton = headerActionDiv.children[0];
|
|
970
1010
|
_react.fireEvent.click(editButton, {});
|
|
971
1011
|
quickEdit = container.childNodes[0].childNodes[1];
|
|
@@ -1012,7 +1052,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1012
1052
|
}, _callee6);
|
|
1013
1053
|
})));
|
|
1014
1054
|
it('should run hook validation when a value changes and local validation is passed', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
|
|
1015
|
-
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1055
|
+
var ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation28, container, _checkSetup27, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1016
1056
|
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
1017
1057
|
while (1) switch (_context8.prev = _context8.next) {
|
|
1018
1058
|
case 0:
|
|
@@ -1031,7 +1071,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1031
1071
|
var target = _ref9.target;
|
|
1032
1072
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1033
1073
|
};
|
|
1034
|
-
|
|
1074
|
+
_renderWithValidation28 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1035
1075
|
id: ID,
|
|
1036
1076
|
entryData: ENTRY,
|
|
1037
1077
|
config: CONFIG,
|
|
@@ -1048,8 +1088,8 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1048
1088
|
inError: true
|
|
1049
1089
|
}), {
|
|
1050
1090
|
hooks: hooks
|
|
1051
|
-
}), container =
|
|
1052
|
-
|
|
1091
|
+
}), container = _renderWithValidation28.container;
|
|
1092
|
+
_checkSetup27 = checkSetup(container), headerActionDiv = _checkSetup27.headerActionDiv;
|
|
1053
1093
|
editButton = headerActionDiv.children[0];
|
|
1054
1094
|
_react.fireEvent.click(editButton, {});
|
|
1055
1095
|
quickEdit = container.childNodes[0].childNodes[1]; // Make a change
|
|
@@ -1086,7 +1126,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1086
1126
|
}, _callee8);
|
|
1087
1127
|
})));
|
|
1088
1128
|
it('should apply changes if no errors are present', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
|
|
1089
|
-
var inErrorValue, ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT,
|
|
1129
|
+
var inErrorValue, ON_SUBMIT_CALLS, hooks, ON_QUICK_EDIT_CALLS, ON_QUICK_EDIT, _renderWithValidation29, container, _checkSetup28, headerActionDiv, editButton, quickEdit, component, componentInput, quickEditButtons, saveButton;
|
|
1090
1130
|
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
1091
1131
|
while (1) switch (_context10.prev = _context10.next) {
|
|
1092
1132
|
case 0:
|
|
@@ -1103,7 +1143,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1103
1143
|
ON_QUICK_EDIT_CALLS.push(target);
|
|
1104
1144
|
inErrorValue = false;
|
|
1105
1145
|
};
|
|
1106
|
-
|
|
1146
|
+
_renderWithValidation29 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1107
1147
|
id: ID,
|
|
1108
1148
|
entryData: {
|
|
1109
1149
|
index: 0,
|
|
@@ -1123,8 +1163,8 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1123
1163
|
inError: inErrorValue
|
|
1124
1164
|
}), {
|
|
1125
1165
|
hooks: hooks
|
|
1126
|
-
}), container =
|
|
1127
|
-
|
|
1166
|
+
}), container = _renderWithValidation29.container;
|
|
1167
|
+
_checkSetup28 = checkSetup(container), headerActionDiv = _checkSetup28.headerActionDiv;
|
|
1128
1168
|
editButton = headerActionDiv.children[0];
|
|
1129
1169
|
_react.fireEvent.click(editButton, {});
|
|
1130
1170
|
quickEdit = container.childNodes[0].childNodes[1]; // Make a change that will be accepted
|
|
@@ -1172,7 +1212,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1172
1212
|
title: 'Title',
|
|
1173
1213
|
details: DETAILS
|
|
1174
1214
|
};
|
|
1175
|
-
var
|
|
1215
|
+
var _renderWithValidation30 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1176
1216
|
id: ID,
|
|
1177
1217
|
entryData: ENTRY,
|
|
1178
1218
|
config: CONFIG,
|
|
@@ -1183,9 +1223,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1183
1223
|
childPages: []
|
|
1184
1224
|
}
|
|
1185
1225
|
})),
|
|
1186
|
-
container =
|
|
1187
|
-
var
|
|
1188
|
-
headerContentDiv =
|
|
1226
|
+
container = _renderWithValidation30.container;
|
|
1227
|
+
var _checkSetup29 = checkSetup(container),
|
|
1228
|
+
headerContentDiv = _checkSetup29.headerContentDiv;
|
|
1189
1229
|
var headerDetails = headerContentDiv.children[1];
|
|
1190
1230
|
expect(headerDetails.tagName).toEqual('DIV');
|
|
1191
1231
|
expect(headerDetails.classList).toContain(classes('header-content-detail'));
|
|
@@ -1196,7 +1236,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1196
1236
|
title: 'Title',
|
|
1197
1237
|
details: ''
|
|
1198
1238
|
};
|
|
1199
|
-
var
|
|
1239
|
+
var _renderWithValidation31 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1200
1240
|
id: ID,
|
|
1201
1241
|
entryData: ENTRY,
|
|
1202
1242
|
config: CONFIG,
|
|
@@ -1207,9 +1247,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1207
1247
|
childPages: []
|
|
1208
1248
|
}
|
|
1209
1249
|
})),
|
|
1210
|
-
container =
|
|
1211
|
-
var
|
|
1212
|
-
headerContentDiv =
|
|
1250
|
+
container = _renderWithValidation31.container;
|
|
1251
|
+
var _checkSetup30 = checkSetup(container),
|
|
1252
|
+
headerContentDiv = _checkSetup30.headerContentDiv;
|
|
1213
1253
|
// If no details are provided, we expect only the header title to be rendered.
|
|
1214
1254
|
expect(headerContentDiv.children.length).toEqual(1);
|
|
1215
1255
|
var headerTitle = headerContentDiv.children[0];
|
|
@@ -1224,7 +1264,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1224
1264
|
title: 'Title',
|
|
1225
1265
|
details: DETAILS
|
|
1226
1266
|
};
|
|
1227
|
-
var
|
|
1267
|
+
var _renderWithValidation32 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1228
1268
|
id: ID,
|
|
1229
1269
|
entryData: INTERPOLATED_ENTRY,
|
|
1230
1270
|
config: CONFIG,
|
|
@@ -1235,9 +1275,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1235
1275
|
childPages: []
|
|
1236
1276
|
}
|
|
1237
1277
|
})),
|
|
1238
|
-
container =
|
|
1239
|
-
var
|
|
1240
|
-
headerContentDiv =
|
|
1278
|
+
container = _renderWithValidation32.container;
|
|
1279
|
+
var _checkSetup31 = checkSetup(container),
|
|
1280
|
+
headerContentDiv = _checkSetup31.headerContentDiv;
|
|
1241
1281
|
var headerDetails = headerContentDiv.children[1];
|
|
1242
1282
|
var expectedInterpolatedString = _copReactComponents.Utils.interpolateString(DETAILS, INTERPOLATED_ENTRY);
|
|
1243
1283
|
expect(headerDetails.textContent).toEqual(expectedInterpolatedString);
|
|
@@ -1246,7 +1286,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1246
1286
|
var CONFIG = {
|
|
1247
1287
|
title: 'Title'
|
|
1248
1288
|
};
|
|
1249
|
-
var
|
|
1289
|
+
var _renderWithValidation33 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1250
1290
|
id: ID,
|
|
1251
1291
|
entryData: ENTRY,
|
|
1252
1292
|
config: CONFIG,
|
|
@@ -1257,9 +1297,9 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1257
1297
|
childPages: []
|
|
1258
1298
|
}
|
|
1259
1299
|
})),
|
|
1260
|
-
container =
|
|
1261
|
-
var
|
|
1262
|
-
headerContentDiv =
|
|
1300
|
+
container = _renderWithValidation33.container;
|
|
1301
|
+
var _checkSetup32 = checkSetup(container),
|
|
1302
|
+
headerContentDiv = _checkSetup32.headerContentDiv;
|
|
1263
1303
|
var headerDetails = headerContentDiv.querySelector("#".concat(ID, ".titleDetail"));
|
|
1264
1304
|
expect(headerDetails).toBeNull();
|
|
1265
1305
|
});
|
|
@@ -1269,7 +1309,7 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1269
1309
|
title: 'Title',
|
|
1270
1310
|
details: DETAILS
|
|
1271
1311
|
};
|
|
1272
|
-
var
|
|
1312
|
+
var _renderWithValidation34 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1273
1313
|
id: ID,
|
|
1274
1314
|
entryData: ENTRY,
|
|
1275
1315
|
config: CONFIG,
|
|
@@ -1281,14 +1321,14 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1281
1321
|
childPages: []
|
|
1282
1322
|
}
|
|
1283
1323
|
})),
|
|
1284
|
-
container =
|
|
1324
|
+
container = _renderWithValidation34.container;
|
|
1285
1325
|
var detailsComponent = container.querySelector('.details');
|
|
1286
1326
|
expect(detailsComponent).toBeNull();
|
|
1287
1327
|
});
|
|
1288
1328
|
});
|
|
1289
1329
|
describe('SummaryLayout config behavior', function () {
|
|
1290
1330
|
it('should render sections and fields based on summaryLayout config', function () {
|
|
1291
|
-
var
|
|
1331
|
+
var CHILD_PAGES = [{
|
|
1292
1332
|
summaryLayout: {
|
|
1293
1333
|
sections: [{
|
|
1294
1334
|
title: 'Section 1',
|
|
@@ -1311,18 +1351,18 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1311
1351
|
var CONFIG = {
|
|
1312
1352
|
title: 'Title'
|
|
1313
1353
|
};
|
|
1314
|
-
var
|
|
1354
|
+
var _renderWithValidation35 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1315
1355
|
id: ID,
|
|
1316
1356
|
entryData: ENTRY,
|
|
1317
1357
|
config: CONFIG,
|
|
1318
1358
|
parentCollectionName: "parent",
|
|
1319
|
-
pages:
|
|
1359
|
+
pages: CHILD_PAGES,
|
|
1320
1360
|
formData: {},
|
|
1321
1361
|
masterPage: {
|
|
1322
|
-
childPages:
|
|
1362
|
+
childPages: CHILD_PAGES
|
|
1323
1363
|
}
|
|
1324
1364
|
})),
|
|
1325
|
-
container =
|
|
1365
|
+
container = _renderWithValidation35.container;
|
|
1326
1366
|
|
|
1327
1367
|
// Function to find an element by its text content
|
|
1328
1368
|
function getByTextContent(parent, text) {
|
|
@@ -1334,16 +1374,134 @@ describe('components.CollectionSummary.SummaryCard', function () {
|
|
|
1334
1374
|
// Check for section titles
|
|
1335
1375
|
var section1Title = getByTextContent(container, 'Section 1');
|
|
1336
1376
|
var section2Title = getByTextContent(container, 'Section 2');
|
|
1337
|
-
expect(section1Title).not.
|
|
1338
|
-
expect(section2Title).not.
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1377
|
+
expect(section1Title).not.toBeUndefined();
|
|
1378
|
+
expect(section2Title).not.toBeUndefined();
|
|
1379
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1380
|
+
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
1381
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1382
|
+
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
1383
|
+
});
|
|
1384
|
+
it('should render sections if they have show_when checks and pass them', function () {
|
|
1385
|
+
var CHILD_PAGES = [{
|
|
1386
|
+
summaryLayout: {
|
|
1387
|
+
sections: [{
|
|
1388
|
+
title: 'Section 1',
|
|
1389
|
+
columns: 2,
|
|
1390
|
+
fields: ['fieldA', 'fieldB'],
|
|
1391
|
+
show_when: [{
|
|
1392
|
+
field: 'showSection1',
|
|
1393
|
+
op: "=",
|
|
1394
|
+
value: true
|
|
1395
|
+
}]
|
|
1396
|
+
}, {
|
|
1397
|
+
title: 'Section 2',
|
|
1398
|
+
columns: 1,
|
|
1399
|
+
fields: ['fieldC']
|
|
1400
|
+
}]
|
|
1401
|
+
},
|
|
1402
|
+
components: [{
|
|
1403
|
+
fieldId: 'fieldA'
|
|
1404
|
+
}, {
|
|
1405
|
+
fieldId: 'fieldB'
|
|
1406
|
+
}, {
|
|
1407
|
+
fieldId: 'fieldC'
|
|
1408
|
+
}]
|
|
1409
|
+
}];
|
|
1410
|
+
var CONFIG = {
|
|
1411
|
+
title: 'Title'
|
|
1412
|
+
};
|
|
1413
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
1414
|
+
showSection1: true
|
|
1415
|
+
});
|
|
1416
|
+
var _renderWithValidation36 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1417
|
+
id: ID,
|
|
1418
|
+
entryData: CUSTOM_ENTRY,
|
|
1419
|
+
config: CONFIG,
|
|
1420
|
+
parentCollectionName: "parent",
|
|
1421
|
+
pages: CHILD_PAGES,
|
|
1422
|
+
formData: {},
|
|
1423
|
+
masterPage: {
|
|
1424
|
+
childPages: CHILD_PAGES
|
|
1425
|
+
}
|
|
1426
|
+
})),
|
|
1427
|
+
container = _renderWithValidation36.container;
|
|
1428
|
+
|
|
1429
|
+
// Function to find an element by its text content
|
|
1430
|
+
function getByTextContent(parent, text) {
|
|
1431
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
1432
|
+
return el.textContent === text;
|
|
1433
|
+
});
|
|
1342
1434
|
}
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1435
|
+
|
|
1436
|
+
// Check for section titles
|
|
1437
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
1438
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
1439
|
+
expect(section1Title).not.toBeUndefined();
|
|
1440
|
+
expect(section2Title).not.toBeUndefined();
|
|
1441
|
+
var section1Content = section1Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1442
|
+
expect(section1Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(2);
|
|
1443
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1444
|
+
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
1445
|
+
});
|
|
1446
|
+
it('should not render sections if they have show_when checks and fail them', function () {
|
|
1447
|
+
var CHILD_PAGES = [{
|
|
1448
|
+
summaryLayout: {
|
|
1449
|
+
sections: [{
|
|
1450
|
+
title: 'Section 1',
|
|
1451
|
+
columns: 2,
|
|
1452
|
+
fields: ['fieldA', 'fieldB'],
|
|
1453
|
+
show_when: [{
|
|
1454
|
+
field: 'showSection1',
|
|
1455
|
+
op: "=",
|
|
1456
|
+
value: true
|
|
1457
|
+
}]
|
|
1458
|
+
}, {
|
|
1459
|
+
title: 'Section 2',
|
|
1460
|
+
columns: 1,
|
|
1461
|
+
fields: ['fieldC']
|
|
1462
|
+
}]
|
|
1463
|
+
},
|
|
1464
|
+
components: [{
|
|
1465
|
+
fieldId: 'fieldA'
|
|
1466
|
+
}, {
|
|
1467
|
+
fieldId: 'fieldB'
|
|
1468
|
+
}, {
|
|
1469
|
+
fieldId: 'fieldC'
|
|
1470
|
+
}]
|
|
1471
|
+
}];
|
|
1472
|
+
var CONFIG = {
|
|
1473
|
+
title: 'Title'
|
|
1474
|
+
};
|
|
1475
|
+
var CUSTOM_ENTRY = _objectSpread(_objectSpread({}, ENTRY), {}, {
|
|
1476
|
+
showSection1: false
|
|
1477
|
+
});
|
|
1478
|
+
var _renderWithValidation37 = (0, _setupTests.renderWithValidation)( /*#__PURE__*/_react2.default.createElement(_SummaryCard.default, {
|
|
1479
|
+
id: ID,
|
|
1480
|
+
entryData: CUSTOM_ENTRY,
|
|
1481
|
+
config: CONFIG,
|
|
1482
|
+
parentCollectionName: "parent",
|
|
1483
|
+
pages: CHILD_PAGES,
|
|
1484
|
+
formData: {},
|
|
1485
|
+
masterPage: {
|
|
1486
|
+
childPages: CHILD_PAGES
|
|
1487
|
+
}
|
|
1488
|
+
})),
|
|
1489
|
+
container = _renderWithValidation37.container;
|
|
1490
|
+
|
|
1491
|
+
// Function to find an element by its text content
|
|
1492
|
+
function getByTextContent(parent, text) {
|
|
1493
|
+
return Array.from(parent.getElementsByClassName(classes('section-title'))).find(function (el) {
|
|
1494
|
+
return el.textContent === text;
|
|
1495
|
+
});
|
|
1346
1496
|
}
|
|
1497
|
+
|
|
1498
|
+
// Check for section titles
|
|
1499
|
+
var section1Title = getByTextContent(container, 'Section 1');
|
|
1500
|
+
var section2Title = getByTextContent(container, 'Section 2');
|
|
1501
|
+
expect(section1Title).toBeUndefined();
|
|
1502
|
+
expect(section2Title).not.toBeUndefined();
|
|
1503
|
+
var section2Content = section2Title.parentNode.querySelector(".".concat(classes('section-content')));
|
|
1504
|
+
expect(section2Content.querySelectorAll(".".concat(classes('field'))).length).toEqual(1);
|
|
1347
1505
|
});
|
|
1348
1506
|
});
|
|
1349
1507
|
});
|