mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-05-15 01:37:37 +01:00
Fixing unit tests
This commit is contained in:
+10
-5
@@ -9,7 +9,8 @@ exports[`DefaultManagedIdentity Edge Cases should handle missing account name gr
|
|||||||
class="toggle-label"
|
class="toggle-label"
|
||||||
>
|
>
|
||||||
Set the system-assigned managed identity as default for "" by switching it on.
|
Set the system-assigned managed identity as default for "" by switching it on.
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
data-testid="info-tooltip"
|
data-testid="info-tooltip"
|
||||||
>
|
>
|
||||||
@@ -72,7 +73,8 @@ exports[`DefaultManagedIdentity Edge Cases should handle null account 1`] = `
|
|||||||
class="toggle-label"
|
class="toggle-label"
|
||||||
>
|
>
|
||||||
Set the system-assigned managed identity as default for "" by switching it on.
|
Set the system-assigned managed identity as default for "" by switching it on.
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
data-testid="info-tooltip"
|
data-testid="info-tooltip"
|
||||||
>
|
>
|
||||||
@@ -135,7 +137,8 @@ exports[`DefaultManagedIdentity Loading States should render loading state snaps
|
|||||||
class="toggle-label"
|
class="toggle-label"
|
||||||
>
|
>
|
||||||
Set the system-assigned managed identity as default for "test-cosmos-account" by switching it on.
|
Set the system-assigned managed identity as default for "test-cosmos-account" by switching it on.
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
data-testid="info-tooltip"
|
data-testid="info-tooltip"
|
||||||
>
|
>
|
||||||
@@ -227,7 +230,8 @@ exports[`DefaultManagedIdentity Rendering should render correctly with default s
|
|||||||
class="toggle-label"
|
class="toggle-label"
|
||||||
>
|
>
|
||||||
Set the system-assigned managed identity as default for "test-cosmos-account" by switching it on.
|
Set the system-assigned managed identity as default for "test-cosmos-account" by switching it on.
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
data-testid="info-tooltip"
|
data-testid="info-tooltip"
|
||||||
>
|
>
|
||||||
@@ -290,7 +294,8 @@ exports[`DefaultManagedIdentity Toggle Interactions should render toggle with ch
|
|||||||
class="toggle-label"
|
class="toggle-label"
|
||||||
>
|
>
|
||||||
Set the system-assigned managed identity as default for "test-cosmos-account" by switching it on.
|
Set the system-assigned managed identity as default for "test-cosmos-account" by switching it on.
|
||||||
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
data-testid="info-tooltip"
|
data-testid="info-tooltip"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { render, screen } from "@testing-library/react";
|
import { render, screen, waitFor } from "@testing-library/react";
|
||||||
import { DatabaseAccount } from "Contracts/DataModels";
|
import { DatabaseAccount } from "Contracts/DataModels";
|
||||||
import {
|
import {
|
||||||
PartitionKeyComponent,
|
PartitionKeyComponent,
|
||||||
PartitionKeyComponentProps,
|
PartitionKeyComponentProps,
|
||||||
} from "Explorer/Controls/Settings/SettingsSubComponents/PartitionKeyComponent";
|
} from "Explorer/Controls/Settings/SettingsSubComponents/PartitionKeyComponent";
|
||||||
import * as useDataTransferJobs from "hooks/useDataTransferJobs";
|
import { useDataTransferJobs } from "hooks/useDataTransferJobs";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { updateUserContext } from "UserContext";
|
import { updateUserContext } from "UserContext";
|
||||||
import { DataTransferJobGetResults } from "Utils/arm/generatedClients/dataTransferService/types";
|
import { DataTransferJobGetResults } from "Utils/arm/generatedClients/dataTransferService/types";
|
||||||
@@ -19,7 +19,7 @@ jest.mock("Common/dataAccess/dataTransfers", () => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
jest.mock("hooks/useDataTransferJobs", () => ({
|
jest.mock("hooks/useDataTransferJobs", () => ({
|
||||||
useDataTransferJobs: () => ({ dataTransferJobs: [] }),
|
useDataTransferJobs: jest.fn(() => ({ dataTransferJobs: [] })),
|
||||||
refreshDataTransferJobs: jest.fn().mockResolvedValue(undefined),
|
refreshDataTransferJobs: jest.fn().mockResolvedValue(undefined),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -117,7 +117,7 @@ describe("PartitionKeyComponent", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("shows cancel button for offline job in progress", () => {
|
it("shows cancel button for offline job in progress", () => {
|
||||||
jest.spyOn(useDataTransferJobs, "useDataTransferJobs").mockReturnValue({
|
(useDataTransferJobs as jest.Mock).mockReturnValue({
|
||||||
dataTransferJobs: [mockOfflineJob],
|
dataTransferJobs: [mockOfflineJob],
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -127,13 +127,15 @@ describe("PartitionKeyComponent", () => {
|
|||||||
expect(container.querySelector("[data-test='online-job-action-menu']")).toBeNull();
|
expect(container.querySelector("[data-test='online-job-action-menu']")).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("shows ellipsis action menu for online job in progress", () => {
|
it("shows ellipsis action menu for online job in progress", async () => {
|
||||||
jest.spyOn(useDataTransferJobs, "useDataTransferJobs").mockReturnValue({
|
(useDataTransferJobs as jest.Mock).mockReturnValue({
|
||||||
dataTransferJobs: [mockOnlineJob],
|
dataTransferJobs: [mockOnlineJob],
|
||||||
});
|
});
|
||||||
|
|
||||||
const { props } = setupTest();
|
const { props } = setupTest();
|
||||||
const { container } = render(<PartitionKeyComponent {...props} />);
|
const { container } = render(<PartitionKeyComponent {...props} />);
|
||||||
expect(container.querySelector("[data-test='online-job-action-menu']")).toBeTruthy();
|
await waitFor(() => {
|
||||||
|
expect(container.querySelector("[data-test='online-job-action-menu']")).toBeTruthy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import {
|
|||||||
DefaultButton,
|
DefaultButton,
|
||||||
DirectionalHint,
|
DirectionalHint,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
IChoiceGroupOption,
|
|
||||||
IDropdownOption,
|
IDropdownOption,
|
||||||
Icon,
|
Icon,
|
||||||
IconButton,
|
IconButton,
|
||||||
@@ -24,7 +23,7 @@ import { createCollection } from "Common/dataAccess/createCollection";
|
|||||||
import { DataTransferParams, initiateDataTransfer } from "Common/dataAccess/dataTransfers";
|
import { DataTransferParams, initiateDataTransfer } from "Common/dataAccess/dataTransfers";
|
||||||
import * as DataModels from "Contracts/DataModels";
|
import * as DataModels from "Contracts/DataModels";
|
||||||
import * as ViewModels from "Contracts/ViewModels";
|
import * as ViewModels from "Contracts/ViewModels";
|
||||||
import { BackupPolicyType, CopyJobMigrationType } from "Explorer/ContainerCopy/Enums/CopyJobEnums";
|
import { BackupPolicyType } from "Explorer/ContainerCopy/Enums/CopyJobEnums";
|
||||||
import {
|
import {
|
||||||
getPartitionKeyName,
|
getPartitionKeyName,
|
||||||
getPartitionKeyPlaceHolder,
|
getPartitionKeyPlaceHolder,
|
||||||
@@ -50,33 +49,6 @@ export interface ChangePartitionKeyPaneProps {
|
|||||||
onClose: () => Promise<void>;
|
onClose: () => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const migrationTypeOptions: IChoiceGroupOption[] = [
|
|
||||||
{
|
|
||||||
key: CopyJobMigrationType.Offline,
|
|
||||||
text: t(Keys.containerCopy.migrationType.offline.title),
|
|
||||||
styles: { root: { width: "33%" } },
|
|
||||||
},
|
|
||||||
{
|
|
||||||
key: CopyJobMigrationType.Online,
|
|
||||||
text: t(Keys.containerCopy.migrationType.online.title),
|
|
||||||
styles: { root: { width: "33%" } },
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const choiceGroupStyles = {
|
|
||||||
flexContainer: { display: "flex" as const },
|
|
||||||
root: {
|
|
||||||
selectors: {
|
|
||||||
".ms-ChoiceField": {
|
|
||||||
color: "var(--colorNeutralForeground1)",
|
|
||||||
},
|
|
||||||
".ms-ChoiceField-field:hover .ms-ChoiceFieldLabel": {
|
|
||||||
color: "var(--colorNeutralForeground1)",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
const checkPitrEnabled = (account: DataModels.DatabaseAccount): boolean => {
|
const checkPitrEnabled = (account: DataModels.DatabaseAccount): boolean => {
|
||||||
return account?.properties?.backupPolicy?.type === BackupPolicyType.Continuous;
|
return account?.properties?.backupPolicy?.type === BackupPolicyType.Continuous;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user