Skip to content
Merged
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: 2 additions & 0 deletions frontends/jest.jsdom.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { resolve } from "path"
import type { Config } from "@jest/types"

process.env.SITE_NAME = "MIT Open"

/**
* Base configuration for jest tests.
*/
Expand Down
2 changes: 1 addition & 1 deletion frontends/mit-open/src/pages/AboutPage/AboutPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe("AboutPage", () => {
url: commonUrls.ABOUT,
})
await waitFor(() => {
expect(document.title).toBe("About Us")
expect(document.title).toBe("About Us | MIT Open")
})
screen.getByRole("heading", {
name: "About Us",
Expand Down
4 changes: 1 addition & 3 deletions frontends/mit-open/src/pages/AboutPage/AboutPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@ const AboutPage: React.FC = () => {
return (
<Container>
<PageContainer>
<MetaTags>
<title>About Us</title>
</MetaTags>
<MetaTags title="About Us" />
<BannerContainer>
<BannerContainerInner>
<Breadcrumbs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe("ArticleDetailsPage", () => {
screen.getByText(article.html)

await waitFor(() => {
expect(document.title).toBe(article.title)
expect(document.title).toBe(`${article.title} | MIT Open`)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ const ArticlesDetailPage: React.FC = () => {
src="/static/images/course_search_banner.png"
className="articles-detail-page"
>
<MetaTags>
<title>{article.data?.title}</title>
</MetaTags>
<MetaTags title={article.data?.title} />
<Container maxWidth="sm">
<GridContainer>
<GridColumn variant="single-full" container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("ArticleEditPage", () => {
expect(bodyInput).toBeInstanceOf(HTMLTextAreaElement)

await waitFor(() => {
expect(document.title).toBe(`Editing: ${article.title}`)
expect(document.title).toBe(`${article.title} | Edit | MIT Open`)
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const ArticleEditPage: React.FC = () => {
[navigate, id],
)
const goHome = useCallback(() => navigate("/"), [navigate])
const title = `Editing: ${article.data?.title ?? ""}`
const title = article.data?.title ? `${article.data?.title} | Edit` : "Edit"
return (
<ArticleUpsertPage title={title}>
<ArticleUpsertForm
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ const ArticleUpsertPage: React.FC<ArticleUpsertPageProps> = ({
}) => {
return (
<BannerPage src="/static/images/course_search_banner.png">
<MetaTags>
<title>{title}</title>
</MetaTags>
<MetaTags title={title} />
<Container maxWidth="sm">
<GridContainer>
<GridColumn variant="single-full">{children}</GridColumn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ describe("DashboardPage", () => {
setupAPIs()
renderWithProviders(<DashboardPage />)
await waitFor(() => {
expect(document.title).toBe("User Home")
expect(document.title).toBe("Your MIT Learning Journey | MIT Open")
})
screen.getByRole("heading", {
name: "Your MIT Learning Journey",
Expand Down
4 changes: 1 addition & 3 deletions frontends/mit-open/src/pages/DashboardPage/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -415,9 +415,7 @@ const DashboardPage: React.FC = () => {
<Background>
<Page>
<DashboardContainer>
<MetaTags>
<title>User Home</title>
</MetaTags>
<MetaTags title="Your MIT Learning Journey" />
<TabContext value={tabValue}>
<DashboardGrid>
<DashboardGridItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ describe("DepartmentListingPage", () => {
}
}

it("Has a page title", async () => {
it("Has correct page title", async () => {
setupApis()
renderWithProviders(<DepartmentListingPage />)
await waitFor(() => {
expect(document.title).toBe("MIT Open | Departments")
expect(document.title).toBe("Departments | MIT Open")
})
screen.getByRole("heading", { name: "Departments" })
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,7 @@ const DepartmentListingPage: React.FC = () => {

return (
<Page>
<MetaTags>
<title>MIT Open | Departments</title>
</MetaTags>
<MetaTags title="Departments" />
<Banner
backgroundUrl="/static/images/background_steps.jpeg"
title="Departments"
Expand Down
10 changes: 5 additions & 5 deletions frontends/mit-open/src/pages/ErrorPage/ErrorPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ test.each([{ status: 401 }, { status: 403 }])(
// redirect elsewhere.
setup(status, { user: { is_authenticated: true } })
await waitFor(() => {
expect(document.title).toBe("Not Allowed")
expect(document.title).toBe("Not Allowed | MIT Open")
})
},
)
Expand All @@ -54,15 +54,15 @@ test("ErrorPage shows NotFound on API 404 errors", async () => {
allowConsoleErrors()
setup(404)
await waitFor(() => {
expect(document.title).toBe("Not Found")
expect(document.title).toBe("Not Found | MIT Open")
})
})

test("ErrorPage shows NotFound on frontend routing 404 errors", async () => {
allowConsoleErrors()
renderTestApp({ url: "/some-fake-route" })
await waitFor(() => {
expect(document.title).toBe("Not Found")
expect(document.title).toBe("Not Found | MIT Open")
})
})

Expand All @@ -87,7 +87,7 @@ test("ErrorPage shows ForbiddenPage on restricted routes.", async () => {
{ user: { is_authenticated: true } },
)
await waitFor(() => {
expect(document.title).toBe("Not Allowed")
expect(document.title).toBe("Not Allowed | MIT Open")
})
})

Expand All @@ -107,7 +107,7 @@ test("ErrorPage shows fallback and logs unexpected errors", async () => {
{ user: { is_authenticated: true } },
)
await waitFor(() => {
expect(document.title).toBe("Not Allowed")
expect(document.title).toBe("Not Allowed | MIT Open")
})
expect(consoleError).toHaveBeenCalledWith(Error("Some Error"))
})
3 changes: 1 addition & 2 deletions frontends/mit-open/src/pages/ErrorPage/ErrorPageTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ const ErrorPageTemplate: React.FC<ErrorPageTemplateProps> = ({
return (
<Container maxWidth="sm">
<MuiCard sx={{ marginTop: "1rem" }}>
<MetaTags>
<MetaTags title={title}>
<meta name="robots" content="noindex,noarchive" />
<title>{title}</title>
</MetaTags>
<CardContent>{children}</CardContent>
<CardActions>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ test("The ForbiddenPage loads with meta", async () => {
})
renderWithProviders(<ForbiddenPage />)
await waitFor(() => {
expect(document.title).toBe("Not Allowed")
expect(document.title).toBe("Not Allowed | MIT Open")
})

const meta = document.head.querySelector('meta[name="robots"]')
Expand Down
4 changes: 1 addition & 3 deletions frontends/mit-open/src/pages/FieldPage/EditFieldPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ const EditFieldPage: React.FC = () => {
name={field.data?.name}
channelType={field.data?.channel_type}
>
<MetaTags>
<title>Edit {field.data.title} Channel</title>
</MetaTags>
<MetaTags title={[field.data.title, "Edit"]} />
{field.data.is_moderator ? (
<TabContext value={tabValue}>
<div className="page-subbanner">
Expand Down
Loading