Skip to content
Closed
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- 6379:6379

steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

- name: update apt
run: sudo apt-get update -y
Expand Down Expand Up @@ -92,7 +92,7 @@ jobs:
javascript-tests:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "^22.0.0"
Expand Down Expand Up @@ -151,7 +151,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

- name: Build the Docker image
env:
Expand Down Expand Up @@ -199,7 +199,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
Expand All @@ -223,7 +223,7 @@ jobs:
GENERATOR_OUTPUT_DIR_VC: ./frontends/api/src/generated/v0
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "^22.0.0"
Expand Down Expand Up @@ -262,7 +262,7 @@ jobs:
GENERATOR_OUTPUT_DIR_VC: ./frontends/api/src/generated/v1
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: "^22.0.0"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/openapi-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout HEAD
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
ref: ${{ github.head_ref }}
path: head
- name: Checkout BASE
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
with:
ref: ${{ github.base_ref }}
path: base
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5

- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
Expand Down
13 changes: 13 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
Release Notes
=============

Version 0.45.3
--------------

- Canvas - skip TutorProblemFile OCR if content is the same (#2557)
- Refactor price assignment for mitxonline (#2550)
- Update MITxOnline API Client (#2554)
- chore(deps): update nginx docker tag to v1.29.1 (#2549)
- chore(deps): update actions/checkout action to v5 (#2551)
- Certificate page design adjustments (#2547)
- Canvas - resolve visibility of orphaned files (#2548)
- Certificate social media / URL sharing (#2524)
- fix(deps): update django-health-check digest to 592f6a8 (#2527)

Version 0.45.1 (Released September 29, 2025)
--------------

Expand Down
6 changes: 3 additions & 3 deletions frontends/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
"@testing-library/react": "^16.3.0",
"enforce-unique": "^1.3.0",
"jest": "^29.7.0",
"jest-when": "^3.6.0",
"jest-when": "^3.7.0",
"lodash": "^4.17.21",
"ol-test-utilities": "0.0.0"
},
"dependencies": {
"@mitodl/mitxonline-api-axios": "^2025.9.11",
"@mitodl/mitxonline-api-axios": "^2025.9.26",
"@tanstack/react-query": "^5.66.0",
"axios": "^1.6.3"
"axios": "^1.12.2"
}
}
4 changes: 2 additions & 2 deletions frontends/api/src/mitxonline/hooks/pages/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { pagesQueries, getPagesDetail } from "./queries"
import { pagesQueries } from "./queries"

export { pagesQueries, getPagesDetail }
export { pagesQueries }
33 changes: 6 additions & 27 deletions frontends/api/src/mitxonline/hooks/pages/queries.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { queryOptions } from "@tanstack/react-query"
import {
// pagesApi,
axiosInstance,
pagesApi,
} from "../../clients"
import { CoursePageList } from "@mitodl/mitxonline-api-axios/v2"
import { pagesApi } from "../../clients"

const pagesKeys = {
root: ["mitxonline", "pages"],
coursePageDetail: (readableId: string) => [
Expand All @@ -14,33 +10,16 @@ const pagesKeys = {
],
}

const getPagesDetail = async (readableId: string) => {
// TODO: When MITxOnline is published, API client will support readable_id param.
// The API supports it now, just not the client.
// return pagesApi
// .pagesfieldstypecmsCoursePageRetrieve({ readable_id: readableId })
// .then((res) => res.data)
const todo = (
..._params: Parameters<typeof pagesApi.pagesfieldstypecmsCoursePageRetrieve>
) => {}
// @ts-expect-error See above ... This error will trigger when client is updated.
todo({ readable_id: readableId })

const BASE_PATH =
process.env.NEXT_PUBLIC_MITX_ONLINE_BASE_URL?.replace(/\/+$/, "") ?? ""

const url = `${BASE_PATH}/api/v2/pages/?fields=*&readable_id=${encodeURIComponent(readableId)}&type=cms.CoursePage`
return axiosInstance.get<CoursePageList>(url)
}

const pagesQueries = {
courseDetail: (readableId: string) =>
queryOptions({
queryKey: pagesKeys.coursePageDetail(readableId),
queryFn: async () => {
return getPagesDetail(readableId).then((res) => res.data)
return pagesApi
.pagesfieldstypecmsCoursePageRetrieve({ readable_id: readableId })
.then((res) => res.data)
},
}),
}

export { pagesQueries, pagesKeys, getPagesDetail }
export { pagesQueries, pagesKeys }
9 changes: 9 additions & 0 deletions frontends/api/src/mitxonline/test-utils/factories/programs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ const program: PartialFactory<V2Program> = (overrides = {}) => {
min_weekly_hours: `${faker.number.int({ min: 1, max: 5 })} hours`,
max_weekly_hours: `${faker.number.int({ min: 6, max: 10 })} hours`,
start_date: faker.date.past().toISOString(),
max_price: faker.number.int({ min: 50, max: 5000 }),
min_price: faker.number.int({ min: 50, max: 5000 }),
enrollment_start: faker.helpers.maybe(() =>
faker.date.past().toISOString(),
),
enrollment_end: faker.helpers.maybe(() =>
faker.date.future().toISOString(),
),
end_date: faker.helpers.maybe(() => faker.date.future().toISOString()),
}

return mergeOverrides<V2Program>(defaults, overrides)
Expand Down
4 changes: 2 additions & 2 deletions frontends/api/src/mitxonline/test-utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ const courses = {

const pages = {
courseDetail: (readableId: string) =>
`${API_BASE_URL}/api/v2/pages/?fields=*&readable_id=${encodeURIComponent(
`${API_BASE_URL}/api/v2/pages/?fields=*&type=cms.CoursePage&readable_id=${encodeURIComponent(
readableId,
)}&type=cms.CoursePage`,
)}`,
}

const organization = {
Expand Down
54 changes: 34 additions & 20 deletions frontends/api/src/test-utils/mockAxios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,28 @@ type Method = "get" | "post" | "patch" | "delete"

type PartialAxiosResponse = Pick<AxiosResponse, "data" | "status">

const alwaysError = (
method: string,
type RequestMaker = (
method: Method,
url: string,
_body?: unknown,
): Promise<PartialAxiosResponse> => {
body?: unknown,
) => Promise<PartialAxiosResponse>

const alwaysError: RequestMaker = (method, url, _body) => {
const msg = `No response specified for ${method} ${url}`
console.error(msg)
throw new Error(msg)
}

const standardizeUrl = (url: string) => {
if (!url.includes("?")) {
return url
}
const [path, queryString] = url.split("?")
const query = new URLSearchParams(queryString)
query.sort()
return `${path}?${query.toString()}`
}

/**
* A jest mock function that makes fake network requests.
*
Expand All @@ -29,17 +41,23 @@ const alwaysError = (
* '/some/url/to/thing',
* expect.objectContaining({ some: 'value' }) // request body
* ])
*
* NOTE: URLs called by this function are first
* ```
*/
const makeRequest = jest.fn(alwaysError)
const makeSortedRequest: RequestMaker = (method, url, body) =>
makeRequest(method, standardizeUrl(url), body)

const mockAxiosInstance = {
get: jest.fn((url: string) => makeRequest("get", url, undefined)),
post: jest.fn((url: string, body: unknown) => makeRequest("post", url, body)),
get: jest.fn((url: string) => makeSortedRequest("get", url, undefined)),
post: jest.fn((url: string, body: unknown) =>
makeSortedRequest("post", url, body),
),
patch: jest.fn((url: string, body: unknown) =>
makeRequest("patch", url, body),
makeSortedRequest("patch", url, body),
),
delete: jest.fn((url: string) => makeRequest("delete", url, undefined)),
delete: jest.fn((url: string) => makeSortedRequest("delete", url, undefined)),
request: jest.fn(
(
{
Expand All @@ -57,7 +75,11 @@ const mockAxiosInstance = {
// on object shape.
const deserialized =
typeof data === "string" ? JSON.parse(data) : undefined
return makeRequest(method.toLowerCase(), url, deserialized)
return makeSortedRequest(
method.toLowerCase() as Method,
url,
deserialized,
)
},
),
defaults: {}, // OpenAPI Generator accesses this, so it needs to exist
Expand All @@ -72,24 +94,16 @@ const expectAnythingOrNil = expect.toBeOneOf([
expect.toBeNil(),
])

const standardizeUrl = <T>(url: T) => {
if (!(typeof url === "string")) return url
if (!url.includes("?")) return url
const [path, queryString] = url.split("?")
const query = new URLSearchParams(queryString)
query.sort()
return `${path}?${query.toString()}`
}

const mockRequest = <T, U>(
method: Method,
url: string,
requestBody: T = expectAnythingOrNil,
responseBody: U | ((req: T) => U) | undefined = undefined,
code: number,
) => {
const urlMatcher = typeof url === "string" ? standardizeUrl(url) : url
when(makeRequest)
.calledWith(method, standardizeUrl(url), requestBody)
.calledWith(method, urlMatcher, requestBody)
.mockImplementation(async () => {
let data
if (isFunction(responseBody)) {
Expand Down Expand Up @@ -158,7 +172,7 @@ const setMockResponse = {
{ code = 200, requestBody }: MockResponseOptions = {},
) => mockRequest("patch", url, requestBody, responseBody, code),
/**
* Set mock response for a PATCH request; default response status is 204.
* Set mock response for a DELETE request; default response status is 204.
*
* If `responseBody` is a Promise, the request will resolve to the value of
* `responseBody` when `responseBody` resolves.
Expand Down
2 changes: 1 addition & 1 deletion frontends/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@emotion/cache": "^11.13.1",
"@emotion/styled": "^11.11.0",
"@mitodl/course-search-utils": "3.3.2",
"@mitodl/mitxonline-api-axios": "^2025.9.11",
"@mitodl/mitxonline-api-axios": "^2025.9.26",
"@mitodl/smoot-design": "^6.17.1",
"@next/bundle-analyzer": "^14.2.15",
"@react-pdf/renderer": "^4.3.0",
Expand Down
Loading
Loading