8000 chore: updated documentation link by Kira-Pilot · Pull Request #1387 · coder/coder · GitHub
[go: up one dir, main page]

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 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
Next Next commit
chore: updated documentation link
  • Loading branch information
Kira-Pilot committed May 11, 2022
commit 0ec9253ac61b144cf99153ade5a752e7132bda34
14 changes: 13 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,17 @@ const renderAndClick = async (props: Partial<UserDropdownProps> = {}) => {
}

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

beforeEach(() => {
jest.resetModules()
Copy link
Collaborator
8000
@BrunoQuaresma BrunoQuaresma May 11, 2022

Choose a reason for hiding this comment

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

Wondering if we need this, I'm not seeing a module being mocked.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've actually never mocked out process.env before so I'm definitely following some internet advice here 😃 but looking at the Jest docs, seems like each test file gets its own module registry by default. Trying to reset the cache with this line so we don't get any conflicts. I can test and see if it's not needed but it might be safer to leave it in. LMK what you think!

Copy link
Collaborator
@BrunoQuaresma BrunoQuaresma May 11, 2022

Choose a reason for hiding this comment

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

If it is not needed, I think we should remove it, but if you think it is needed, I'm good to keep it. I'm good with the decision you feel is the best 😄

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure; we can always add it back in if we see conflicts.

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.

})

afterEach(() => {
process.env = env
})

describe("when the trigger is clicked", () => {
it("opens the menu", async () => {
await renderAndClick()
Expand All @@ -32,14 +43,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
0