mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-10-13 23:38:45 +01:00
Update SettingsComponent tests and snapshots
This commit is contained in:
parent
c2b3330e4f
commit
77668896d4
@ -1,5 +1,8 @@
|
|||||||
|
import { IndexingPolicy } from "@azure/cosmos";
|
||||||
|
import { act } from "@testing-library/react";
|
||||||
import { AuthType } from "AuthType";
|
import { AuthType } from "AuthType";
|
||||||
import { shallow } from "enzyme";
|
import { shallow } from "enzyme";
|
||||||
|
import { useIndexingPolicyStore } from "Explorer/Tabs/QueryTab/ResultsView";
|
||||||
import ko from "knockout";
|
import ko from "knockout";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { updateCollection } from "../../../Common/dataAccess/updateCollection";
|
import { updateCollection } from "../../../Common/dataAccess/updateCollection";
|
||||||
@ -287,3 +290,48 @@ describe("SettingsComponent", () => {
|
|||||||
expect(wrapper.state("isThroughputBucketsSaveable")).toBe(false);
|
expect(wrapper.state("isThroughputBucketsSaveable")).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe("SettingsComponent - indexing policy subscription", () => {
|
||||||
|
const baseProps: SettingsComponentProps = {
|
||||||
|
settingsTab: new CollectionSettingsTabV2({
|
||||||
|
collection: collection,
|
||||||
|
tabKind: ViewModels.CollectionTabKind.CollectionSettingsV2,
|
||||||
|
title: "Scale & Settings",
|
||||||
|
tabPath: "",
|
||||||
|
node: undefined,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
it("subscribes to the correct container's indexing policy and updates state on change", async () => {
|
||||||
|
const containerId = collection.id();
|
||||||
|
const mockIndexingPolicy: IndexingPolicy = {
|
||||||
|
automatic: false,
|
||||||
|
indexingMode: "lazy",
|
||||||
|
includedPaths: [{ path: "/foo/*" }],
|
||||||
|
excludedPaths: [{ path: "/bar/*" }],
|
||||||
|
compositeIndexes: [],
|
||||||
|
spatialIndexes: [],
|
||||||
|
vectorIndexes: [],
|
||||||
|
fullTextIndexes: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const wrapper = shallow(<SettingsComponent {...baseProps} />);
|
||||||
|
const instance = wrapper.instance() as SettingsComponent;
|
||||||
|
|
||||||
|
await act(async () => {
|
||||||
|
useIndexingPolicyStore.setState({
|
||||||
|
indexingPolicies: {
|
||||||
|
[containerId]: mockIndexingPolicy,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
wrapper.update();
|
||||||
|
|
||||||
|
expect(wrapper.state("indexingPolicyContent")).toEqual(mockIndexingPolicy);
|
||||||
|
expect(wrapper.state("indexingPolicyContentBaseline")).toEqual(mockIndexingPolicy);
|
||||||
|
// Optionally, check the collection's rawDataModel (ignore TS error in test)
|
||||||
|
// @ts-expect-error
|
||||||
|
expect(instance.collection.rawDataModel.indexingPolicy).toEqual(mockIndexingPolicy);
|
||||||
|
});
|
||||||
|
});
|
@ -72,6 +72,16 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKey",
|
"partitionKey",
|
||||||
],
|
],
|
||||||
"rawDataModel": {
|
"rawDataModel": {
|
||||||
|
"indexingPolicy": {
|
||||||
|
"automatic": true,
|
||||||
|
"compositeIndexes": [],
|
||||||
|
"excludedPaths": [],
|
||||||
|
"fullTextIndexes": [],
|
||||||
|
"includedPaths": [],
|
||||||
|
"indexingMode": "consistent",
|
||||||
|
"spatialIndexes": [],
|
||||||
|
"vectorIndexes": [],
|
||||||
|
},
|
||||||
"uniqueKeyPolicy": {
|
"uniqueKeyPolicy": {
|
||||||
"uniqueKeys": [
|
"uniqueKeys": [
|
||||||
{
|
{
|
||||||
@ -164,6 +174,16 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKey",
|
"partitionKey",
|
||||||
],
|
],
|
||||||
"rawDataModel": {
|
"rawDataModel": {
|
||||||
|
"indexingPolicy": {
|
||||||
|
"automatic": true,
|
||||||
|
"compositeIndexes": [],
|
||||||
|
"excludedPaths": [],
|
||||||
|
"fullTextIndexes": [],
|
||||||
|
"includedPaths": [],
|
||||||
|
"indexingMode": "consistent",
|
||||||
|
"spatialIndexes": [],
|
||||||
|
"vectorIndexes": [],
|
||||||
|
},
|
||||||
"uniqueKeyPolicy": {
|
"uniqueKeyPolicy": {
|
||||||
"uniqueKeys": [
|
"uniqueKeys": [
|
||||||
{
|
{
|
||||||
@ -238,17 +258,25 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
indexingPolicyContent={
|
indexingPolicyContent={
|
||||||
{
|
{
|
||||||
"automatic": true,
|
"automatic": true,
|
||||||
|
"compositeIndexes": [],
|
||||||
"excludedPaths": [],
|
"excludedPaths": [],
|
||||||
|
"fullTextIndexes": [],
|
||||||
"includedPaths": [],
|
"includedPaths": [],
|
||||||
"indexingMode": "consistent",
|
"indexingMode": "consistent",
|
||||||
|
"spatialIndexes": [],
|
||||||
|
"vectorIndexes": [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
indexingPolicyContentBaseline={
|
indexingPolicyContentBaseline={
|
||||||
{
|
{
|
||||||
"automatic": true,
|
"automatic": true,
|
||||||
|
"compositeIndexes": [],
|
||||||
"excludedPaths": [],
|
"excludedPaths": [],
|
||||||
|
"fullTextIndexes": [],
|
||||||
"includedPaths": [],
|
"includedPaths": [],
|
||||||
"indexingMode": "consistent",
|
"indexingMode": "consistent",
|
||||||
|
"spatialIndexes": [],
|
||||||
|
"vectorIndexes": [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isVectorSearchEnabled={false}
|
isVectorSearchEnabled={false}
|
||||||
@ -321,6 +349,16 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKey",
|
"partitionKey",
|
||||||
],
|
],
|
||||||
"rawDataModel": {
|
"rawDataModel": {
|
||||||
|
"indexingPolicy": {
|
||||||
|
"automatic": true,
|
||||||
|
"compositeIndexes": [],
|
||||||
|
"excludedPaths": [],
|
||||||
|
"fullTextIndexes": [],
|
||||||
|
"includedPaths": [],
|
||||||
|
"indexingMode": "consistent",
|
||||||
|
"spatialIndexes": [],
|
||||||
|
"vectorIndexes": [],
|
||||||
|
},
|
||||||
"uniqueKeyPolicy": {
|
"uniqueKeyPolicy": {
|
||||||
"uniqueKeys": [
|
"uniqueKeys": [
|
||||||
{
|
{
|
||||||
@ -461,6 +499,16 @@ exports[`SettingsComponent renders 1`] = `
|
|||||||
"partitionKey",
|
"partitionKey",
|
||||||
],
|
],
|
||||||
"rawDataModel": {
|
"rawDataModel": {
|
||||||
|
"indexingPolicy": {
|
||||||
|
"automatic": true,
|
||||||
|
"compositeIndexes": [],
|
||||||
|
"excludedPaths": [],
|
||||||
|
"fullTextIndexes": [],
|
||||||
|
"includedPaths": [],
|
||||||
|
"indexingMode": "consistent",
|
||||||
|
"spatialIndexes": [],
|
||||||
|
"vectorIndexes": [],
|
||||||
|
},
|
||||||
"uniqueKeyPolicy": {
|
"uniqueKeyPolicy": {
|
||||||
"uniqueKeys": [
|
"uniqueKeys": [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user