mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-30 06:11:38 +00:00
* added SettingsV2 Tab * lint changes * foxed failing test * Addressed PR comments - removed dangerouslySetInnerHtml - removed underscore dependency - added AccessibleElement - removed unnecesary exceptions to linting * split render into separate functions - removed sinon in test - Added some enums to replace constant strings - removed dangerously set inner html - made autopilot input as StatefulValue * add settingscomponent snapshot * fixed linting errors * fixed errors * addressed PR comments - Moved StatefulValue to new class - Split render to more functions for throughputInputComponents * Added sub components - Added tests for SettingsRenderUtls - Added empty test files for adding tests later * Moved all inputs to fluent UI - removed rupm - added reusable styles * Added Tabs - Added ToolTipLabel component - Removed toggleables for individual components - Removed accessible elements - Added IndexingPolicyComponent * Added more tests * Addressed PR comments * Moved Label radio buttons to choicegroup * fixed lint errors * Removed StatefulValue - Moved conflict res tab to the end - Added styling for autpilot radiobuttons * fixed linting errors * fix bugs from merge to master * fixed formatting issue * Addressed PR comments - Added unit tests for smaller methods within each component * fixed linting errors * removed redundant snapshots * removed empty line * made separate props objects for subcomponents * Moved dirty checks to sub components * Made indesing policy component height = 80% of view port - modified auto pilot v3 messages - Added Fluent UI tolltip - * Moved warning messages inline * moved conflict res helpers out * fixed bugs * added stack style for message * fixed tests * Added tests * fixed linting and format errors * undid changes * more edits * fixed compile errors * fixed compile errors * fixed errors * fixed bug with save and discard buttons * fixed compile errors * addressed PR comments
90 lines
3.0 KiB
TypeScript
90 lines
3.0 KiB
TypeScript
import { collection, container } from "./TestUtils";
|
|
import {
|
|
getMaxRUs,
|
|
getMinRUs,
|
|
hasDatabaseSharedThroughput,
|
|
isDirty,
|
|
isDirtyTypes,
|
|
parseConflictResolutionMode,
|
|
parseConflictResolutionProcedure
|
|
} from "./SettingsUtils";
|
|
import * as DataModels from "../../../Contracts/DataModels";
|
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
|
import ko from "knockout";
|
|
|
|
describe("SettingsUtils", () => {
|
|
it("getMaxRUs", () => {
|
|
expect(collection.offer().content.collectionThroughputInfo.numPhysicalPartitions).toEqual(4);
|
|
expect(getMaxRUs(collection, container)).toEqual(40000);
|
|
});
|
|
|
|
it("getMinRUs", () => {
|
|
expect(collection.offer().content.collectionThroughputInfo.numPhysicalPartitions).toEqual(4);
|
|
expect(getMinRUs(collection, container)).toEqual(6000);
|
|
});
|
|
|
|
it("hasDatabaseSharedThroughput", () => {
|
|
expect(hasDatabaseSharedThroughput(collection)).toEqual(undefined);
|
|
|
|
const newCollection = { ...collection };
|
|
newCollection.getDatabase = () => {
|
|
return {
|
|
nodeKind: undefined,
|
|
rid: undefined,
|
|
container: undefined,
|
|
self: "",
|
|
id: ko.observable(""),
|
|
collections: ko.observableArray(undefined),
|
|
offer: ko.observable(undefined),
|
|
isDatabaseExpanded: ko.observable(false),
|
|
isDatabaseShared: ko.computed(() => true),
|
|
selectedSubnodeKind: ko.observable(undefined),
|
|
selectDatabase: undefined,
|
|
expandDatabase: undefined,
|
|
collapseDatabase: undefined,
|
|
loadCollections: undefined,
|
|
findCollectionWithId: undefined,
|
|
openAddCollection: undefined,
|
|
onDeleteDatabaseContextMenuClick: undefined,
|
|
readSettings: undefined,
|
|
onSettingsClick: undefined,
|
|
loadOffer: undefined
|
|
} as ViewModels.Database;
|
|
};
|
|
newCollection.offer(undefined);
|
|
expect(hasDatabaseSharedThroughput(newCollection)).toEqual(true);
|
|
});
|
|
|
|
it("parseConflictResolutionMode", () => {
|
|
expect(parseConflictResolutionMode("custom")).toEqual(DataModels.ConflictResolutionMode.Custom);
|
|
expect(parseConflictResolutionMode("lastwriterwins")).toEqual(DataModels.ConflictResolutionMode.LastWriterWins);
|
|
});
|
|
|
|
it("parseConflictResolutionProcedure", () => {
|
|
expect(parseConflictResolutionProcedure("/dbs/db/colls/coll/sprocs/conflictResSproc")).toEqual("conflictResSproc");
|
|
expect(parseConflictResolutionProcedure("conflictResSproc")).toEqual("conflictResSproc");
|
|
});
|
|
|
|
describe("isDirty", () => {
|
|
const indexingPolicy = {
|
|
automatic: true,
|
|
indexingMode: "consistent",
|
|
includedPaths: [],
|
|
excludedPaths: []
|
|
} as DataModels.IndexingPolicy;
|
|
|
|
const cases = [
|
|
["baseline", "current"],
|
|
[0, 1],
|
|
[true, false],
|
|
[undefined, indexingPolicy],
|
|
[indexingPolicy, { ...indexingPolicy, automatic: false }]
|
|
];
|
|
|
|
test.each(cases)("", (baseline: isDirtyTypes, current: isDirtyTypes) => {
|
|
expect(isDirty(baseline, baseline)).toEqual(false);
|
|
expect(isDirty(baseline, current)).toEqual(true);
|
|
});
|
|
});
|
|
});
|