Copilot instructions and build/test skills (#2444)

* Add copilot instructions and skills for build and tests.

* Add dev-server skill.

* Auth Util changes to fix Entra login while running from copilot.

* Fix lint issue.
This commit is contained in:
jawelton74
2026-04-06 15:51:54 -07:00
committed by GitHub
parent cd4766b490
commit b483118b99
7 changed files with 546 additions and 1 deletions

View File

@@ -1,8 +1,14 @@
import { AuthType } from "../AuthType";
import * as Constants from "../Common/Constants";
import { resetConfigContext, updateConfigContext } from "../ConfigContext";
import { ApiType, updateUserContext, userContext } from "../UserContext";
import * as AuthorizationUtils from "./AuthorizationUtils";
jest.mock("../Explorer/Explorer");
jest.mock("@azure/msal-browser", () => ({
PublicClientApplication: jest.fn().mockImplementation((config) => ({
_config: config,
})),
}));
describe("AuthorizationUtils", () => {
const setAadDataPlane = (enabled: boolean) => {
@@ -134,4 +140,43 @@ describe("AuthorizationUtils", () => {
expect(AuthorizationUtils.useDataplaneRbacAuthorization(userContext)).toBe(false);
});
});
describe("getMsalInstance()", () => {
const originalHostname = window.location.hostname;
afterEach(() => {
resetConfigContext();
Object.defineProperty(window, "location", {
value: { ...window.location, hostname: originalHostname },
writable: true,
});
});
it("should use configContext.msalRedirectURI when set", async () => {
updateConfigContext({ msalRedirectURI: "https://dataexplorer-preview.azurewebsites.net/" });
const instance = await AuthorizationUtils.getMsalInstance();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((instance as any)._config.auth.redirectUri).toBe("https://dataexplorer-preview.azurewebsites.net/");
});
it("should use dev redirect URI on localhost", async () => {
Object.defineProperty(window, "location", {
value: { ...window.location, hostname: "localhost" },
writable: true,
});
const instance = await AuthorizationUtils.getMsalInstance();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((instance as any)._config.auth.redirectUri).toBe("https://dataexplorer-dev.azurewebsites.net");
});
it("should not set redirect URI in non-localhost production", async () => {
Object.defineProperty(window, "location", {
value: { ...window.location, hostname: "cosmos.azure.com" },
writable: true,
});
const instance = await AuthorizationUtils.getMsalInstance();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
expect((instance as any)._config.auth.redirectUri).toBeUndefined();
});
});
});

View File

@@ -61,7 +61,9 @@ export async function getMsalInstance() {
},
};
if (process.env.NODE_ENV === "development") {
if (configContext.msalRedirectURI) {
msalConfig.auth.redirectUri = configContext.msalRedirectURI;
} else if (process.env.NODE_ENV === "development" || window.location.hostname === "localhost") {
msalConfig.auth.redirectUri = "https://dataexplorer-dev.azurewebsites.net";
}