@oneuptime/common 14.0.2 → 14.0.3
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/AlertFeed.ts +2 -0
- package/Models/DatabaseModels/IncidentAlert.ts +540 -0
- package/Models/DatabaseModels/IncidentFeed.ts +2 -0
- package/Models/DatabaseModels/Index.ts +2 -0
- package/Models/DatabaseModels/Project.ts +60 -0
- package/Models/DatabaseModels/RumApplication.ts +52 -1
- package/Server/Infrastructure/Postgres/SchemaMigrations/1794800000000-AddSessionReplaySameOriginTracePropagation.ts +28 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/1794900000000-AddIncidentAlert.ts +89 -0
- package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
- package/Server/Services/IncidentAlertService.ts +1811 -0
- package/Server/Services/IncidentService.ts +210 -10
- package/Server/Services/IncidentStateTimelineService.ts +24 -0
- package/Server/Services/Index.ts +2 -0
- package/Server/Utils/SessionReplay/SessionReplayGateCache.ts +24 -2
- package/Tests/App/Dashboard/BulkIncidentLinkActions.test.tsx +869 -0
- package/Tests/App/Dashboard/CephMetricTooltips.test.tsx +1777 -0
- package/Tests/App/Dashboard/CloudFleetSummary.test.ts +8 -0
- package/Tests/App/Dashboard/CloudMetricTooltips.test.tsx +887 -0
- package/Tests/App/Dashboard/ContainerHostMetricTooltips.test.tsx +1309 -0
- package/Tests/App/Dashboard/DiscoveryScanLivePage.test.tsx +39 -0
- package/Tests/App/Dashboard/DockerSwarmClustersListTooltips.test.tsx +414 -0
- package/Tests/App/Dashboard/DockerSwarmMetricTooltips.test.ts +796 -0
- package/Tests/App/Dashboard/DockerSwarmOverviewTooltips.test.tsx +747 -0
- package/Tests/App/Dashboard/ExceptionMonitorEnvironmentFilter.test.tsx +38 -18
- package/Tests/App/Dashboard/HostDetailViewTooltips.test.tsx +725 -0
- package/Tests/App/Dashboard/HostListColumnTooltips.test.tsx +472 -0
- package/Tests/App/Dashboard/HostMetricTooltips.test.ts +709 -0
- package/Tests/App/Dashboard/HostOverviewTooltips.test.tsx +698 -0
- package/Tests/App/Dashboard/HostTooltipHarness.ts +124 -0
- package/Tests/App/Dashboard/HostsListTooltips.test.tsx +395 -0
- package/Tests/App/Dashboard/IncidentAlertLinkDialog.test.tsx +691 -0
- package/Tests/App/Dashboard/IncidentAlertLinkHelpers.test.ts +458 -0
- package/Tests/App/Dashboard/IncidentAlertLinkPages.test.tsx +828 -0
- package/Tests/App/Dashboard/IncidentAlertLinkSideMenus.test.tsx +231 -0
- package/Tests/App/Dashboard/IncidentCreateFromAlerts.test.tsx +689 -0
- package/Tests/App/Dashboard/IoTMetricTooltips.test.tsx +1123 -0
- package/Tests/App/Dashboard/KubernetesClusterMetricTooltips.test.ts +837 -0
- package/Tests/App/Dashboard/KubernetesClusterOverviewTooltips.test.tsx +699 -0
- package/Tests/App/Dashboard/KubernetesContainersTabTooltips.test.tsx +320 -0
- package/Tests/App/Dashboard/KubernetesCostTooltips.test.tsx +502 -0
- package/Tests/App/Dashboard/KubernetesInsightsTooltips.test.tsx +222 -0
- package/Tests/App/Dashboard/KubernetesResourceMetricTooltips.test.ts +561 -0
- package/Tests/App/Dashboard/KubernetesResourcePagesTooltips.test.tsx +1168 -0
- package/Tests/App/Dashboard/LinkIncidentAlertModal.test.tsx +154 -0
- package/Tests/App/Dashboard/MetricDescriptionRules.ts +170 -0
- package/Tests/App/Dashboard/MetricDescriptionsCatalog.test.ts +206 -0
- package/Tests/App/Dashboard/MetricDescriptionsConsistency.test.ts +275 -0
- package/Tests/App/Dashboard/NetworkDeviceTooltips.test.tsx +852 -0
- package/Tests/App/Dashboard/NetworkDiagnosticsTooltips.test.tsx +556 -0
- package/Tests/App/Dashboard/NetworkMetricTooltips.test.ts +1348 -0
- package/Tests/App/Dashboard/NetworkSiteTooltips.test.tsx +679 -0
- package/Tests/App/Dashboard/ProxmoxMetricTooltips.test.ts +592 -0
- package/Tests/App/Dashboard/ProxmoxOverviewTooltips.test.tsx +1002 -0
- package/Tests/App/Dashboard/ProxmoxResourcePageTooltips.test.tsx +923 -0
- package/Tests/App/Dashboard/ResourceOverviewTileTooltips.test.tsx +1066 -0
- package/Tests/App/Dashboard/RumOverviewPage.test.tsx +1195 -0
- package/Tests/App/Dashboard/ServerlessMetricTooltips.test.tsx +474 -0
- package/Tests/App/Dashboard/ServiceMetricTooltips.test.tsx +772 -0
- package/Tests/App/Dashboard/SessionReplayAuditTable.test.tsx +56 -1
- package/Tests/App/Dashboard/TelemetryMetricsSignals.test.ts +1207 -0
- package/Tests/App/Dashboard/TelemetryResourceTabTooltips.test.tsx +437 -0
- package/Tests/App/Dashboard/VMwareMetricTooltips.test.ts +801 -0
- package/Tests/App/Dashboard/VMwareOverviewTooltips.test.tsx +601 -0
- package/Tests/App/Dashboard/VMwareResourcePagesTooltips.test.tsx +646 -0
- package/Tests/App/Dashboard/VMwareTooltipHarness.ts +145 -0
- package/Tests/Models/DatabaseModels/IncidentAlertModel.test.ts +554 -0
- package/Tests/Models/DatabaseModels/SessionReplayModels.test.ts +117 -0
- package/Tests/Server/Infrastructure/Postgres/AddIncidentAlertMigration.test.ts +341 -0
- package/Tests/Server/Infrastructure/Postgres/AddSessionReplaySameOriginTracePropagationMigration.test.ts +247 -0
- package/Tests/Server/Services/IncidentAlertPostgres.test.ts +903 -0
- package/Tests/Server/Services/IncidentAlertRegistration.test.ts +96 -0
- package/Tests/Server/Services/IncidentAlertService.test.ts +2225 -0
- package/Tests/Server/Services/IncidentAlertStateCascade.test.ts +970 -0
- package/Tests/Server/Services/IncidentCreateFromAlerts.test.ts +1284 -0
- package/Tests/Server/Utils/SessionReplay/SessionReplayGateCachePolicy.test.ts +103 -0
- package/Tests/Types/Rum/WebVitals.test.ts +173 -0
- package/Tests/UI/Components/FieldLabelInfoCardTooltip.test.tsx +413 -0
- package/Tests/UI/Components/InfoTooltip.test.tsx +242 -0
- package/Tests/UI/Components/ModelTable/BaseModelTableBulkDelete.test.tsx +207 -3
- package/Tests/UI/Components/ModelTable/BaseModelTableBulkDeleteVerb.test.tsx +367 -0
- package/Tests/UI/Components/ModelTable/BaseModelTableCreateButtonTitle.test.tsx +275 -0
- package/Tests/UI/Components/TableHeaderTooltip.test.tsx +662 -0
- package/Tests/UI/Rum/PrivacySummaryCard.test.tsx +166 -9
- package/Tests/UI/Rum/RecordingHealthTooltips.test.tsx +447 -0
- package/Tests/UI/Rum/ReplayCorrelationPanel.test.tsx +164 -0
- package/Tests/UI/Rum/ReplayFrameCapture.test.ts +6750 -0
- package/Tests/UI/Rum/ReplayRail.test.tsx +723 -12
- package/Tests/UI/Rum/ReplayRailDetail.test.tsx +86 -0
- package/Tests/UI/Rum/ReplayScreenshot.test.ts +2124 -0
- package/Tests/UI/Rum/ReplayScreenshotActions.test.tsx +3288 -0
- package/Tests/UI/Rum/ReplayStage.test.tsx +62 -0
- package/Tests/UI/Rum/ReplayStageOverlays.test.tsx +983 -2
- package/Tests/UI/Rum/SessionReplaySettingsPolicyLoading.test.tsx +149 -0
- package/Tests/UI/Rum/SessionReplaySetupGuide.test.tsx +107 -6
- package/Tests/UI/Rum/SessionReplayUsersTableTooltips.test.tsx +330 -0
- package/Tests/UI/Rum/UserFlowTooltips.test.tsx +886 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealBreadcrumbTrails.ts +10 -0
- package/Tests/UI/Utils/Breadcrumb/fixtures/RealRoutePatterns.ts +2 -0
- package/Tests/UI/Utils/PermissionGate.test.ts +76 -0
- package/Tests/Utils/Incident/IncidentFromAlerts.test.ts +696 -0
- package/Tests/Utils/Rum/SessionTraceState.test.ts +239 -0
- package/Types/Incident/IncidentAlertLink.ts +38 -0
- package/Types/Permission.ts +48 -0
- package/Types/Rum/SessionReplay.ts +25 -6
- package/Types/Rum/WebVitals.ts +52 -0
- package/UI/Components/Detail/FieldLabel.tsx +8 -0
- package/UI/Components/InfoCard/InfoCard.tsx +47 -1
- package/UI/Components/ModelTable/BaseModelTable.tsx +95 -17
- package/UI/Components/ModelTable/Column.ts +5 -0
- package/UI/Components/Table/TableHeader.tsx +47 -2
- package/UI/Components/Table/Types/Column.ts +7 -0
- package/UI/Components/Tooltip/InfoTooltip.tsx +78 -0
- package/UI/Utils/PermissionGate.ts +11 -2
- package/Utils/Incident/IncidentFromAlerts.ts +516 -0
- package/Utils/Rum/SessionTraceState.ts +212 -0
- package/build/dist/Models/DatabaseModels/AlertFeed.js +2 -0
- package/build/dist/Models/DatabaseModels/AlertFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/IncidentAlert.js +553 -0
- package/build/dist/Models/DatabaseModels/IncidentAlert.js.map +1 -0
- package/build/dist/Models/DatabaseModels/IncidentFeed.js +2 -0
- package/build/dist/Models/DatabaseModels/IncidentFeed.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Index.js +2 -0
- package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
- package/build/dist/Models/DatabaseModels/Project.js +62 -0
- package/build/dist/Models/DatabaseModels/Project.js.map +1 -1
- package/build/dist/Models/DatabaseModels/RumApplication.js +53 -1
- package/build/dist/Models/DatabaseModels/RumApplication.js.map +1 -1
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1794800000000-AddSessionReplaySameOriginTracePropagation.js +20 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1794800000000-AddSessionReplaySameOriginTracePropagation.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1794900000000-AddIncidentAlert.js +42 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1794900000000-AddIncidentAlert.js.map +1 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
- package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
- package/build/dist/Server/Services/IncidentAlertService.js +1370 -0
- package/build/dist/Server/Services/IncidentAlertService.js.map +1 -0
- package/build/dist/Server/Services/IncidentService.js +164 -12
- package/build/dist/Server/Services/IncidentService.js.map +1 -1
- package/build/dist/Server/Services/IncidentStateTimelineService.js +21 -0
- package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
- package/build/dist/Server/Services/Index.js +2 -0
- package/build/dist/Server/Services/Index.js.map +1 -1
- package/build/dist/Server/Utils/SessionReplay/SessionReplayGateCache.js +8 -0
- package/build/dist/Server/Utils/SessionReplay/SessionReplayGateCache.js.map +1 -1
- package/build/dist/Types/Incident/IncidentAlertLink.js +34 -0
- package/build/dist/Types/Incident/IncidentAlertLink.js.map +1 -0
- package/build/dist/Types/Permission.js +42 -0
- package/build/dist/Types/Permission.js.map +1 -1
- package/build/dist/Types/Rum/WebVitals.js +25 -0
- package/build/dist/Types/Rum/WebVitals.js.map +1 -1
- package/build/dist/UI/Components/Detail/FieldLabel.js +2 -0
- package/build/dist/UI/Components/Detail/FieldLabel.js.map +1 -1
- package/build/dist/UI/Components/InfoCard/InfoCard.js +22 -1
- package/build/dist/UI/Components/InfoCard/InfoCard.js.map +1 -1
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js +66 -14
- package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
- package/build/dist/UI/Components/Table/TableHeader.js +18 -2
- package/build/dist/UI/Components/Table/TableHeader.js.map +1 -1
- package/build/dist/UI/Components/Tooltip/InfoTooltip.js +28 -0
- package/build/dist/UI/Components/Tooltip/InfoTooltip.js.map +1 -0
- package/build/dist/UI/Utils/PermissionGate.js +4 -2
- package/build/dist/UI/Utils/PermissionGate.js.map +1 -1
- package/build/dist/Utils/Incident/IncidentFromAlerts.js +306 -0
- package/build/dist/Utils/Incident/IncidentFromAlerts.js.map +1 -0
- package/build/dist/Utils/Rum/SessionTraceState.js +154 -0
- package/build/dist/Utils/Rum/SessionTraceState.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { describe, expect, test } from "@jest/globals";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import {
|
|
5
|
+
MigrationInterface,
|
|
6
|
+
QueryRunner,
|
|
7
|
+
getMetadataArgsStorage,
|
|
8
|
+
} from "typeorm";
|
|
9
|
+
import type { ColumnMetadataArgs } from "typeorm/metadata-args/ColumnMetadataArgs";
|
|
10
|
+
import RumApplication from "../../../../Models/DatabaseModels/RumApplication";
|
|
11
|
+
import SchemaMigrations from "../../../../Server/Infrastructure/Postgres/SchemaMigrations/Index";
|
|
12
|
+
import { AddSessionReplaySameOriginTracePropagation1794800000000 } from "../../../../Server/Infrastructure/Postgres/SchemaMigrations/1794800000000-AddSessionReplaySameOriginTracePropagation";
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* The migration behind RumApplication.sessionReplaySameOriginTracePropagation:
|
|
16
|
+
* the per-application switch for the browser recorder's automatic
|
|
17
|
+
* traceparent + session tracestate on requests to the page's own origin.
|
|
18
|
+
*
|
|
19
|
+
* The one decision the SQL carries is DEFAULT true on a NOT NULL column:
|
|
20
|
+
* Postgres fills every EXISTING application with true as the column appears,
|
|
21
|
+
* so installed recorders start linking on their next page load with no
|
|
22
|
+
* backfill statement to forget, and the column is the way to turn it off
|
|
23
|
+
* without a customer redeploy. The statements are executed against a fake
|
|
24
|
+
* QueryRunner, so up() and down() are told apart.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const MIGRATION_TIMESTAMP: string = "1794800000000";
|
|
28
|
+
|
|
29
|
+
const MIGRATION_BASE_NAME: string =
|
|
30
|
+
"AddSessionReplaySameOriginTracePropagation";
|
|
31
|
+
|
|
32
|
+
const MIGRATION_FILE_NAME: string = `${MIGRATION_TIMESTAMP}-${MIGRATION_BASE_NAME}.ts`;
|
|
33
|
+
|
|
34
|
+
const MIGRATION_CLASS_NAME: string = `${MIGRATION_BASE_NAME}${MIGRATION_TIMESTAMP}`;
|
|
35
|
+
|
|
36
|
+
const MIGRATION_DIRECTORY: string = path.join(
|
|
37
|
+
__dirname,
|
|
38
|
+
"../../../../Server/Infrastructure/Postgres/SchemaMigrations",
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const ADD_SQL: string = `ALTER TABLE "RumApplication" ADD "sessionReplaySameOriginTracePropagation" boolean NOT NULL DEFAULT true`;
|
|
42
|
+
|
|
43
|
+
const DROP_SQL: string = `ALTER TABLE "RumApplication" DROP COLUMN "sessionReplaySameOriginTracePropagation"`;
|
|
44
|
+
|
|
45
|
+
const CLASS_TIMESTAMP: RegExp = /(\d{13})$/;
|
|
46
|
+
|
|
47
|
+
type MakeQueryRunnerResult = {
|
|
48
|
+
runner: QueryRunner;
|
|
49
|
+
statements: Array<string>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type MakeQueryRunnerFunction = () => MakeQueryRunnerResult;
|
|
53
|
+
|
|
54
|
+
const makeQueryRunner: MakeQueryRunnerFunction = (): MakeQueryRunnerResult => {
|
|
55
|
+
const statements: Array<string> = [];
|
|
56
|
+
|
|
57
|
+
const query: (...args: Array<unknown>) => Promise<undefined> = (
|
|
58
|
+
...args: Array<unknown>
|
|
59
|
+
): Promise<undefined> => {
|
|
60
|
+
statements.push(String(args[0]));
|
|
61
|
+
return Promise.resolve(undefined);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
runner: { query } as unknown as QueryRunner,
|
|
66
|
+
statements,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
async function upStatements(): Promise<Array<string>> {
|
|
71
|
+
const { runner, statements } = makeQueryRunner();
|
|
72
|
+
await new AddSessionReplaySameOriginTracePropagation1794800000000().up(
|
|
73
|
+
runner,
|
|
74
|
+
);
|
|
75
|
+
return statements;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function downStatements(): Promise<Array<string>> {
|
|
79
|
+
const { runner, statements } = makeQueryRunner();
|
|
80
|
+
await new AddSessionReplaySameOriginTracePropagation1794800000000().down(
|
|
81
|
+
runner,
|
|
82
|
+
);
|
|
83
|
+
return statements;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
describe("executing it", () => {
|
|
87
|
+
test("up() adds exactly the one column and does nothing else", async () => {
|
|
88
|
+
expect(await upStatements()).toEqual([ADD_SQL]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("down() drops exactly that column and nothing else", async () => {
|
|
92
|
+
expect(await downStatements()).toEqual([DROP_SQL]);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* On for existing applications too: the default IS the rollout. No
|
|
97
|
+
* UPDATE, because ADD COLUMN ... NOT NULL DEFAULT true already writes true
|
|
98
|
+
* into every existing row.
|
|
99
|
+
*/
|
|
100
|
+
test("existing applications get the switch on through the column default, with no backfill", async () => {
|
|
101
|
+
const statements: Array<string> = await upStatements();
|
|
102
|
+
|
|
103
|
+
expect(statements[0]).toContain("boolean NOT NULL DEFAULT true");
|
|
104
|
+
|
|
105
|
+
for (const statement of [...statements, ...(await downStatements())]) {
|
|
106
|
+
expect(statement).not.toContain("UPDATE");
|
|
107
|
+
expect(statement).not.toContain("INDEX");
|
|
108
|
+
expect(statement).not.toContain("DEFAULT false");
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test("every statement is a complete, single statement", async () => {
|
|
113
|
+
const statements: Array<string> = [
|
|
114
|
+
...(await upStatements()),
|
|
115
|
+
...(await downStatements()),
|
|
116
|
+
];
|
|
117
|
+
|
|
118
|
+
expect(statements).toHaveLength(2);
|
|
119
|
+
|
|
120
|
+
for (const statement of statements) {
|
|
121
|
+
expect(statement).not.toContain(";");
|
|
122
|
+
expect(statement).not.toContain("\n");
|
|
123
|
+
expect(statement.trim()).toBe(statement);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test("is a MigrationInterface whose two steps are still named up and down", () => {
|
|
128
|
+
const migration: MigrationInterface =
|
|
129
|
+
new AddSessionReplaySameOriginTracePropagation1794800000000();
|
|
130
|
+
|
|
131
|
+
expect(typeof migration.up).toBe("function");
|
|
132
|
+
expect(typeof migration.down).toBe("function");
|
|
133
|
+
expect(
|
|
134
|
+
Object.getOwnPropertyNames(
|
|
135
|
+
AddSessionReplaySameOriginTracePropagation1794800000000.prototype,
|
|
136
|
+
).sort(),
|
|
137
|
+
).toEqual(["constructor", "down", "up"]);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
describe("the migration runs", () => {
|
|
142
|
+
test("it is imported and listed in Index.ts", () => {
|
|
143
|
+
const index: string = fs.readFileSync(
|
|
144
|
+
path.join(MIGRATION_DIRECTORY, "Index.ts"),
|
|
145
|
+
"utf8",
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
expect(index).toContain(
|
|
149
|
+
`import { ${MIGRATION_CLASS_NAME} } from "./${MIGRATION_TIMESTAMP}-${MIGRATION_BASE_NAME}";`,
|
|
150
|
+
);
|
|
151
|
+
expect(index).toContain(` ${MIGRATION_CLASS_NAME},\n`);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test("it is in the exported migration list, exactly once", () => {
|
|
155
|
+
expect(SchemaMigrations).toContain(
|
|
156
|
+
AddSessionReplaySameOriginTracePropagation1794800000000,
|
|
157
|
+
);
|
|
158
|
+
expect(
|
|
159
|
+
SchemaMigrations.filter((migration: unknown): boolean => {
|
|
160
|
+
return (
|
|
161
|
+
migration === AddSessionReplaySameOriginTracePropagation1794800000000
|
|
162
|
+
);
|
|
163
|
+
}),
|
|
164
|
+
).toHaveLength(1);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
/*
|
|
168
|
+
* TypeORM records applied migrations by `name`. A mismatch re-runs the
|
|
169
|
+
* migration on every boot, and an ADD COLUMN without IF NOT EXISTS fails
|
|
170
|
+
* the boot the second time.
|
|
171
|
+
*/
|
|
172
|
+
test("its declared name, its class name and its timestamp agree", () => {
|
|
173
|
+
expect(
|
|
174
|
+
new AddSessionReplaySameOriginTracePropagation1794800000000().name,
|
|
175
|
+
).toBe(MIGRATION_CLASS_NAME);
|
|
176
|
+
expect(AddSessionReplaySameOriginTracePropagation1794800000000.name).toBe(
|
|
177
|
+
MIGRATION_CLASS_NAME,
|
|
178
|
+
);
|
|
179
|
+
expect(
|
|
180
|
+
AddSessionReplaySameOriginTracePropagation1794800000000.name.match(
|
|
181
|
+
CLASS_TIMESTAMP,
|
|
182
|
+
)?.[1],
|
|
183
|
+
).toBe(MIGRATION_TIMESTAMP);
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
test("exactly one file on disk carries its timestamp, and it is this one", () => {
|
|
187
|
+
const matching: Array<string> = fs
|
|
188
|
+
.readdirSync(MIGRATION_DIRECTORY)
|
|
189
|
+
.filter((file: string): boolean => {
|
|
190
|
+
return file.startsWith(`${MIGRATION_TIMESTAMP}-`);
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
expect(matching).toEqual([MIGRATION_FILE_NAME]);
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
test("its timestamp sorts after every migration registered before it", () => {
|
|
197
|
+
const position: number = SchemaMigrations.indexOf(
|
|
198
|
+
AddSessionReplaySameOriginTracePropagation1794800000000,
|
|
199
|
+
);
|
|
200
|
+
|
|
201
|
+
expect(position).toBeGreaterThan(-1);
|
|
202
|
+
|
|
203
|
+
const earlierTimestamps: Array<number> = [];
|
|
204
|
+
|
|
205
|
+
for (const migrationClass of SchemaMigrations.slice(0, position)) {
|
|
206
|
+
const match: RegExpMatchArray | null = (
|
|
207
|
+
migrationClass as { name: string }
|
|
208
|
+
).name.match(CLASS_TIMESTAMP);
|
|
209
|
+
|
|
210
|
+
if (match) {
|
|
211
|
+
earlierTimestamps.push(Number(match[1]));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Math.max() of an empty list is -Infinity; prove the list was read.
|
|
216
|
+
expect(earlierTimestamps.length).toBeGreaterThan(100);
|
|
217
|
+
|
|
218
|
+
expect(Number(MIGRATION_TIMESTAMP)).toBeGreaterThan(
|
|
219
|
+
Math.max(...earlierTimestamps),
|
|
220
|
+
);
|
|
221
|
+
});
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
/*
|
|
225
|
+
* The model side of the same contract. TypeORM generates the schema from
|
|
226
|
+
* these decorators, so a model column whose type, nullability or default
|
|
227
|
+
* disagrees with the migration is exactly the drift the Postgres Schema
|
|
228
|
+
* Drift workflow fails on.
|
|
229
|
+
*/
|
|
230
|
+
describe("the RumApplication model carries the column the migration adds", () => {
|
|
231
|
+
test("a non-nullable boolean defaulting to true", () => {
|
|
232
|
+
const args: ColumnMetadataArgs | undefined = getMetadataArgsStorage()
|
|
233
|
+
.columns.filter((candidate: ColumnMetadataArgs): boolean => {
|
|
234
|
+
return candidate.target === RumApplication;
|
|
235
|
+
})
|
|
236
|
+
.find((candidate: ColumnMetadataArgs): boolean => {
|
|
237
|
+
return (
|
|
238
|
+
candidate.propertyName === "sessionReplaySameOriginTracePropagation"
|
|
239
|
+
);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
expect(args).toBeDefined();
|
|
243
|
+
expect(args?.options.type).toBe("boolean");
|
|
244
|
+
expect(args?.options.nullable).toBe(false);
|
|
245
|
+
expect(args?.options.default).toBe(true);
|
|
246
|
+
});
|
|
247
|
+
});
|