-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tie chatbots to URL parameters (#2076)
* make LinkAdapter use shallow * tie AskTim to drawer query param * display syllabus chat based on query param
- Loading branch information
1 parent
aa02630
commit 7239c23
Showing
19 changed files
with
347 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -112,7 +112,12 @@ export const UNITS = "/units" | |
|
||
export const CONTACT = "mailto:[email protected]" | ||
|
||
export const RESOURCE_DRAWER_QUERY_PARAM = "resource" | ||
export const RECOMMENDER_QUERY_PARAM = "recommender" | ||
|
||
export const RESOURCE_DRAWER_PARAMS = { | ||
resource: "resource", | ||
syllabus: "syllabus", | ||
} as const | ||
|
||
export const querifiedSearchUrl = ( | ||
params: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
frontends/main/src/page-components/AiChat/AskTimDrawerButton.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from "react" | ||
import { renderWithProviders, screen, user, waitFor } from "@/test-utils" | ||
import AskTIMButton from "./AskTimDrawerButton" | ||
import { RECOMMENDER_QUERY_PARAM } from "@/common/urls" | ||
|
||
describe("AskTIMButton", () => { | ||
it.each([ | ||
{ url: "", open: false }, | ||
{ url: `?${RECOMMENDER_QUERY_PARAM}`, open: true }, | ||
])("Opens drawer based on URL param", async ({ url, open }) => { | ||
renderWithProviders(<AskTIMButton />, { | ||
url, | ||
}) | ||
|
||
const aiChat = screen.queryByTestId("ai-chat-entry-screen") | ||
expect(!!aiChat).toBe(open) | ||
}) | ||
|
||
test("Clicking button opens / closes drawer", async () => { | ||
const { location } = renderWithProviders(<AskTIMButton />) | ||
|
||
expect(location.current.searchParams.has(RECOMMENDER_QUERY_PARAM)).toBe( | ||
false, | ||
) | ||
|
||
const askTim = screen.getByRole("link", { name: /ask tim/i }) | ||
|
||
await user.click(askTim) | ||
|
||
expect(location.current.searchParams.has(RECOMMENDER_QUERY_PARAM)).toBe( | ||
true, | ||
) | ||
|
||
await user.click(screen.getByRole("button", { name: "Close" })) | ||
|
||
await waitFor(() => { | ||
expect(location.current.searchParams.has(RECOMMENDER_QUERY_PARAM)).toBe( | ||
false, | ||
) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.