Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontends/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
},
"dependencies": {
"@mitodl/mit-learn-api-axios": "2026.7.22",
"@mitodl/mitxonline-api-axios": "2026.7.22",
"@mitodl/mitxonline-api-axios": "2026.8.6",
"@tanstack/react-query": "^5.66.0",
"axios": "^1.12.2",
"tiny-invariant": "^1.3.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ const contractCode = (
redeemed_by: isRedeemed ? faker.internet.email() : null,
redeemed_on: isRedeemed ? faker.date.past().toISOString() : null,
last_sent: null,
email_status: null,
email_status_event_timestamp: null,
...overrides,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const organization = (
description: faker.lorem.paragraph(),
logo: faker.image.url(),
slug: faker.lorem.slug(),
sso_organization_id: faker.string.uuid(),
contracts: [],
},
overrides,
Expand All @@ -24,6 +25,7 @@ const organization = (
description: merged.description!,
logo: merged.logo!,
slug: merged.slug!,
sso_organization_id: merged.sso_organization_id ?? null,
contracts: merged.contracts!,
}
}
Expand Down
2 changes: 1 addition & 1 deletion frontends/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@mitodl/arithmix": "^0.2.2",
"@mitodl/course-search-utils": "^3.5.2",
"@mitodl/hacksnack": "^0.1.0",
"@mitodl/mitxonline-api-axios": "2026.7.22",
"@mitodl/mitxonline-api-axios": "2026.8.6",
"@mitodl/smoot-design": "6.31.1",
"@mui/base": "5.0.0-beta.70",
"@mui/material": "^6.4.5",
Expand Down
28 changes: 0 additions & 28 deletions frontends/main/src/app-pages/DashboardPage/Analytics/orgUuid.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,15 @@ const managerOrgsUrl = urls.organization.managerOrganizationsList()

const ORG_UUID = "3fa85f64-5717-4562-b3fc-2c963f66afa6"

/**
* `sso_organization_id` is not on the generated `OrganizationPage` type yet
* (mitodl/mitxonline#3789 has not been released into the client), so it is
* spliced on here the same way it arrives on the wire.
*/
const orgWithUuid = (
overrides: Partial<OrganizationPage> = {},
ssoOrganizationId: string | null = ORG_UUID,
) => {
const org = factories.organizations.organization({
) =>
factories.organizations.organization({
contracts: [factories.contracts.contract()],
sso_organization_id: ssoOrganizationId,
...overrides,
})
return ssoOrganizationId
? { ...org, sso_organization_id: ssoOrganizationId }
: org
}

const setManagerOrgs = (orgs: unknown[]) => {
setMockResponse.get(managerOrgsUrl, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import EngagementTrendChart from "./Analytics/EngagementTrendChart"
import ProgramFunnelChart from "./Analytics/ProgramFunnelChart"
import SectionHeader from "./Analytics/SectionHeader"
import SectionTruncation from "./Analytics/SectionTruncation"
import { getOrgUuid } from "./Analytics/orgUuid"

/**
* Org-scoped B2B analytics, the reporting half of the org-manager dashboard
Expand Down Expand Up @@ -154,7 +153,12 @@ const AnalyticsContentInternal: React.FC<AnalyticsContentInternalProps> = ({
} = useQuery(managerOrganizationQueries.managerOrganizationsList())

const org = managerOrgs?.find(matchOrganizationBySlug(orgSlug))
const orgUuid = getOrgUuid(org)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, this did

  const value = (org as { sso_organization_id?: unknown } | undefined)
    ?.sso_organization_id
  return typeof value === "string" && value.length > 0 ? value : null

I.e., it was a type-safe way of getting sso_organization_id before it was included in the API client.

(I guess it also omitted empty string "" uuids. The new version, direct access, does not do that. But if the uuid is empty, then we have bigger problems... we should trust the API)

// The Keycloak organization UUID, which is what the analytics API keys every
// org endpoint on (see mitodl/ol-analytics-api#13). It is null on orgs whose
// MITx Online record predates the field, and absent altogether against a
// deploy that predates mitodl/mitxonline#3789 — both must read as "analytics
// unavailable" rather than a request with `undefined` in the path.
const orgUuid = org?.sso_organization_id ?? null
const analyticsAvailable = isAnalyticsConfigured() && !!orgUuid

// Per-section page size. Raised only by that section's "Show all", so
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@ describe("OrganizationCards", () => {
count: number,
withContracts: boolean = true,
): OrganizationPage[] => {
return Array.from({ length: count }, (_, i) => ({
id: i + 1,
name: `Test Organization ${i + 1}`,
description: `Description for org ${i + 1}`,
logo: `https://example.com/logo${i + 1}.png`,
slug: `org-test-${i + 1}`,
contracts: withContracts
? [
mitxOnlineFactories.contracts.contract({
id: i + 1,
name: `Contract ${i + 1}`,
organization: i + 1,
}),
]
: [],
}))
return Array.from({ length: count }, (_, i) =>
mitxOnlineFactories.organizations.organization({
id: i + 1,
name: `Test Organization ${i + 1}`,
description: `Description for org ${i + 1}`,
logo: `https://example.com/logo${i + 1}.png`,
slug: `org-test-${i + 1}`,
contracts: withContracts
? [
mitxOnlineFactories.contracts.contract({
id: i + 1,
name: `Contract ${i + 1}`,
organization: i + 1,
}),
]
: [],
}),
)
}

const setup = ({ organizations = [] }: SetupOptions = {}) => {
Expand Down Expand Up @@ -81,7 +83,7 @@ describe("OrganizationCards", () => {
})

it("displays organization logo", async () => {
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test Description",
Expand All @@ -94,7 +96,7 @@ describe("OrganizationCards", () => {
name: "Contract 1",
}),
],
}
})
setup({ organizations: [organization] })

const image = await screen.findByAltText("")
Expand All @@ -108,7 +110,7 @@ describe("OrganizationCards", () => {

describe("when organization has contracts", () => {
it("renders contract cards with correct information", async () => {
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test description",
Expand All @@ -126,7 +128,7 @@ describe("OrganizationCards", () => {
organization: 1,
}),
],
}
})

setup({ organizations: [organization] })

Expand Down Expand Up @@ -160,14 +162,14 @@ describe("OrganizationCards", () => {
organization: 1,
slug: "contract-2",
})
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test description",
logo: "https://example.com/logo.png",
slug: "org-test-org",
contracts: [contract1, contract2],
}
})

setup({ organizations: [organization] })

Expand All @@ -192,7 +194,7 @@ describe("OrganizationCards", () => {
})

it("renders cards for both mobile and desktop screen sizes", async () => {
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test description",
Expand All @@ -205,7 +207,7 @@ describe("OrganizationCards", () => {
organization: 1,
}),
],
}
})

setup({ organizations: [organization] })

Expand All @@ -217,14 +219,14 @@ describe("OrganizationCards", () => {

describe("when organization has no matching contracts", () => {
it("renders organization header but no contract cards", async () => {
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test description",
logo: "https://example.com/logo.png",
slug: "org-test-org",
contracts: [], // No contracts for this organization
}
})

setup({ organizations: [organization] })

Expand All @@ -245,7 +247,7 @@ describe("OrganizationCards", () => {

describe("with multiple organizations", () => {
it("renders all organizations with their respective contracts", async () => {
const org1: OrganizationPage = {
const org1 = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Organization One",
description: "Test description",
Expand All @@ -265,8 +267,8 @@ describe("OrganizationCards", () => {
slug: "org1-contract-2",
}),
],
}
const org2: OrganizationPage = {
})
const org2 = mitxOnlineFactories.organizations.organization({
id: 2,
name: "Organization Two",
description: "Test description",
Expand All @@ -280,7 +282,7 @@ describe("OrganizationCards", () => {
slug: "org2-contract-1",
}),
],
}
})

setup({ organizations: [org1, org2] })

Expand Down Expand Up @@ -368,14 +370,14 @@ describe("OrganizationCards", () => {
organization: 1,
slug: "test-contract",
})
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test description",
logo: "https://example.com/logo.png",
slug: "org-my-company",
contracts: [contract],
}
})

setup({ organizations: [organization] })

Expand All @@ -395,14 +397,14 @@ describe("OrganizationCards", () => {
organization: 1,
slug: "test-contract",
})
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test description",
logo: "https://example.com/logo.png",
slug: "my-company", // No 'org-' prefix
contracts: [contract],
}
})

setup({ organizations: [organization] })

Expand All @@ -416,14 +418,14 @@ describe("OrganizationCards", () => {
})

it("filters contracts correctly when none match organization ID", async () => {
const organization: OrganizationPage = {
const organization = mitxOnlineFactories.organizations.organization({
id: 1,
name: "Test Organization",
description: "Test description",
logo: "https://example.com/logo.png",
slug: "org-test-org",
contracts: [], // No contracts for this organization
}
})

setup({ organizations: [organization] })

Expand Down
12 changes: 6 additions & 6 deletions yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading