From 754354dbf9ae3e5dba992e0676e663c512b84265 Mon Sep 17 00:00:00 2001 From: vchske Date: Tue, 19 Sep 2023 17:12:41 -0700 Subject: [PATCH] Adds unit tests for vcore quickstart feature code (#1618) * Safety checkin * Adding vcoremongo to Main * Safety checkin * Adding vcoremongo to Main * Safety commit * Safety checkin * Adding vcoremongo to Main * Safety commit * Integrating mongo shell * Safety checkin * Adding vcoremongo to Main * Safety commit * Integrating mongo shell * Safety checkin * Safety commit * Enable mongo shell in its own tab * Safety checkin * Adding vcoremongo to Main * Safety commit * Integrating mongo shell * Safety checkin * Safety commit * Safety commit * Integrating mongo shell * Safety checkin * Safety commit * Enable mongo shell in its own tab * Adding message * Integrated mongo shell * Moving Juno endpoint back to prod * Fixed command bar unit tests * Fixing spelling * Adds unit tests for vcore quickstart feature code * Fix lint --- .../NotebookTerminalComponent.test.tsx | 49 ++++++++ .../NotebookTerminalComponent.test.tsx.snap | 24 ++++ .../CommandBarComponentButtonFactory.test.ts | 25 +++++ .../Tabs/Shared/CheckFirewallRules.test.ts | 91 +++++++++++++++ src/Utils/EndpointValidation.ts | 11 ++ src/Utils/JestUtils.ts | 4 + src/Utils/NetworkUtility.test.ts | 106 ++++++++++++++++++ src/Utils/NetworkUtility.ts | 19 ++-- src/userContext.test.ts | 18 +++ 9 files changed, 335 insertions(+), 12 deletions(-) create mode 100644 src/Explorer/Tabs/Shared/CheckFirewallRules.test.ts create mode 100644 src/Utils/JestUtils.ts create mode 100644 src/Utils/NetworkUtility.test.ts diff --git a/src/Explorer/Controls/Notebook/NotebookTerminalComponent.test.tsx b/src/Explorer/Controls/Notebook/NotebookTerminalComponent.test.tsx index fdc93adea..bd816ac31 100644 --- a/src/Explorer/Controls/Notebook/NotebookTerminalComponent.test.tsx +++ b/src/Explorer/Controls/Notebook/NotebookTerminalComponent.test.tsx @@ -32,6 +32,20 @@ const testCassandraAccount: DataModels.DatabaseAccount = { }, }; +const testPostgresAccount: DataModels.DatabaseAccount = { + ...testAccount, + properties: { + postgresqlEndpoint: "https://testPostgresEndpoint.azure.com/", + }, +}; + +const testVCoreMongoAccount: DataModels.DatabaseAccount = { + ...testAccount, + properties: { + vcoreMongoEndpoint: "https://testVCoreMongoEndpoint.azure.com/", + }, +}; + const testNotebookServerInfo: DataModels.NotebookWorkspaceConnectionInfo = { authToken: "authToken", notebookServerEndpoint: "https://testNotebookServerEndpoint.azure.com", @@ -50,6 +64,18 @@ const testCassandraNotebookServerInfo: DataModels.NotebookWorkspaceConnectionInf forwardingId: "Id", }; +const testPostgresNotebookServerInfo: DataModels.NotebookWorkspaceConnectionInfo = { + authToken: "authToken", + notebookServerEndpoint: "https://testNotebookServerEndpoint.azure.com/postgresql", + forwardingId: "Id", +}; + +const testVCoreMongoNotebookServerInfo: DataModels.NotebookWorkspaceConnectionInfo = { + authToken: "authToken", + notebookServerEndpoint: "https://testNotebookServerEndpoint.azure.com/mongovcore", + forwardingId: "Id", +}; + describe("NotebookTerminalComponent", () => { it("renders terminal", () => { const props: NotebookTerminalComponentProps = { @@ -94,4 +120,27 @@ describe("NotebookTerminalComponent", () => { const wrapper = shallow(); expect(wrapper).toMatchSnapshot(); }); + + it("renders Postgres shell", () => { + const props: NotebookTerminalComponentProps = { + databaseAccount: testPostgresAccount, + notebookServerInfo: testPostgresNotebookServerInfo, + tabId: undefined, + }; + + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + }); + + it("renders vCore Mongo shell", () => { + const props: NotebookTerminalComponentProps = { + databaseAccount: testVCoreMongoAccount, + notebookServerInfo: testVCoreMongoNotebookServerInfo, + tabId: undefined, + username: "username", + }; + + const wrapper = shallow(); + expect(wrapper).toMatchSnapshot(); + }); }); diff --git a/src/Explorer/Controls/Notebook/__snapshots__/NotebookTerminalComponent.test.tsx.snap b/src/Explorer/Controls/Notebook/__snapshots__/NotebookTerminalComponent.test.tsx.snap index a87a1c96d..440579141 100644 --- a/src/Explorer/Controls/Notebook/__snapshots__/NotebookTerminalComponent.test.tsx.snap +++ b/src/Explorer/Controls/Notebook/__snapshots__/NotebookTerminalComponent.test.tsx.snap @@ -1,5 +1,17 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`NotebookTerminalComponent renders Postgres shell 1`] = ` +
+