Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Show template.display_name on pages
  • Loading branch information
mtojek committed Nov 15, 2022
commit f30032c96206beb5af0459085904090847a68a72
4 changes: 3 additions & 1 deletion site/src/components/WorkspaceStats/WorkspaceStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const WorkspaceStats: FC<WorkspaceStatsProps> = ({
to={`/templates/${workspace.template_name}`}
className={combineClasses([styles.statsValue, styles.link])}
>
{workspace.template_display_name.length > 0 ? workspace.template_display_name : workspace.template_name}
{workspace.template_display_name.length > 0
? workspace.template_display_name
: workspace.template_name}
</Link>
</div>
<div className={styles.statItem}>
Expand Down
6 changes: 5 additions & 1 deletion site/src/components/WorkspacesTable/WorkspacesRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ export const WorkspacesRow: FC<
</TableCellLink>

<TableCellLink to={workspacePageLink}>
<TableCellDataPrimary>{workspace.template_display_name.length > 0 ? workspace.template_display_name : workspace.template_name}</TableCellDataPrimary>
<TableCellDataPrimary>
{workspace.template_display_name.length > 0
? workspace.template_display_name
: workspace.template_name}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we could have a util function on utils/workspace called getWorkspaceDisplayName(workspace: Workspace): string but it is your call.

Copy link
Member Author

Choose a reason for hiding this comment

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

Added a util function.

</TableCellDataPrimary>
</TableCellLink>
<TableCellLink to={workspacePageLink}>
<TableCellData>
Expand Down
4 changes: 4 additions & 0 deletions site/src/pages/WorkspacePage/WorkspacePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ describe("WorkspacePage", () => {
t("workspaceStatus.deleted", { ns: "common" }),
)
})
it("renders the template display name", async () => {
await renderWorkspacePage()
await screen.findByText(MockWorkspace.template_display_name)
})
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the FE, we use Storybook for visual tests and "integration tests"(the ones run by Jest) only for testing actions. So I think we can remove this.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed, thanks for the suggestion!


describe("Timeline", () => {
it("shows the timeline build", async () => {
Expand Down
9 changes: 8 additions & 1 deletion site/src/pages/WorkspacesPage/WorkspacesPage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { screen, waitFor } from "@testing-library/react"
import { rest } from "msw"
import * as CreateDayString from "util/createDayString"
import { MockWorkspace } from "../../testHelpers/entities"
import {
MockWorkspace,
MockWorkspacesResponse,
} from "../../testHelpers/entities"
import { history, render } from "../../testHelpers/renderHelpers"
import { server } from "../../testHelpers/server"
import WorkspacesPage from "./WorkspacesPage"
Expand Down Expand Up @@ -54,5 +57,9 @@ describe("WorkspacesPage", () => {
{ timeout: 2000 },
)
await screen.findByText(`${MockWorkspace.name}1`)
const templateDisplayNames = await screen.findAllByText(
`${MockWorkspace.template_display_name}`,
)
expect(templateDisplayNames).toHaveLength(MockWorkspacesResponse.count)
})
})