@oneuptime/common 12.0.9 → 12.0.11
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/Models/DatabaseModels/NetworkDevice.ts +44 -0
- package/Models/DatabaseModels/NetworkDeviceLink.ts +116 -0
- package/Models/DatabaseModels/RunnerJob.ts +17 -2
- package/Server/API/LlmProviderAPI.ts +8 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1787400000000-AddDeviceRoleAndDeclaredLinkParent.ts +52 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
- package/Server/Services/NetworkDeviceLabelRuleEngineService.ts +240 -0
- package/Server/Services/NetworkDeviceLinkService.ts +338 -2
- package/Server/Services/NetworkDeviceService.ts +265 -12
- package/Server/Services/RunnerJobService.ts +24 -1
- package/Server/Types/Billing/MeteredPlan/AllMeteredPlans.ts +19 -5
- package/Server/Types/Database/JSONColumnQuery.ts +42 -4
- package/Server/Utils/LLM/LLMService.ts +108 -19
- package/Server/Utils/Monitor/MonitorAlert.ts +22 -115
- package/Server/Utils/Monitor/MonitorIncident.ts +7 -337
- package/Server/Utils/Monitor/MonitorMaintenanceSuppression.ts +27 -2
- package/Server/Utils/Monitor/SeriesResourceLabels.ts +32 -0
- package/Server/Utils/Monitor/SeriesResourceLinker.ts +469 -0
- package/Server/Utils/SSRFProtection.ts +5 -4
- package/Server/Utils/Telemetry/InventoryEntityRegistry.ts +186 -38
- package/Tests/App/AdminDashboard/AdminUsersBulkAddToProject.test.tsx +955 -0
- package/Tests/App/AdminDashboard/BulkAddUsersToProject.test.ts +778 -0
- package/Tests/App/AdminDashboard/BulkAddUsersToProjectModal.test.tsx +1051 -0
- package/Tests/App/Dashboard/AdminNotificationRulesPage.test.tsx +420 -112
- package/Tests/App/Dashboard/OnCallReadinessSurfaces.test.tsx +81 -6
- package/Tests/App/Dashboard/PayAsYouGoConsentGate.test.tsx +543 -0
- package/Tests/App/Dashboard/PayAsYouGoFreePlan.test.ts +125 -0
- package/Tests/App/Dashboard/PayAsYouGoNotices.test.tsx +612 -0
- package/Tests/App/Dashboard/SloWidgetChartRendering.test.tsx +536 -0
- package/Tests/App/Dashboard/UserElementEmail.test.tsx +447 -0
- package/Tests/App/Dashboard/UserEmailCallSites.test.tsx +284 -0
- package/Tests/Models/AnalyticsModels/CommonModel.test.ts +312 -0
- package/Tests/Server/Infrastructure/Postgres/DeviceRoleAndDeclaredLinkParentMigration.test.ts +250 -0
- package/Tests/Server/Infrastructure/Postgres/EpisodeMemberNotifyIndexesMigration.test.ts +46 -18
- package/Tests/Server/Services/NetworkDeviceLabelRuleRun.test.ts +618 -0
- package/Tests/Server/Services/NetworkDeviceLinkParentValidation.test.ts +1043 -0
- package/Tests/Server/Services/NetworkSiteAssignmentRuleRun.test.ts +706 -0
- package/Tests/Server/Services/RunnerJobEnqueue.test.ts +412 -0
- package/Tests/Server/Types/Billing/PayAsYouGoMeteredPricing.test.ts +125 -0
- package/Tests/Server/Types/Database/JSONColumnQuery.test.ts +508 -0
- package/Tests/Server/Utils/AI/LLMServiceRequestPolicy.test.ts +2 -2
- package/Tests/Server/Utils/AI/LLMServiceRetryPolicy.test.ts +450 -0
- package/Tests/Server/Utils/Monitor/MonitorAlertResourceLinking.test.ts +556 -0
- package/Tests/Server/Utils/Monitor/MonitorIncidentResourceLinking.test.ts +547 -0
- package/Tests/Server/Utils/Monitor/MonitorMaintenanceSuppression.test.ts +30 -0
- package/Tests/Server/Utils/Monitor/SeriesResourceLinker.test.ts +699 -0
- package/Tests/Server/Utils/SeriesResourceLabels.test.ts +55 -0
- package/Tests/Server/Utils/Telemetry/InventoryEntityRegistry.test.ts +668 -0
- package/Tests/Types/API/URLMalformedTolerance.test.ts +301 -0
- package/Tests/Types/API/URLTelScheme.test.ts +261 -0
- package/Tests/Types/API/URLUnsupportedScheme.test.ts +148 -0
- package/Tests/Types/Billing/PayAsYouGoPricing.test.ts +64 -0
- package/Tests/Types/CustomField/CustomFieldTypeCorrespondence.test.ts +107 -0
- package/Tests/Types/Monitor/MonitorType.test.ts +62 -0
- package/Tests/Types/NetworkAutomation/RuleRunResult.test.ts +184 -0
- package/Tests/Types/Runbook/RunbookStepType.test.ts +124 -0
- package/Tests/Types/Workflow/BaseModelComponents.test.ts +17 -0
- package/Tests/UI/Components/Button.test.tsx +279 -0
- package/Tests/UI/Components/Charts/ChartXAxisDataKey.test.tsx +256 -0
- package/Tests/UI/Components/Charts/DataPointUtil.test.ts +323 -0
- package/Tests/UI/Components/DictionaryValuePlaceholderAndSuggestions.test.tsx +595 -0
- package/Tests/UI/Components/Icon.test.tsx +57 -0
- package/Tests/UI/Components/List.test.tsx +20 -3
- package/Tests/UI/Components/LogsSavedViewsDropdown.test.tsx +304 -0
- package/Tests/UI/Components/LogsViewerClearSavedView.test.tsx +179 -0
- package/Tests/UI/Components/ModelTable/CustomFieldColumns.test.tsx +349 -1
- package/Tests/UI/Components/Pagination.test.tsx +721 -146
- package/Tests/UI/Components/PaginationIntegration.test.tsx +386 -0
- package/Tests/UI/Components/PaginationUtil.test.ts +417 -0
- package/Tests/UI/Components/TelemetrySavedViewsDropdown.test.tsx +343 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnControl.test.ts +289 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnOperators.test.ts +271 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnRow.test.ts +119 -0
- package/Tests/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.test.ts +968 -0
- package/Tests/UI/Components/Workflow/ModelColumnEditor.render.test.tsx +766 -0
- package/Tests/UI/Utils/RunNetworkRule.test.ts +320 -0
- package/Tests/Utils/APIRetryPolicy.test.ts +823 -0
- package/Tests/Utils/Monitor/NetworkDeviceRoleUtil.test.ts +502 -0
- package/Tests/Utils/Monitor/NetworkTopologyDeclaredHierarchy.test.ts +759 -0
- package/Tests/Utils/NetworkAutomation/RuleRunSummary.test.ts +286 -0
- package/Tests/Utils/Schema/BaseSchema.test.ts +651 -0
- package/Types/API/Protocol.ts +9 -0
- package/Types/API/URL.ts +286 -20
- package/Types/Billing/PayAsYouGoPricing.ts +47 -0
- package/Types/CustomField/CustomFieldType.ts +28 -0
- package/Types/Monitor/MonitorType.ts +11 -0
- package/Types/Monitor/SnmpMonitor/NetworkTopology.ts +13 -0
- package/Types/NetworkAutomation/RuleRunResult.ts +121 -0
- package/Types/Runbook/RunbookStepType.ts +23 -0
- package/UI/Components/AutocompleteTextInput/AutocompleteTextInput.tsx +7 -0
- package/UI/Components/Button/Button.tsx +14 -22
- package/UI/Components/Charts/Area/AreaChart.tsx +4 -2
- package/UI/Components/Charts/Bar/BarChart.tsx +4 -2
- package/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.ts +13 -0
- package/UI/Components/Charts/Line/LineChart.tsx +4 -2
- package/UI/Components/Charts/Types/XAxis/XAxis.ts +6 -0
- package/UI/Components/Charts/Utils/DataPoint.ts +15 -12
- package/UI/Components/Dictionary/Dictionary.tsx +4 -39
- package/UI/Components/Icon/Icon.tsx +1 -1
- package/UI/Components/LogsViewer/LogsViewer.tsx +5 -1
- package/UI/Components/LogsViewer/components/LogsFacetSidebar.tsx +8 -0
- package/UI/Components/LogsViewer/components/LogsPagination.tsx +29 -91
- package/UI/Components/LogsViewer/components/LogsViewerToolbar.tsx +2 -0
- package/UI/Components/LogsViewer/components/SavedViewsDropdown.tsx +66 -1
- package/UI/Components/ModelTable/CustomFieldColumns.tsx +55 -0
- package/UI/Components/Pagination/Pagination.tsx +373 -328
- package/UI/Components/Pagination/PaginationUtil.ts +263 -0
- package/UI/Components/Pagination/Screenshots/README.md +15 -0
- package/UI/Components/Pagination/Screenshots/pagination-before-after.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-go-to-page-modal.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-long-list.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-mobile.png +0 -0
- package/UI/Components/Pagination/Screenshots/pagination-telemetry.png +0 -0
- package/UI/Components/TelemetryViewer/components/SavedViewsDropdown.tsx +66 -1
- package/UI/Components/TelemetryViewer/components/TelemetryPagination.tsx +38 -92
- package/UI/Components/TextArea/TextArea.tsx +3 -0
- package/UI/Components/Workflow/ArgumentsForm.tsx +18 -1
- package/UI/Components/Workflow/ColumnEditor/AddColumnDropdown.tsx +177 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnConditionRow.tsx +243 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnControl.ts +255 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnFieldRow.tsx +178 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnOperators.ts +206 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnRow.ts +157 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.ts +517 -0
- package/UI/Components/Workflow/ColumnEditor/ColumnValueInput.tsx +482 -0
- package/UI/Components/Workflow/ColumnEditor/ModelQueryBuilder.tsx +131 -0
- package/UI/Components/Workflow/ColumnEditor/ModelRecordForm.tsx +163 -0
- package/UI/Components/Workflow/ModelColumnEditor.tsx +284 -100
- package/UI/Utils/NetworkAutomation/RunNetworkRule.ts +122 -0
- package/Utils/API.ts +243 -36
- package/Utils/Monitor/NetworkDeviceRoleUtil.ts +45 -0
- package/Utils/Monitor/NetworkTopologyUtil.ts +42 -2
- package/Utils/NetworkAutomation/RuleRunSummary.ts +147 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js +45 -0
- package/build/dist/Models/DatabaseModels/NetworkDevice.js.map +1 -1
- package/build/dist/Models/DatabaseModels/NetworkDeviceLink.js +115 -0
- package/build/dist/Models/DatabaseModels/NetworkDeviceLink.js.map +1 -1
- package/build/dist/Models/DatabaseModels/RunnerJob.js +17 -2
- package/build/dist/Models/DatabaseModels/RunnerJob.js.map +1 -1
- package/build/dist/Server/API/LlmProviderAPI.js +9 -1
- package/build/dist/Server/API/LlmProviderAPI.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787400000000-AddDeviceRoleAndDeclaredLinkParent.js +33 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1787400000000-AddDeviceRoleAndDeclaredLinkParent.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js +202 -0
- package/build/dist/Server/Services/NetworkDeviceLabelRuleEngineService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceLinkService.js +253 -1
- package/build/dist/Server/Services/NetworkDeviceLinkService.js.map +1 -1
- package/build/dist/Server/Services/NetworkDeviceService.js +223 -12
- package/build/dist/Server/Services/NetworkDeviceService.js.map +1 -1
- package/build/dist/Server/Services/RunnerJobService.js +20 -2
- package/build/dist/Server/Services/RunnerJobService.js.map +1 -1
- package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js +12 -5
- package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js.map +1 -1
- package/build/dist/Server/Types/Database/JSONColumnQuery.js +40 -4
- package/build/dist/Server/Types/Database/JSONColumnQuery.js.map +1 -1
- package/build/dist/Server/Utils/LLM/LLMService.js +78 -22
- package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js +22 -98
- package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js +7 -254
- package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/MonitorMaintenanceSuppression.js +14 -2
- package/build/dist/Server/Utils/Monitor/MonitorMaintenanceSuppression.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js +27 -0
- package/build/dist/Server/Utils/Monitor/SeriesResourceLabels.js.map +1 -1
- package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js +285 -0
- package/build/dist/Server/Utils/Monitor/SeriesResourceLinker.js.map +1 -0
- package/build/dist/Server/Utils/SSRFProtection.js +5 -4
- package/build/dist/Server/Utils/SSRFProtection.js.map +1 -1
- package/build/dist/Server/Utils/Telemetry/InventoryEntityRegistry.js +128 -35
- package/build/dist/Server/Utils/Telemetry/InventoryEntityRegistry.js.map +1 -1
- package/build/dist/Types/API/Protocol.js +9 -0
- package/build/dist/Types/API/Protocol.js.map +1 -1
- package/build/dist/Types/API/URL.js +241 -18
- package/build/dist/Types/API/URL.js.map +1 -1
- package/build/dist/Types/Billing/PayAsYouGoPricing.js +41 -0
- package/build/dist/Types/Billing/PayAsYouGoPricing.js.map +1 -0
- package/build/dist/Types/CustomField/CustomFieldType.js +26 -0
- package/build/dist/Types/CustomField/CustomFieldType.js.map +1 -1
- package/build/dist/Types/Monitor/MonitorType.js +10 -0
- package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
- package/build/dist/Types/NetworkAutomation/RuleRunResult.js +39 -0
- package/build/dist/Types/NetworkAutomation/RuleRunResult.js.map +1 -0
- package/build/dist/Types/Runbook/RunbookStepType.js +21 -0
- package/build/dist/Types/Runbook/RunbookStepType.js.map +1 -1
- package/build/dist/UI/Components/AutocompleteTextInput/AutocompleteTextInput.js +1 -1
- package/build/dist/UI/Components/AutocompleteTextInput/AutocompleteTextInput.js.map +1 -1
- package/build/dist/UI/Components/Button/Button.js +10 -16
- package/build/dist/UI/Components/Button/Button.js.map +1 -1
- package/build/dist/UI/Components/Charts/Area/AreaChart.js +2 -1
- package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js +2 -1
- package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js +12 -0
- package/build/dist/UI/Components/Charts/ChartLibrary/Types/ChartDataPoint.js.map +1 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js +2 -1
- package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js +17 -10
- package/build/dist/UI/Components/Charts/Utils/DataPoint.js.map +1 -1
- package/build/dist/UI/Components/Dictionary/Dictionary.js +4 -18
- package/build/dist/UI/Components/Dictionary/Dictionary.js.map +1 -1
- package/build/dist/UI/Components/Icon/Icon.js +1 -1
- package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js +3 -3
- package/build/dist/UI/Components/LogsViewer/LogsViewer.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js +5 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsFacetSidebar.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsPagination.js +14 -44
- package/build/dist/UI/Components/LogsViewer/components/LogsPagination.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsViewerToolbar.js +1 -1
- package/build/dist/UI/Components/LogsViewer/components/LogsViewerToolbar.js.map +1 -1
- package/build/dist/UI/Components/LogsViewer/components/SavedViewsDropdown.js +20 -2
- package/build/dist/UI/Components/LogsViewer/components/SavedViewsDropdown.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js +42 -0
- package/build/dist/UI/Components/ModelTable/CustomFieldColumns.js.map +1 -1
- package/build/dist/UI/Components/Pagination/Pagination.js +174 -199
- package/build/dist/UI/Components/Pagination/Pagination.js.map +1 -1
- package/build/dist/UI/Components/Pagination/PaginationUtil.js +160 -0
- package/build/dist/UI/Components/Pagination/PaginationUtil.js.map +1 -0
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js +20 -2
- package/build/dist/UI/Components/TelemetryViewer/components/SavedViewsDropdown.js.map +1 -1
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryPagination.js +23 -47
- package/build/dist/UI/Components/TelemetryViewer/components/TelemetryPagination.js.map +1 -1
- package/build/dist/UI/Components/TextArea/TextArea.js +1 -1
- package/build/dist/UI/Components/TextArea/TextArea.js.map +1 -1
- package/build/dist/UI/Components/Workflow/ArgumentsForm.js +14 -2
- package/build/dist/UI/Components/Workflow/ArgumentsForm.js.map +1 -1
- package/build/dist/UI/Components/Workflow/ColumnEditor/AddColumnDropdown.js +86 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/AddColumnDropdown.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnConditionRow.js +119 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnConditionRow.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnControl.js +206 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnControl.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnFieldRow.js +57 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnFieldRow.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnOperators.js +150 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnOperators.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRow.js +67 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRow.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.js +309 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnRowSerialization.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnValueInput.js +204 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ColumnValueInput.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelQueryBuilder.js +66 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelQueryBuilder.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelRecordForm.js +83 -0
- package/build/dist/UI/Components/Workflow/ColumnEditor/ModelRecordForm.js.map +1 -0
- package/build/dist/UI/Components/Workflow/ModelColumnEditor.js +187 -68
- package/build/dist/UI/Components/Workflow/ModelColumnEditor.js.map +1 -1
- package/build/dist/UI/Utils/NetworkAutomation/RunNetworkRule.js +75 -0
- package/build/dist/UI/Utils/NetworkAutomation/RunNetworkRule.js.map +1 -0
- package/build/dist/Utils/API.js +175 -34
- package/build/dist/Utils/API.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkDeviceRoleUtil.js +37 -0
- package/build/dist/Utils/Monitor/NetworkDeviceRoleUtil.js.map +1 -1
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js +25 -3
- package/build/dist/Utils/Monitor/NetworkTopologyUtil.js.map +1 -1
- package/build/dist/Utils/NetworkAutomation/RuleRunSummary.js +78 -0
- package/build/dist/Utils/NetworkAutomation/RuleRunSummary.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import "@testing-library/jest-dom";
|
|
2
|
+
import { describe, expect, it, jest } from "@jest/globals";
|
|
3
|
+
import { fireEvent, render, screen } from "@testing-library/react";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import Table from "../../../UI/Components/Table/Table";
|
|
6
|
+
import LocalTable from "../../../UI/Components/Table/LocalTable";
|
|
7
|
+
import Columns from "../../../UI/Components/Table/Types/Columns";
|
|
8
|
+
import FieldType from "../../../UI/Components/Types/FieldType";
|
|
9
|
+
import SortOrder from "../../../Types/BaseDatabase/SortOrder";
|
|
10
|
+
import LogsPagination from "../../../UI/Components/LogsViewer/components/LogsPagination";
|
|
11
|
+
import TelemetryPagination from "../../../UI/Components/TelemetryViewer/components/TelemetryPagination";
|
|
12
|
+
import getJestMockFunction, { MockFunction } from "../../../Tests/MockType";
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* The pagination control is shared, so what is worth testing at this level is
|
|
16
|
+
* the wiring: that every surface that paginates really renders the inline
|
|
17
|
+
* controls, and that the page number and page size each surface speaks in
|
|
18
|
+
* survive the trip through the adapter.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
jest.mock("react-i18next", () => {
|
|
22
|
+
return {
|
|
23
|
+
useTranslation: () => {
|
|
24
|
+
return {
|
|
25
|
+
t: (key: string, opts?: { defaultValue?: string }): string => {
|
|
26
|
+
return opts?.defaultValue ?? key;
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
interface Row {
|
|
34
|
+
_id?: string | undefined;
|
|
35
|
+
name?: string | undefined;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const columns: Columns<Row> = [
|
|
39
|
+
{ title: "Name", type: FieldType.Text, key: "name" },
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
type MakeRowsFunction = (count: number) => Array<Row>;
|
|
43
|
+
|
|
44
|
+
const makeRows: MakeRowsFunction = (count: number): Array<Row> => {
|
|
45
|
+
return Array.from({ length: count }, (_unused: unknown, index: number) => {
|
|
46
|
+
return { _id: `${index + 1}`, name: `Row ${index + 1}` };
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
describe("Pagination in a Table", () => {
|
|
51
|
+
type RenderTableFunction = (overrides?: {
|
|
52
|
+
currentPageNumber?: number;
|
|
53
|
+
totalItemsCount?: number;
|
|
54
|
+
itemsOnPage?: number;
|
|
55
|
+
rowCount?: number;
|
|
56
|
+
}) => MockFunction;
|
|
57
|
+
|
|
58
|
+
const renderTable: RenderTableFunction = (overrides?: {
|
|
59
|
+
currentPageNumber?: number;
|
|
60
|
+
totalItemsCount?: number;
|
|
61
|
+
itemsOnPage?: number;
|
|
62
|
+
rowCount?: number;
|
|
63
|
+
}): MockFunction => {
|
|
64
|
+
const onNavigateToPage: MockFunction = getJestMockFunction();
|
|
65
|
+
|
|
66
|
+
render(
|
|
67
|
+
<Table<Row>
|
|
68
|
+
id="test-table"
|
|
69
|
+
columns={columns}
|
|
70
|
+
data={makeRows(overrides?.rowCount ?? 10)}
|
|
71
|
+
currentPageNumber={overrides?.currentPageNumber ?? 1}
|
|
72
|
+
totalItemsCount={overrides?.totalItemsCount ?? 240}
|
|
73
|
+
itemsOnPage={overrides?.itemsOnPage ?? 10}
|
|
74
|
+
onNavigateToPage={
|
|
75
|
+
onNavigateToPage as unknown as (
|
|
76
|
+
pageNumber: number,
|
|
77
|
+
itemsOnPage: number,
|
|
78
|
+
) => void
|
|
79
|
+
}
|
|
80
|
+
error=""
|
|
81
|
+
isLoading={false}
|
|
82
|
+
singularLabel="Monitor"
|
|
83
|
+
pluralLabel="Monitors"
|
|
84
|
+
sortBy={null}
|
|
85
|
+
sortOrder={SortOrder.Ascending}
|
|
86
|
+
onSortChanged={() => {}}
|
|
87
|
+
/>,
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return onNavigateToPage;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
it("shows the page size on the page, not behind a menu", () => {
|
|
94
|
+
renderTable();
|
|
95
|
+
|
|
96
|
+
expect(screen.getByLabelText("Rows per page")).toBeInTheDocument();
|
|
97
|
+
expect(screen.queryByTestId("show-pagination-modal-button")).toBeNull();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("changes the page size from the table footer", () => {
|
|
101
|
+
const onNavigateToPage: MockFunction = renderTable();
|
|
102
|
+
|
|
103
|
+
fireEvent.change(screen.getByTestId("pagination-items-on-page-select"), {
|
|
104
|
+
target: { value: "25" },
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
expect(onNavigateToPage).toHaveBeenCalledWith(1, 25);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("jumps straight to a page from the table footer", () => {
|
|
111
|
+
const onNavigateToPage: MockFunction = renderTable();
|
|
112
|
+
|
|
113
|
+
fireEvent.click(screen.getByTestId("pagination-page-3"));
|
|
114
|
+
|
|
115
|
+
expect(onNavigateToPage).toHaveBeenCalledWith(3, 10);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
/*
|
|
119
|
+
* The table is the caller that knows how many rows it actually drew, which
|
|
120
|
+
* is what keeps the last page of a list from over-reporting its range.
|
|
121
|
+
*/
|
|
122
|
+
it("reports the range from the rows the table drew", () => {
|
|
123
|
+
renderTable({
|
|
124
|
+
currentPageNumber: 24,
|
|
125
|
+
totalItemsCount: 236,
|
|
126
|
+
rowCount: 6,
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
130
|
+
"Showing 231-236 of 236 monitors",
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("says there is nothing to page through when the table is empty", () => {
|
|
135
|
+
renderTable({ totalItemsCount: 0, rowCount: 0 });
|
|
136
|
+
|
|
137
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
138
|
+
"No monitors",
|
|
139
|
+
);
|
|
140
|
+
expect(screen.getByTestId("pagination-next-button")).toBeDisabled();
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
describe("Pagination in a LocalTable", () => {
|
|
145
|
+
it("really pages through the data it was given", () => {
|
|
146
|
+
render(
|
|
147
|
+
<LocalTable<Row>
|
|
148
|
+
id="local-table"
|
|
149
|
+
columns={columns}
|
|
150
|
+
data={makeRows(25)}
|
|
151
|
+
singularLabel="Row"
|
|
152
|
+
pluralLabel="Rows"
|
|
153
|
+
/>,
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
expect(screen.getByText("Row 1")).toBeInTheDocument();
|
|
157
|
+
expect(screen.queryByText("Row 11")).toBeNull();
|
|
158
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
159
|
+
"Showing 1-10 of 25 rows",
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
fireEvent.click(screen.getByTestId("pagination-page-2"));
|
|
163
|
+
|
|
164
|
+
expect(screen.getByText("Row 11")).toBeInTheDocument();
|
|
165
|
+
expect(screen.queryByText("Row 1")).toBeNull();
|
|
166
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
167
|
+
"Showing 11-20 of 25 rows",
|
|
168
|
+
);
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
it("shows the short last page without over-reporting it", () => {
|
|
172
|
+
render(
|
|
173
|
+
<LocalTable<Row>
|
|
174
|
+
id="local-table"
|
|
175
|
+
columns={columns}
|
|
176
|
+
data={makeRows(25)}
|
|
177
|
+
singularLabel="Row"
|
|
178
|
+
pluralLabel="Rows"
|
|
179
|
+
/>,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
fireEvent.click(screen.getByTestId("pagination-page-3"));
|
|
183
|
+
|
|
184
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
185
|
+
"Showing 21-25 of 25 rows",
|
|
186
|
+
);
|
|
187
|
+
expect(screen.getByTestId("pagination-next-button")).toBeDisabled();
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
it("re-slices the data when the page size changes", () => {
|
|
191
|
+
render(
|
|
192
|
+
<LocalTable<Row>
|
|
193
|
+
id="local-table"
|
|
194
|
+
columns={columns}
|
|
195
|
+
data={makeRows(25)}
|
|
196
|
+
singularLabel="Row"
|
|
197
|
+
pluralLabel="Rows"
|
|
198
|
+
/>,
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
fireEvent.change(screen.getByTestId("pagination-items-on-page-select"), {
|
|
202
|
+
target: { value: "25" },
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
expect(screen.getByText("Row 25")).toBeInTheDocument();
|
|
206
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
207
|
+
"Showing 1-25 of 25 rows",
|
|
208
|
+
);
|
|
209
|
+
});
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
describe("LogsPagination", () => {
|
|
213
|
+
type RenderLogsPaginationFunction = (overrides?: {
|
|
214
|
+
currentPage?: number;
|
|
215
|
+
totalItems?: number;
|
|
216
|
+
pageSize?: number;
|
|
217
|
+
isDisabled?: boolean;
|
|
218
|
+
}) => { onPageChange: MockFunction; onPageSizeChange: MockFunction };
|
|
219
|
+
|
|
220
|
+
const renderLogsPagination: RenderLogsPaginationFunction = (overrides?: {
|
|
221
|
+
currentPage?: number;
|
|
222
|
+
totalItems?: number;
|
|
223
|
+
pageSize?: number;
|
|
224
|
+
isDisabled?: boolean;
|
|
225
|
+
}): { onPageChange: MockFunction; onPageSizeChange: MockFunction } => {
|
|
226
|
+
const onPageChange: MockFunction = getJestMockFunction();
|
|
227
|
+
const onPageSizeChange: MockFunction = getJestMockFunction();
|
|
228
|
+
|
|
229
|
+
render(
|
|
230
|
+
<LogsPagination
|
|
231
|
+
currentPage={overrides?.currentPage ?? 1}
|
|
232
|
+
totalItems={overrides?.totalItems ?? 500}
|
|
233
|
+
pageSize={overrides?.pageSize ?? 50}
|
|
234
|
+
pageSizeOptions={[50, 100, 250]}
|
|
235
|
+
onPageChange={onPageChange as unknown as (page: number) => void}
|
|
236
|
+
onPageSizeChange={onPageSizeChange as unknown as (size: number) => void}
|
|
237
|
+
isDisabled={overrides?.isDisabled ?? false}
|
|
238
|
+
/>,
|
|
239
|
+
);
|
|
240
|
+
|
|
241
|
+
return { onPageChange: onPageChange, onPageSizeChange: onPageSizeChange };
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
it("prints the range in logs", () => {
|
|
245
|
+
renderLogsPagination();
|
|
246
|
+
|
|
247
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
248
|
+
"Showing 1-50 of 500 logs",
|
|
249
|
+
);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("offers only the page sizes the viewer supports", () => {
|
|
253
|
+
renderLogsPagination();
|
|
254
|
+
|
|
255
|
+
const options: Array<HTMLOptionElement> = Array.from(
|
|
256
|
+
screen
|
|
257
|
+
.getByTestId("pagination-items-on-page-select")
|
|
258
|
+
.querySelectorAll("option"),
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
expect(
|
|
262
|
+
options.map((option: HTMLOptionElement) => {
|
|
263
|
+
return option.value;
|
|
264
|
+
}),
|
|
265
|
+
).toEqual(["50", "100", "250"]);
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it("jumps to a page", () => {
|
|
269
|
+
const { onPageChange, onPageSizeChange } = renderLogsPagination();
|
|
270
|
+
|
|
271
|
+
fireEvent.click(screen.getByTestId("pagination-page-3"));
|
|
272
|
+
|
|
273
|
+
expect(onPageChange).toHaveBeenCalledWith(3);
|
|
274
|
+
expect(onPageSizeChange).not.toHaveBeenCalled();
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
it("jumps to a page in between from the collapsed gap", () => {
|
|
278
|
+
const { onPageChange } = renderLogsPagination();
|
|
279
|
+
|
|
280
|
+
fireEvent.click(screen.getByTestId("pagination-ellipsis-end"));
|
|
281
|
+
fireEvent.change(screen.getByTestId("pagination-go-to-page-input"), {
|
|
282
|
+
target: { value: "7" },
|
|
283
|
+
});
|
|
284
|
+
fireEvent.click(screen.getByTestId("modal-footer-submit-button"));
|
|
285
|
+
|
|
286
|
+
expect(onPageChange).toHaveBeenCalledWith(7);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
/*
|
|
290
|
+
* The viewer takes the page and the page size through two callbacks, so a
|
|
291
|
+
* resize has to report both the new size and the return to page one.
|
|
292
|
+
*/
|
|
293
|
+
it("reports a resize as a size change and a return to page one", () => {
|
|
294
|
+
const { onPageChange, onPageSizeChange } = renderLogsPagination({
|
|
295
|
+
currentPage: 5,
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
fireEvent.change(screen.getByTestId("pagination-items-on-page-select"), {
|
|
299
|
+
target: { value: "250" },
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
expect(onPageSizeChange).toHaveBeenCalledWith(250);
|
|
303
|
+
expect(onPageChange).toHaveBeenCalledWith(1);
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it("freezes while the viewer is busy", () => {
|
|
307
|
+
renderLogsPagination({ isDisabled: true });
|
|
308
|
+
|
|
309
|
+
expect(screen.getByTestId("pagination-next-button")).toBeDisabled();
|
|
310
|
+
expect(
|
|
311
|
+
screen.getByTestId("pagination-items-on-page-select"),
|
|
312
|
+
).toBeDisabled();
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
describe("TelemetryPagination", () => {
|
|
317
|
+
type RenderTelemetryPaginationFunction = (overrides?: {
|
|
318
|
+
currentPage?: number;
|
|
319
|
+
totalItems?: number;
|
|
320
|
+
itemLabel?: string;
|
|
321
|
+
}) => MockFunction;
|
|
322
|
+
|
|
323
|
+
const renderTelemetryPagination: RenderTelemetryPaginationFunction =
|
|
324
|
+
(overrides?: {
|
|
325
|
+
currentPage?: number;
|
|
326
|
+
totalItems?: number;
|
|
327
|
+
itemLabel?: string;
|
|
328
|
+
}): MockFunction => {
|
|
329
|
+
const onPageChange: MockFunction = getJestMockFunction();
|
|
330
|
+
|
|
331
|
+
render(
|
|
332
|
+
<TelemetryPagination
|
|
333
|
+
currentPage={overrides?.currentPage ?? 1}
|
|
334
|
+
totalItems={overrides?.totalItems ?? 240}
|
|
335
|
+
pageSize={20}
|
|
336
|
+
pageSizeOptions={[20, 50, 100]}
|
|
337
|
+
onPageChange={onPageChange as unknown as (page: number) => void}
|
|
338
|
+
onPageSizeChange={() => {}}
|
|
339
|
+
itemLabel={overrides?.itemLabel ?? "traces"}
|
|
340
|
+
/>,
|
|
341
|
+
);
|
|
342
|
+
|
|
343
|
+
return onPageChange;
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
it("prints the range in the caller's own words", () => {
|
|
347
|
+
renderTelemetryPagination();
|
|
348
|
+
|
|
349
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
350
|
+
"Showing 1-20 of 240 traces",
|
|
351
|
+
);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it("uses the singular for a result set of one", () => {
|
|
355
|
+
renderTelemetryPagination({ totalItems: 1 });
|
|
356
|
+
|
|
357
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
358
|
+
"Showing 1 of 1 trace",
|
|
359
|
+
);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
it("falls back to a generic label", () => {
|
|
363
|
+
render(
|
|
364
|
+
<TelemetryPagination
|
|
365
|
+
currentPage={1}
|
|
366
|
+
totalItems={0}
|
|
367
|
+
pageSize={20}
|
|
368
|
+
pageSizeOptions={[20]}
|
|
369
|
+
onPageChange={() => {}}
|
|
370
|
+
onPageSizeChange={() => {}}
|
|
371
|
+
/>,
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
expect(screen.getByTestId("pagination-summary")).toHaveTextContent(
|
|
375
|
+
"No results",
|
|
376
|
+
);
|
|
377
|
+
});
|
|
378
|
+
|
|
379
|
+
it("jumps to the last page in one click", () => {
|
|
380
|
+
const onPageChange: MockFunction = renderTelemetryPagination();
|
|
381
|
+
|
|
382
|
+
fireEvent.click(screen.getByTestId("pagination-page-12"));
|
|
383
|
+
|
|
384
|
+
expect(onPageChange).toHaveBeenCalledWith(12);
|
|
385
|
+
});
|
|
386
|
+
});
|