Skip to content

chore: updated documentation link #1387

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 11, 2022
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
15 changes: 14 additions & 1 deletion site/src/components/UserDropdown/UserDropdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ const renderAndClick = async (props: Partial<UserDropdownProps> = {}) => {
}

describe("UserDropdown", () => {
const env = process.env

// REMARK: copying process.env so we don't mutate that object or encounter conflicts between tests
beforeEach(() => {
process.env = { ...env }
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since env is already receiving the process.env in line 14, I would guess we are doing this to clone the object, is that right?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's right - I don't want to mutate process.env IRL.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If makes sense, I just would add a comment about this.

})

// REMARK: restoring process.env
afterEach(() => {
process.env = env
})

describe("when the trigger is clicked", () => {
it("opens the menu", async () => {
await renderAndClick()
Expand All @@ -32,14 +44,15 @@ describe("UserDropdown", () => {
})

it("has the correct link for the documentation item", async () => {
process.env.CODER_VERSION = "v0.5.4"
await renderAndClick()

const link = screen.getByText(Language.docsLabel).closest("a")
if (!link) {
throw new Error("Anchor tag not found for the documentation menu item")
}

expect(link.getAttribute("href")).toBe("https://coder.com/docs")
expect(link.getAttribute("href")).toBe(`https://github.com/coder/coder/tree/${process.env.CODER_VERSION}/docs`)
})

it("has the correct link for the account item", async () => {
Expand Down
7 changes: 6 additions & 1 deletion site/src/components/UserDropdown/UsersDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ export const UserDropdown: React.FC<UserDropdownProps> = ({ user, onSignOut }: U
</MenuItem>
</Link>

<a href="https://coder.com/docs" target="_blank" rel="noreferrer" className={styles.link}>
<a
href={`https://github.com/coder/coder/tree/${process.env.CODER_VERSION}/docs`}
target="_blank"
rel="noreferrer"
className={styles.link}
>
<MenuItem className={styles.menuItem} onClick={onPopoverClose}>
<ListItemIcon className={styles.icon}>
<DocsIcon />
Expand Down
2 changes: 2 additions & 0 deletions site/webpack.common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ import { Configuration, EnvironmentPlugin } from "webpack"
*/
const environmentPlugin = new EnvironmentPlugin({
INSPECT_XSTATE: "",
CODER_VERSION: "main",
})
console.info(`--- Setting INSPECT_XSTATE to '${process.env.INSPECT_XSTATE || ""}'`)
console.info(`--- Setting CODER_VERSION to '${process.env.CODER_VERSION || "main"}'`)
console.info(`--- Setting NODE_ENV to '${process.env.NODE_ENV || ""}'`)

/**
Expand Down