-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Show org token selector (#7385)
- Loading branch information
Showing
12 changed files
with
596 additions
and
57 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
250 changes: 250 additions & 0 deletions
250
src/components/__tests__/__snapshots__/codeBlock.test.js.snap
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,250 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`CodeWrapper renders multiple placeholders 1`] = ` | ||
<code> | ||
process.env.MY_ENV = | ||
<span | ||
className="css-1rhw0e5" | ||
onClick={[Function]} | ||
onKeyDown={[Function]} | ||
role="button" | ||
tabIndex={0} | ||
title="example-org / example-project" | ||
> | ||
<svg | ||
className="css-1i93cgw" | ||
fill="none" | ||
height="12px" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="2" | ||
viewBox="0 0 24 24" | ||
width="12px" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<line | ||
x1="12" | ||
x2="12" | ||
y1="5" | ||
y2="19" | ||
/> | ||
<polyline | ||
points="19 12 12 19 5 12" | ||
/> | ||
</svg> | ||
<span | ||
style={ | ||
{ | ||
"display": undefined, | ||
} | ||
} | ||
> | ||
<span | ||
className="css-1f5vc5" | ||
style={ | ||
{ | ||
"opacity": 1, | ||
"position": "relative", | ||
"transform": "none", | ||
} | ||
} | ||
> | ||
example-org | ||
</span> | ||
</span> | ||
</span> | ||
+ | ||
<span | ||
className="css-1rhw0e5" | ||
onClick={[Function]} | ||
onKeyDown={[Function]} | ||
role="button" | ||
tabIndex={0} | ||
title="example-org / example-project" | ||
> | ||
<svg | ||
className="css-1i93cgw" | ||
fill="none" | ||
height="12px" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="2" | ||
viewBox="0 0 24 24" | ||
width="12px" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<line | ||
x1="12" | ||
x2="12" | ||
y1="5" | ||
y2="19" | ||
/> | ||
<polyline | ||
points="19 12 12 19 5 12" | ||
/> | ||
</svg> | ||
<span | ||
style={ | ||
{ | ||
"display": undefined, | ||
} | ||
} | ||
> | ||
<span | ||
className="css-1f5vc5" | ||
style={ | ||
{ | ||
"opacity": 1, | ||
"position": "relative", | ||
"transform": "none", | ||
} | ||
} | ||
> | ||
example-project | ||
</span> | ||
</span> | ||
</span> | ||
</code> | ||
`; | ||
|
||
exports[`CodeWrapper renders org auth token placeholder when not signed in 1`] = ` | ||
<code> | ||
process.env.MY_ENV = | ||
sntrys_YOUR_TOKEN_HERE | ||
</code> | ||
`; | ||
|
||
exports[`CodeWrapper renders org auth token placeholder when signed in 1`] = ` | ||
<code> | ||
process.env.MY_ENV = | ||
<span | ||
className="css-1rhw0e5" | ||
onClick={[Function]} | ||
> | ||
Click to generate token | ||
</span> | ||
</code> | ||
`; | ||
|
||
exports[`CodeWrapper renders with placeholder 1`] = ` | ||
<code> | ||
process.env.MY_ENV = | ||
<span | ||
className="css-1rhw0e5" | ||
onClick={[Function]} | ||
onKeyDown={[Function]} | ||
role="button" | ||
tabIndex={0} | ||
title="example-org / example-project" | ||
> | ||
<svg | ||
className="css-1i93cgw" | ||
fill="none" | ||
height="12px" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="2" | ||
viewBox="0 0 24 24" | ||
width="12px" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<line | ||
x1="12" | ||
x2="12" | ||
y1="5" | ||
y2="19" | ||
/> | ||
<polyline | ||
points="19 12 12 19 5 12" | ||
/> | ||
</svg> | ||
<span | ||
style={ | ||
{ | ||
"display": undefined, | ||
} | ||
} | ||
> | ||
<span | ||
className="css-1f5vc5" | ||
style={ | ||
{ | ||
"opacity": 1, | ||
"position": "relative", | ||
"transform": "none", | ||
} | ||
} | ||
> | ||
example-org | ||
</span> | ||
</span> | ||
</span> | ||
</code> | ||
`; | ||
|
||
exports[`CodeWrapper renders with placeholder in middle of text 1`] = ` | ||
<code> | ||
process.env.MY_ENV = https:// | ||
<span | ||
className="css-1rhw0e5" | ||
onClick={[Function]} | ||
onKeyDown={[Function]} | ||
role="button" | ||
tabIndex={0} | ||
title="example-org / example-project" | ||
> | ||
<svg | ||
className="css-1i93cgw" | ||
fill="none" | ||
height="12px" | ||
stroke="currentColor" | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="2" | ||
viewBox="0 0 24 24" | ||
width="12px" | ||
xmlns="http://www.w3.org/2000/svg" | ||
> | ||
<line | ||
x1="12" | ||
x2="12" | ||
y1="5" | ||
y2="19" | ||
/> | ||
<polyline | ||
points="19 12 12 19 5 12" | ||
/> | ||
</svg> | ||
<span | ||
style={ | ||
{ | ||
"display": undefined, | ||
} | ||
} | ||
> | ||
<span | ||
className="css-1f5vc5" | ||
style={ | ||
{ | ||
"opacity": 1, | ||
"position": "relative", | ||
"transform": "none", | ||
} | ||
} | ||
> | ||
example-org | ||
</span> | ||
</span> | ||
</span> | ||
.sentry.io | ||
</code> | ||
`; | ||
|
||
exports[`CodeWrapper renders without placeholder 1`] = ` | ||
<code> | ||
process.env.MY_ENV = 'foo' | ||
</code> | ||
`; |
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,74 @@ | ||
import React from 'react'; | ||
import {create} from 'react-test-renderer'; | ||
|
||
import {CodeWrapper} from '../codeBlock'; | ||
import {_setCachedCodeKeywords, CodeContextProvider, DEFAULTS} from '../codeContext'; | ||
|
||
describe('CodeWrapper', () => { | ||
beforeEach(() => { | ||
_setCachedCodeKeywords(DEFAULTS); | ||
}); | ||
|
||
it('renders without placeholder', () => { | ||
const tree = create( | ||
<CodeContextProvider> | ||
<CodeWrapper>process.env.MY_ENV = 'foo'</CodeWrapper> | ||
</CodeContextProvider> | ||
); | ||
|
||
expect(tree.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders with placeholder', () => { | ||
const tree = create( | ||
<CodeContextProvider> | ||
<CodeWrapper>process.env.MY_ENV = ___ORG_SLUG___</CodeWrapper> | ||
</CodeContextProvider> | ||
); | ||
|
||
expect(tree.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders with placeholder in middle of text', () => { | ||
const tree = create( | ||
<CodeContextProvider> | ||
<CodeWrapper>process.env.MY_ENV = https://___ORG_SLUG___.sentry.io</CodeWrapper> | ||
</CodeContextProvider> | ||
); | ||
|
||
expect(tree.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders org auth token placeholder when not signed in', () => { | ||
const tree = create( | ||
<CodeContextProvider> | ||
<CodeWrapper>process.env.MY_ENV = ___ORG_AUTH_TOKEN___</CodeWrapper> | ||
</CodeContextProvider> | ||
); | ||
|
||
expect(tree.toJSON()).toMatchSnapshot(); | ||
}); | ||
it('renders org auth token placeholder when signed in', () => { | ||
_setCachedCodeKeywords({...DEFAULTS, USER: {ID: 123, NAME: 'test@sentry.io'}}); | ||
|
||
const tree = create( | ||
<CodeContextProvider> | ||
<CodeWrapper>process.env.MY_ENV = ___ORG_AUTH_TOKEN___</CodeWrapper> | ||
</CodeContextProvider> | ||
); | ||
|
||
expect(tree.toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders multiple placeholders', () => { | ||
const tree = create( | ||
<CodeContextProvider> | ||
<CodeWrapper> | ||
process.env.MY_ENV = ___ORG_SLUG___ + ___PROJECT_SLUG___ | ||
</CodeWrapper> | ||
</CodeContextProvider> | ||
); | ||
|
||
expect(tree.toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
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.
59158be
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
sentry-docs – ./
docs.sentry.io
sentry-docs.sentry.dev
sentry-docs-git-master.sentry.dev