@pingux/astro 2.155.0-alpha.0 → 2.155.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/lib/cjs/components/Button/Buttons.styles.d.ts +859 -0
- package/lib/cjs/components/Button/Buttons.styles.js +17 -1
- package/lib/cjs/components/SearchNav/MoreItemsPopover.d.ts +4 -0
- package/lib/cjs/components/SearchNav/MoreItemsPopover.js +74 -0
- package/lib/cjs/components/SearchNav/SearchNav.chromatic.stories.d.ts +6 -0
- package/lib/cjs/components/SearchNav/SearchNav.chromatic.stories.js +101 -0
- package/lib/cjs/components/SearchNav/SearchNav.d.ts +13 -0
- package/lib/cjs/components/SearchNav/SearchNav.js +218 -0
- package/lib/cjs/components/SearchNav/SearchNav.stories.d.ts +6 -0
- package/lib/cjs/components/SearchNav/SearchNav.stories.js +76 -0
- package/lib/cjs/components/SearchNav/SearchNav.styles.d.ts +33 -0
- package/lib/cjs/components/SearchNav/SearchNav.styles.js +51 -0
- package/lib/cjs/components/SearchNav/SearchNav.test.d.ts +1 -0
- package/lib/cjs/components/SearchNav/SearchNav.test.js +610 -0
- package/lib/cjs/components/SearchNav/SearchNavTab.d.ts +4 -0
- package/lib/cjs/components/SearchNav/SearchNavTab.js +69 -0
- package/lib/cjs/components/SearchNav/index.d.ts +1 -0
- package/lib/cjs/components/SearchNav/index.js +14 -0
- package/lib/cjs/components/Text/Text.styles.d.ts +2548 -0
- package/lib/cjs/components/Text/Text.styles.js +23 -1
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +45 -26
- package/lib/cjs/styles/colors.d.ts +6 -0
- package/lib/cjs/styles/colors.js +4 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.d.ts +1 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/colors.js +2 -1
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.d.ts +9 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +10 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/text.d.ts +12 -0
- package/lib/cjs/styles/themeOverrides/nextGenDarkMode/variants/text.js +12 -0
- package/lib/cjs/styles/themes/next-gen/convertedComponentList.js +1 -1
- package/lib/cjs/styles/themes/next-gen/next-gen.d.ts +15 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.d.ts +9 -0
- package/lib/cjs/styles/themes/next-gen/variants/button.js +10 -0
- package/lib/cjs/styles/themes/next-gen/variants/searchNav.d.ts +6 -0
- package/lib/cjs/styles/themes/next-gen/variants/searchNav.js +14 -0
- package/lib/cjs/styles/themes/next-gen/variants/text.d.ts +1 -0
- package/lib/cjs/styles/themes/next-gen/variants/text.js +2 -1
- package/lib/cjs/styles/themes/next-gen/variants/variants.d.ts +5 -0
- package/lib/cjs/styles/themes/next-gen/variants/variants.js +2 -0
- package/lib/cjs/styles/variants/variants.js +2 -0
- package/lib/cjs/types/searchNav.d.ts +49 -0
- package/lib/cjs/types/searchNav.js +6 -0
- package/lib/components/Button/Buttons.styles.js +18 -2
- package/lib/components/SearchNav/MoreItemsPopover.js +60 -0
- package/lib/components/SearchNav/SearchNav.chromatic.stories.js +86 -0
- package/lib/components/SearchNav/SearchNav.js +203 -0
- package/lib/components/SearchNav/SearchNav.stories.js +61 -0
- package/lib/components/SearchNav/SearchNav.styles.js +43 -0
- package/lib/components/SearchNav/SearchNav.test.js +601 -0
- package/lib/components/SearchNav/SearchNavTab.js +55 -0
- package/lib/components/SearchNav/index.js +1 -0
- package/lib/components/Text/Text.styles.js +21 -1
- package/lib/index.js +2 -0
- package/lib/styles/colors.js +4 -0
- package/lib/styles/themeOverrides/nextGenDarkMode/colors.js +2 -1
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/buttons.js +10 -0
- package/lib/styles/themeOverrides/nextGenDarkMode/variants/text.js +12 -0
- package/lib/styles/themes/next-gen/convertedComponentList.js +1 -1
- package/lib/styles/themes/next-gen/variants/button.js +10 -0
- package/lib/styles/themes/next-gen/variants/searchNav.js +6 -0
- package/lib/styles/themes/next-gen/variants/text.js +2 -1
- package/lib/styles/themes/next-gen/variants/variants.js +2 -0
- package/lib/styles/variants/variants.js +2 -0
- package/lib/types/searchNav.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,610 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
|
4
|
+
var _Object$defineProperty2 = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
5
|
+
var _Symbol = require("@babel/runtime-corejs3/core-js-stable/symbol");
|
|
6
|
+
var _Object$create = require("@babel/runtime-corejs3/core-js-stable/object/create");
|
|
7
|
+
var _Object$getPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/get-prototype-of");
|
|
8
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
|
9
|
+
var _Object$setPrototypeOf = require("@babel/runtime-corejs3/core-js-stable/object/set-prototype-of");
|
|
10
|
+
var _Promise = require("@babel/runtime-corejs3/core-js-stable/promise");
|
|
11
|
+
var _reverseInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/reverse");
|
|
12
|
+
var _sliceInstanceProperty2 = require("@babel/runtime-corejs3/core-js-stable/instance/slice");
|
|
13
|
+
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
|
14
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
|
15
|
+
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
16
|
+
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
17
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/define-property"));
|
|
18
|
+
var _slice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/slice"));
|
|
19
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/asyncToGenerator"));
|
|
20
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/createClass"));
|
|
21
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/classCallCheck"));
|
|
22
|
+
var _defineProperty3 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
|
23
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
|
24
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/slicedToArray"));
|
|
25
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
26
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
27
|
+
var _index = require("../../index");
|
|
28
|
+
var _testWrapper = require("../../utils/testUtils/testWrapper");
|
|
29
|
+
var _universalComponentTest = require("../../utils/testUtils/universalComponentTest");
|
|
30
|
+
var _SearchNav = _interopRequireWildcard(require("./SearchNav"));
|
|
31
|
+
var _react2 = require("@emotion/react");
|
|
32
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
33
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = _Object$defineProperty2 && _Object$getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? _Object$getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { _Object$defineProperty2(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
34
|
+
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 exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = _Object$defineProperty2 || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof _Symbol ? _Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return _Object$defineProperty2(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = _Object$create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = _Object$getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = _Object$create(IteratorPrototype); function defineIteratorMethods(prototype) { var _context7; _forEachInstanceProperty(_context7 = ["next", "throw", "return"]).call(_context7, function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], _forEachInstanceProperty(tryLocsList).call(tryLocsList, pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return _Object$setPrototypeOf ? _Object$setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = _Object$create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = _Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return _reverseInstanceProperty(keys).call(keys), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { var _context8; if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, _forEachInstanceProperty(_context8 = this.tryEntries).call(_context8, resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+_sliceInstanceProperty2(name).call(name, 1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
35
|
+
var items = [{
|
|
36
|
+
text: 'Overview',
|
|
37
|
+
key: 'Overview',
|
|
38
|
+
children: (0, _react2.jsx)(_index.Text, null, "Overview body")
|
|
39
|
+
}, {
|
|
40
|
+
text: 'Configuration',
|
|
41
|
+
key: 'Configuration',
|
|
42
|
+
children: (0, _react2.jsx)(_index.Text, null, "Configuration body")
|
|
43
|
+
}, {
|
|
44
|
+
text: 'Resources',
|
|
45
|
+
key: 'Resources',
|
|
46
|
+
children: (0, _react2.jsx)(_index.Text, null, "Resources body")
|
|
47
|
+
}, {
|
|
48
|
+
text: 'Policies',
|
|
49
|
+
key: 'Policies',
|
|
50
|
+
children: (0, _react2.jsx)(_index.Text, null, "Policies body")
|
|
51
|
+
}, {
|
|
52
|
+
text: 'Attribute Mappings',
|
|
53
|
+
key: 'Attribute Mappings',
|
|
54
|
+
children: (0, _react2.jsx)(_index.Text, null, "Attribute body")
|
|
55
|
+
}, {
|
|
56
|
+
text: 'Access',
|
|
57
|
+
key: 'Access',
|
|
58
|
+
children: (0, _react2.jsx)(_index.Text, null, "Access body")
|
|
59
|
+
}, {
|
|
60
|
+
text: 'Integration',
|
|
61
|
+
key: 'Integration',
|
|
62
|
+
children: (0, _react2.jsx)(_index.Text, null, "Integration body")
|
|
63
|
+
}];
|
|
64
|
+
var testId = 'searchNavId';
|
|
65
|
+
var onSelectionChangeCallback = jest.fn();
|
|
66
|
+
var onOpenChangeCallback = jest.fn();
|
|
67
|
+
var defaultProps = {
|
|
68
|
+
items: items,
|
|
69
|
+
'data-testid': testId,
|
|
70
|
+
onSelectionChange: onSelectionChangeCallback
|
|
71
|
+
};
|
|
72
|
+
var MORE_BUTTON_TEXT = 'More';
|
|
73
|
+
var TAB_ITEM_WIDTH = 100;
|
|
74
|
+
var offsetWidthMock;
|
|
75
|
+
var mockContainerWidth = 0;
|
|
76
|
+
var TestComponent = function TestComponent(props) {
|
|
77
|
+
var _items$find;
|
|
78
|
+
var _useState = (0, _react.useState)(items[0].key),
|
|
79
|
+
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
|
80
|
+
selectedKey = _useState2[0],
|
|
81
|
+
setSelectedKey = _useState2[1];
|
|
82
|
+
var setSelectedKeyCallback = function setSelectedKeyCallback(e) {
|
|
83
|
+
setSelectedKey(e);
|
|
84
|
+
};
|
|
85
|
+
return (0, _react2.jsx)(_index.Box, {
|
|
86
|
+
maxWidth: "600px"
|
|
87
|
+
}, (0, _react2.jsx)(_SearchNav["default"], (0, _extends2["default"])({}, props, {
|
|
88
|
+
items: items,
|
|
89
|
+
selectedKey: selectedKey,
|
|
90
|
+
setSelectedKey: function setSelectedKey(e) {
|
|
91
|
+
return setSelectedKeyCallback(e);
|
|
92
|
+
}
|
|
93
|
+
})), (_items$find = (0, _find["default"])(items).call(items, function (item) {
|
|
94
|
+
return item.key === selectedKey;
|
|
95
|
+
})) === null || _items$find === void 0 ? void 0 : _items$find.children);
|
|
96
|
+
};
|
|
97
|
+
var resizeObserverCallback = null;
|
|
98
|
+
|
|
99
|
+
// Mock the global ResizeObserver
|
|
100
|
+
var MockResizeObserver = /*#__PURE__*/(0, _createClass2["default"])(function MockResizeObserver(callback) {
|
|
101
|
+
(0, _classCallCheck2["default"])(this, MockResizeObserver);
|
|
102
|
+
(0, _defineProperty3["default"])(this, "observe", jest.fn());
|
|
103
|
+
(0, _defineProperty3["default"])(this, "unobserve", jest.fn());
|
|
104
|
+
(0, _defineProperty3["default"])(this, "disconnect", jest.fn());
|
|
105
|
+
resizeObserverCallback = callback;
|
|
106
|
+
});
|
|
107
|
+
beforeAll(function () {
|
|
108
|
+
// Overwrite the global ResizeObserver for testing environment
|
|
109
|
+
(0, _defineProperty2["default"])(global, 'ResizeObserver', {
|
|
110
|
+
value: MockResizeObserver,
|
|
111
|
+
writable: true
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
beforeEach(function () {
|
|
115
|
+
mockContainerWidth = 1000; // Default large container width
|
|
116
|
+
|
|
117
|
+
// Mock offsetWidth to return different values for container and children
|
|
118
|
+
offsetWidthMock = jest.spyOn(window.HTMLElement.prototype, 'offsetWidth', 'get').mockImplementation(function () {
|
|
119
|
+
// The tab list container is identified by its role="list"
|
|
120
|
+
if (this.getAttribute('role') === 'list') {
|
|
121
|
+
return mockContainerWidth;
|
|
122
|
+
}
|
|
123
|
+
// The individual items are the <Text> components in the hidden box
|
|
124
|
+
return TAB_ITEM_WIDTH;
|
|
125
|
+
});
|
|
126
|
+
jest.useFakeTimers();
|
|
127
|
+
});
|
|
128
|
+
afterEach(function () {
|
|
129
|
+
offsetWidthMock.mockRestore();
|
|
130
|
+
jest.useRealTimers();
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
// Needs to be added to each components test file
|
|
134
|
+
(0, _universalComponentTest.universalComponentTests)({
|
|
135
|
+
renderComponent: function renderComponent(props) {
|
|
136
|
+
return (0, _react2.jsx)(_SearchNav["default"], (0, _extends2["default"])({}, props, {
|
|
137
|
+
items: items
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
var getComponent = function getComponent(props) {
|
|
142
|
+
return (0, _testWrapper.render)((0, _react2.jsx)(TestComponent, (0, _extends2["default"])({}, defaultProps, props)));
|
|
143
|
+
};
|
|
144
|
+
var MORE_BUTTON_WIDTH = 60; // Use the value from your component
|
|
145
|
+
|
|
146
|
+
describe('Pure Functions Tests', function () {
|
|
147
|
+
// Test the measurement function
|
|
148
|
+
it('measureItemWidths correctly measures the offsetWidth of items', function () {
|
|
149
|
+
// Mock the input data: items array and a refs object with mock offsetWidths
|
|
150
|
+
var mockItems = [{
|
|
151
|
+
key: '1',
|
|
152
|
+
text: 'Item One'
|
|
153
|
+
}, {
|
|
154
|
+
key: '2',
|
|
155
|
+
text: 'Item Two'
|
|
156
|
+
}];
|
|
157
|
+
var mockMeasurementRefs = {
|
|
158
|
+
current: {
|
|
159
|
+
'1': {
|
|
160
|
+
offsetWidth: 100
|
|
161
|
+
},
|
|
162
|
+
'2': {
|
|
163
|
+
offsetWidth: 150
|
|
164
|
+
},
|
|
165
|
+
'3': null // handle missing refs
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
var widths = (0, _SearchNav.measureItemWidths)(mockItems, mockMeasurementRefs);
|
|
170
|
+
|
|
171
|
+
// Assert the expected output
|
|
172
|
+
expect(widths).toEqual({
|
|
173
|
+
'1': 100,
|
|
174
|
+
'2': 150
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
// Test the core logic for calculating visible count
|
|
179
|
+
describe('calculateVisibleCount', function () {
|
|
180
|
+
var mockOrderedItems = (0, _slice["default"])(items).call(items, 0, 3); // Overview, Configuration, Resources
|
|
181
|
+
// Mock widths for these 3 items (width + margin)
|
|
182
|
+
// Overview: 90 + 10 = 100 total width
|
|
183
|
+
// Config: 120 + 10 = 130 total width
|
|
184
|
+
// Resources: 100 + 10 = 110 total width
|
|
185
|
+
var mockItemWidths = {
|
|
186
|
+
'Overview': 90,
|
|
187
|
+
'Configuration': 120,
|
|
188
|
+
'Resources': 100
|
|
189
|
+
};
|
|
190
|
+
var moreButtonWidth = MORE_BUTTON_WIDTH; // 60px
|
|
191
|
+
|
|
192
|
+
it('returns the total count when all items fit within the container', function () {
|
|
193
|
+
// Container width: 100 + 130 + 110 = 340 needed. Set wide enough (e.g., 500)
|
|
194
|
+
var containerWidthFull = 500;
|
|
195
|
+
var visibleCount = (0, _SearchNav.calculateVisibleCount)(containerWidthFull, moreButtonWidth, mockOrderedItems, mockItemWidths);
|
|
196
|
+
expect(visibleCount).toBe(3);
|
|
197
|
+
});
|
|
198
|
+
it('breaks when adding an item and the required space for the "More" button exceeds container width', function () {
|
|
199
|
+
// Set container width to only allow the first two items and the "More" button
|
|
200
|
+
var containerWidthPartial = 290;
|
|
201
|
+
var visibleCount = (0, _SearchNav.calculateVisibleCount)(containerWidthPartial, moreButtonWidth, mockOrderedItems, mockItemWidths);
|
|
202
|
+
// It should fit the first two, but break on the third, so count should be 2.
|
|
203
|
+
expect(visibleCount).toBe(2);
|
|
204
|
+
});
|
|
205
|
+
it('handles an edge case where no items can be visible', function () {
|
|
206
|
+
// Container width is too small to even fit one item's width + the "More" button width
|
|
207
|
+
var containerWidthTiny = 100;
|
|
208
|
+
var visibleCount = (0, _SearchNav.calculateVisibleCount)(containerWidthTiny, moreButtonWidth, mockOrderedItems, mockItemWidths);
|
|
209
|
+
expect(visibleCount).toBe(0);
|
|
210
|
+
});
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
test('component does render', function () {
|
|
214
|
+
getComponent({
|
|
215
|
+
items: items
|
|
216
|
+
});
|
|
217
|
+
var searcgNavComponent = _testWrapper.screen.getByTestId(testId);
|
|
218
|
+
expect(searcgNavComponent).toBeInTheDocument();
|
|
219
|
+
});
|
|
220
|
+
test('visible tab selection updates the selected key and content', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
221
|
+
var resourcesTab;
|
|
222
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
223
|
+
while (1) switch (_context.prev = _context.next) {
|
|
224
|
+
case 0:
|
|
225
|
+
// Setup: Ensure all tabs fit (default mockContainerWidth=1000)
|
|
226
|
+
getComponent({
|
|
227
|
+
items: items
|
|
228
|
+
});
|
|
229
|
+
jest.advanceTimersByTime(100);
|
|
230
|
+
|
|
231
|
+
// Initial state: 'Overview' is selected
|
|
232
|
+
expect(_testWrapper.screen.getByText('Overview body')).toBeInTheDocument();
|
|
233
|
+
|
|
234
|
+
// Click 'Resources' tab
|
|
235
|
+
resourcesTab = _testWrapper.screen.getByRole('link', {
|
|
236
|
+
name: 'Resources'
|
|
237
|
+
});
|
|
238
|
+
_userEvent["default"].click(resourcesTab);
|
|
239
|
+
|
|
240
|
+
// Expect selected key and content to change
|
|
241
|
+
_context.next = 7;
|
|
242
|
+
return _testWrapper.screen.findByText('Resources body');
|
|
243
|
+
case 7:
|
|
244
|
+
case "end":
|
|
245
|
+
return _context.stop();
|
|
246
|
+
}
|
|
247
|
+
}, _callee);
|
|
248
|
+
})));
|
|
249
|
+
test('tabs show a "More" button when content overflows', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
250
|
+
var tabs, moreButton, hiddenItem;
|
|
251
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
252
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
253
|
+
case 0:
|
|
254
|
+
// Use a mock setup that only allows ONE tab to fit:
|
|
255
|
+
offsetWidthMock.mockImplementation(function () {
|
|
256
|
+
if (this.getAttribute('role') === 'list') {
|
|
257
|
+
// Container size only slightly larger than Tab 1's required width (100 + 30 = 130)
|
|
258
|
+
return 250;
|
|
259
|
+
}
|
|
260
|
+
return 100; // Item width
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
getComponent({
|
|
264
|
+
items: items
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
// Advance timers to trigger the visibility calculation
|
|
268
|
+
jest.advanceTimersByTime(100);
|
|
269
|
+
|
|
270
|
+
// Expect 1 visible tab and 2 hidden tabs
|
|
271
|
+
tabs = _testWrapper.screen.getByRole('link');
|
|
272
|
+
expect(tabs).toBeInTheDocument(); // Only 'Tab 1' is visible
|
|
273
|
+
|
|
274
|
+
// Expect the "More" button to show the other 2 tabs
|
|
275
|
+
moreButton = _testWrapper.screen.getByText(MORE_BUTTON_TEXT);
|
|
276
|
+
expect(moreButton).toBeInTheDocument();
|
|
277
|
+
|
|
278
|
+
// Test selection from the menu
|
|
279
|
+
_userEvent["default"].click(moreButton);
|
|
280
|
+
hiddenItem = _testWrapper.screen.getByRole('menuitem', {
|
|
281
|
+
name: 'Access'
|
|
282
|
+
});
|
|
283
|
+
_userEvent["default"].click(hiddenItem);
|
|
284
|
+
|
|
285
|
+
// // Expect Tab 2 content to be shown
|
|
286
|
+
if (!items[1].children) {
|
|
287
|
+
_context2.next = 13;
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
_context2.next = 13;
|
|
291
|
+
return _testWrapper.screen.findByText('Access body');
|
|
292
|
+
case 13:
|
|
293
|
+
expect(onSelectionChangeCallback).toHaveBeenCalled();
|
|
294
|
+
case 14:
|
|
295
|
+
case "end":
|
|
296
|
+
return _context2.stop();
|
|
297
|
+
}
|
|
298
|
+
}, _callee2);
|
|
299
|
+
})));
|
|
300
|
+
test('hidden tab selection updates key, content, and triggers swap', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
|
|
301
|
+
var moreButton, resourcesMenuItem;
|
|
302
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
303
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
304
|
+
case 0:
|
|
305
|
+
// Setup: Mock widths so only the first 2 tabs fit (2 * 110 = 220 + 40(More) = 260)
|
|
306
|
+
// Set container to 300px
|
|
307
|
+
mockContainerWidth = 300;
|
|
308
|
+
getComponent({
|
|
309
|
+
items: items,
|
|
310
|
+
onOpenChange: onOpenChangeCallback
|
|
311
|
+
});
|
|
312
|
+
jest.advanceTimersByTime(100);
|
|
313
|
+
|
|
314
|
+
// Initial check: 'Resources' is hidden, 'More' button is visible
|
|
315
|
+
moreButton = _testWrapper.screen.getByText(MORE_BUTTON_TEXT);
|
|
316
|
+
expect(moreButton).toBeInTheDocument();
|
|
317
|
+
|
|
318
|
+
// Click 'More' button to open menu
|
|
319
|
+
_userEvent["default"].click(moreButton);
|
|
320
|
+
|
|
321
|
+
// Click 'Resources' (hidden item 3)
|
|
322
|
+
resourcesMenuItem = _testWrapper.screen.getByRole('menuitem', {
|
|
323
|
+
name: 'Resources'
|
|
324
|
+
});
|
|
325
|
+
_userEvent["default"].click(resourcesMenuItem);
|
|
326
|
+
|
|
327
|
+
// 1. Expect content update
|
|
328
|
+
_context3.next = 10;
|
|
329
|
+
return _testWrapper.screen.findByText('Resources body');
|
|
330
|
+
case 10:
|
|
331
|
+
_context3.next = 12;
|
|
332
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
333
|
+
// Check the final tab in the visible list (which should be 'Resources')
|
|
334
|
+
var visibleTabs = _testWrapper.screen.getAllByRole('link');
|
|
335
|
+
|
|
336
|
+
// We expect 2 visible tabs: Tab 1 ('Overview') and the newly swapped-in tab ('Resources')
|
|
337
|
+
// We expect the 'More' button to be the third listitem
|
|
338
|
+
expect(visibleTabs.length).toBe(2);
|
|
339
|
+
});
|
|
340
|
+
case 12:
|
|
341
|
+
// 2. Expect swap: 'Resources' should now be visible as the
|
|
342
|
+
// second tab (since 'Configuration' was the second tab)
|
|
343
|
+
_userEvent["default"].click(moreButton);
|
|
344
|
+
_context3.next = 15;
|
|
345
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
346
|
+
// The displaced tab ('Configuration') should now be in the menu
|
|
347
|
+
expect(_testWrapper.screen.getByRole('menuitem', {
|
|
348
|
+
name: 'Configuration'
|
|
349
|
+
})).toBeInTheDocument();
|
|
350
|
+
});
|
|
351
|
+
case 15:
|
|
352
|
+
expect(onOpenChangeCallback).toHaveBeenCalled();
|
|
353
|
+
case 16:
|
|
354
|
+
case "end":
|
|
355
|
+
return _context3.stop();
|
|
356
|
+
}
|
|
357
|
+
}, _callee3);
|
|
358
|
+
})));
|
|
359
|
+
test('resizing container to be very small hides all but one tab', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
360
|
+
var moreButton, longMenuItem;
|
|
361
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
362
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
363
|
+
case 0:
|
|
364
|
+
// Start large (mockContainerWidth = 1000)
|
|
365
|
+
mockContainerWidth = 1000;
|
|
366
|
+
getComponent({
|
|
367
|
+
items: items
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
// Initial calculation (from useLayoutEffect)
|
|
371
|
+
jest.advanceTimersByTime(100);
|
|
372
|
+
|
|
373
|
+
// Initial check: All 7 tabs should be visible
|
|
374
|
+
expect(_testWrapper.screen.queryByText(MORE_BUTTON_TEXT)).not.toBeInTheDocument();
|
|
375
|
+
|
|
376
|
+
// --- Resize Step ---
|
|
377
|
+
|
|
378
|
+
// 1. Shrink: Set container size to allow only 1 tab (110px) + More button (40px) = 150px
|
|
379
|
+
mockContainerWidth = 250;
|
|
380
|
+
|
|
381
|
+
// 2. Manually trigger the ResizeObserver callback
|
|
382
|
+
// This tells the component the container dimensions have changed.
|
|
383
|
+
|
|
384
|
+
(0, _testWrapper.act)(function () {
|
|
385
|
+
if (resizeObserverCallback) {
|
|
386
|
+
resizeObserverCallback([{
|
|
387
|
+
contentRect: {
|
|
388
|
+
width: mockContainerWidth
|
|
389
|
+
}
|
|
390
|
+
}]);
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
// 3. Advance timers to process state updates from the calculation
|
|
395
|
+
(0, _testWrapper.act)(function () {
|
|
396
|
+
jest.advanceTimersByTime(100);
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
// 4. Final check: Only the first tab ('Overview') should remain visible
|
|
400
|
+
_context4.next = 9;
|
|
401
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
402
|
+
// The first tab should be visible
|
|
403
|
+
expect(_testWrapper.screen.getByRole('link', {
|
|
404
|
+
name: 'Overview'
|
|
405
|
+
})).toBeInTheDocument();
|
|
406
|
+
});
|
|
407
|
+
case 9:
|
|
408
|
+
_context4.next = 11;
|
|
409
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
410
|
+
// The second tab should be hidden
|
|
411
|
+
expect(_testWrapper.screen.queryByRole('link', {
|
|
412
|
+
name: 'Configuration'
|
|
413
|
+
})).not.toBeInTheDocument();
|
|
414
|
+
});
|
|
415
|
+
case 11:
|
|
416
|
+
_context4.next = 13;
|
|
417
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
418
|
+
expect(_testWrapper.screen.getByText(MORE_BUTTON_TEXT)).toBeInTheDocument();
|
|
419
|
+
});
|
|
420
|
+
case 13:
|
|
421
|
+
_context4.next = 15;
|
|
422
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
423
|
+
var visibleListItems = _testWrapper.screen.getAllByRole('listitem');
|
|
424
|
+
expect(visibleListItems.length).toBe(2);
|
|
425
|
+
});
|
|
426
|
+
case 15:
|
|
427
|
+
mockContainerWidth = 540;
|
|
428
|
+
(0, _testWrapper.act)(function () {
|
|
429
|
+
if (resizeObserverCallback) {
|
|
430
|
+
resizeObserverCallback([{
|
|
431
|
+
contentRect: {
|
|
432
|
+
width: mockContainerWidth
|
|
433
|
+
}
|
|
434
|
+
}]);
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
// 3. Advance timers to process state updates from the calculation
|
|
439
|
+
(0, _testWrapper.act)(function () {
|
|
440
|
+
jest.advanceTimersByTime(100);
|
|
441
|
+
});
|
|
442
|
+
|
|
443
|
+
// 4. Final check: Only the first tab ('Overview') should remain visible
|
|
444
|
+
_context4.next = 20;
|
|
445
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
446
|
+
// The first tab should be visible
|
|
447
|
+
expect(_testWrapper.screen.getAllByRole('link').length).toBe(4);
|
|
448
|
+
});
|
|
449
|
+
case 20:
|
|
450
|
+
// await waitFor(() => {
|
|
451
|
+
moreButton = _testWrapper.screen.getByText(MORE_BUTTON_TEXT);
|
|
452
|
+
expect(moreButton).toBeInTheDocument();
|
|
453
|
+
|
|
454
|
+
// Click 'More' button to open menu
|
|
455
|
+
_userEvent["default"].click(moreButton);
|
|
456
|
+
|
|
457
|
+
// Click 'Resources' (hidden item 3)
|
|
458
|
+
longMenuItem = _testWrapper.screen.getByRole('menuitem', {
|
|
459
|
+
name: 'Attribute Mappings'
|
|
460
|
+
});
|
|
461
|
+
_userEvent["default"].click(longMenuItem);
|
|
462
|
+
(0, _testWrapper.act)(function () {
|
|
463
|
+
jest.advanceTimersByTime(100);
|
|
464
|
+
});
|
|
465
|
+
case 26:
|
|
466
|
+
case "end":
|
|
467
|
+
return _context4.stop();
|
|
468
|
+
}
|
|
469
|
+
}, _callee4);
|
|
470
|
+
})));
|
|
471
|
+
test('recalculates visible items when More button causes an item to be hidden', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
|
|
472
|
+
var visibleListItems;
|
|
473
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
474
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
475
|
+
case 0:
|
|
476
|
+
// Setup: Container wide enough for 3 tabs, but NOT 3 tabs + More button.
|
|
477
|
+
mockContainerWidth = 350; // Max allowed width
|
|
478
|
+
|
|
479
|
+
// We ensure the mock returns 100 for items and 60 for the More button.
|
|
480
|
+
offsetWidthMock.mockImplementation(function () {
|
|
481
|
+
if (this.getAttribute('role') === 'list') {
|
|
482
|
+
return mockContainerWidth;
|
|
483
|
+
}
|
|
484
|
+
// Assume the 'More' button element has a specific class/role/text for measurement
|
|
485
|
+
// If your More button component has a fixed width in the test environment (60),
|
|
486
|
+
// this mock might not be necessary, but we include it for safety.
|
|
487
|
+
if (this.textContent === 'More') {
|
|
488
|
+
return 60;
|
|
489
|
+
}
|
|
490
|
+
return 100; // Item width
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
getComponent({
|
|
494
|
+
items: items
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
// Manually trigger the ResizeObserver/LayoutEffect calculation
|
|
498
|
+
(0, _testWrapper.act)(function () {
|
|
499
|
+
if (resizeObserverCallback) {
|
|
500
|
+
resizeObserverCallback([{
|
|
501
|
+
contentRect: {
|
|
502
|
+
width: mockContainerWidth
|
|
503
|
+
}
|
|
504
|
+
}]);
|
|
505
|
+
jest.advanceTimersByTime(100);
|
|
506
|
+
} else {
|
|
507
|
+
(0, _testWrapper.act)(function () {
|
|
508
|
+
jest.advanceTimersByTime(100);
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
// Wait for the state update (numVisibleItems = 2)
|
|
514
|
+
// await waitFor(() => {
|
|
515
|
+
// We expect only 2 tabs to be visible (Overview, Configuration)
|
|
516
|
+
// Tab 3 ('Resources') should be hidden.
|
|
517
|
+
|
|
518
|
+
expect(_testWrapper.screen.getByRole('link', {
|
|
519
|
+
name: 'Overview'
|
|
520
|
+
})).toBeInTheDocument();
|
|
521
|
+
expect(_testWrapper.screen.getByRole('link', {
|
|
522
|
+
name: 'Configuration'
|
|
523
|
+
})).toBeInTheDocument();
|
|
524
|
+
expect(_testWrapper.screen.queryByRole('link', {
|
|
525
|
+
name: 'Resources'
|
|
526
|
+
})).not.toBeInTheDocument();
|
|
527
|
+
|
|
528
|
+
// The More button must be visible
|
|
529
|
+
expect(_testWrapper.screen.getByText(MORE_BUTTON_TEXT)).toBeInTheDocument();
|
|
530
|
+
|
|
531
|
+
// Check the final count
|
|
532
|
+
visibleListItems = _testWrapper.screen.getAllByRole('listitem');
|
|
533
|
+
expect(visibleListItems.length).toBe(3); // 2 tabs + 1 More button
|
|
534
|
+
// });
|
|
535
|
+
case 10:
|
|
536
|
+
case "end":
|
|
537
|
+
return _context5.stop();
|
|
538
|
+
}
|
|
539
|
+
}, _callee5);
|
|
540
|
+
})));
|
|
541
|
+
test('covers adjustment logic when More button overflows last item', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6() {
|
|
542
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
543
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
544
|
+
case 0:
|
|
545
|
+
// Force a tight scenario:
|
|
546
|
+
// Container: 279. Max fit for 2 tabs (220). Max fit for 2 tabs + More (280).
|
|
547
|
+
mockContainerWidth = 279;
|
|
548
|
+
|
|
549
|
+
// We ensure the mock returns 100 for items and 60 for the More button.
|
|
550
|
+
offsetWidthMock.mockImplementation(function () {
|
|
551
|
+
if (this.getAttribute('role') === 'list') {
|
|
552
|
+
return mockContainerWidth;
|
|
553
|
+
}
|
|
554
|
+
if (this.textContent === 'More') {
|
|
555
|
+
return 60; // More button width
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
return 100; // Item width
|
|
559
|
+
});
|
|
560
|
+
|
|
561
|
+
getComponent({
|
|
562
|
+
items: items
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
// Manually trigger the ResizeObserver calculation
|
|
566
|
+
(0, _testWrapper.act)(function () {
|
|
567
|
+
if (resizeObserverCallback) {
|
|
568
|
+
resizeObserverCallback([{
|
|
569
|
+
contentRect: {
|
|
570
|
+
width: mockContainerWidth
|
|
571
|
+
}
|
|
572
|
+
}]);
|
|
573
|
+
}
|
|
574
|
+
jest.advanceTimersByTime(100);
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
// Wait for the state update (numVisibleItems will be 1)
|
|
578
|
+
_context6.next = 6;
|
|
579
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
580
|
+
// The while loop should have run once, reducing visibleCount from 2 to 1.
|
|
581
|
+
|
|
582
|
+
expect(_testWrapper.screen.getByRole('link', {
|
|
583
|
+
name: 'Overview'
|
|
584
|
+
})).toBeInTheDocument();
|
|
585
|
+
});
|
|
586
|
+
case 6:
|
|
587
|
+
_context6.next = 8;
|
|
588
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
589
|
+
expect(_testWrapper.screen.queryByRole('link', {
|
|
590
|
+
name: 'Configuration'
|
|
591
|
+
})).not.toBeInTheDocument();
|
|
592
|
+
});
|
|
593
|
+
case 8:
|
|
594
|
+
_context6.next = 10;
|
|
595
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
596
|
+
expect(_testWrapper.screen.getByText(MORE_BUTTON_TEXT)).toBeInTheDocument();
|
|
597
|
+
});
|
|
598
|
+
case 10:
|
|
599
|
+
_context6.next = 12;
|
|
600
|
+
return (0, _testWrapper.waitFor)(function () {
|
|
601
|
+
// Total visible items: 1 tab + 1 More button
|
|
602
|
+
var visibleListItems = _testWrapper.screen.getAllByRole('listitem');
|
|
603
|
+
expect(visibleListItems.length).toBe(2);
|
|
604
|
+
});
|
|
605
|
+
case 12:
|
|
606
|
+
case "end":
|
|
607
|
+
return _context6.stop();
|
|
608
|
+
}
|
|
609
|
+
}, _callee6);
|
|
610
|
+
})));
|