Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
Fix storybook type errors and add CI test (#59362)
Browse files Browse the repository at this point in the history
* commiting a type error

* WIP

* added ts_project for stories

* removed fake story

* committing type error

* re-fixed type error

* used gazelle custom groups

* fixed another ts issue
  • Loading branch information
jamesmcnamara authored Jan 8, 2024
1 parent 34ea7f4 commit f2e8167
Show file tree
Hide file tree
Showing 6 changed files with 330 additions and 43 deletions.
306 changes: 284 additions & 22 deletions client/web/BUILD.bazel

Large diffs are not rendered by default.

33 changes: 29 additions & 4 deletions client/web/src/enterprise/own/RepositoryOwnEditPage.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { subDays } from 'date-fns'

import { getDocumentNode } from '@sourcegraph/http-client'

import { AuthenticatedUser } from '../../auth'
import { WebStory } from '../../components/WebStory'
import {
ExternalServiceKind,
Expand All @@ -12,6 +13,7 @@ import {
type RepositoryFields,
RepositoryType,
} from '../../graphql-operations'
import { OwnershipAssignPermission } from '../../rbac/constants'

import { GET_INGESTED_CODEOWNERS_QUERY } from './graphqlQueries'
import { RepositoryOwnEditPage } from './RepositoryOwnEditPage'
Expand Down Expand Up @@ -51,6 +53,13 @@ const repo: RepositoryFields = {
topics: [],
}

const emptyPermissions: AuthenticatedUser['permissions'] = { nodes: [] }

// If you wish to test assigning a new repo owner
const ownershipAssignPermissions: AuthenticatedUser['permissions'] = {
nodes: [{ id: OwnershipAssignPermission, displayName: OwnershipAssignPermission }],
}

const emptyResponse: MockedResponse<GetIngestedCodeownersResult, GetIngestedCodeownersVariables> = {
request: {
query: getDocumentNode(GET_INGESTED_CODEOWNERS_QUERY),
Expand All @@ -66,7 +75,11 @@ const emptyResponse: MockedResponse<GetIngestedCodeownersResult, GetIngestedCode
export const EmptyNonAdmin: StoryFn = () => (
<WebStory mocks={[emptyResponse]}>
{({ useBreadcrumb }) => (
<RepositoryOwnEditPage repo={repo} authenticatedUser={{ siteAdmin: false }} useBreadcrumb={useBreadcrumb} />
<RepositoryOwnEditPage
repo={repo}
authenticatedUser={{ siteAdmin: false, permissions: emptyPermissions }}
useBreadcrumb={useBreadcrumb}
/>
)}
</WebStory>
)
Expand All @@ -75,7 +88,11 @@ EmptyNonAdmin.storyName = 'Empty (non-admin)'
export const EmptyAdmin: StoryFn = () => (
<WebStory mocks={[emptyResponse]}>
{({ useBreadcrumb }) => (
<RepositoryOwnEditPage repo={repo} authenticatedUser={{ siteAdmin: true }} useBreadcrumb={useBreadcrumb} />
<RepositoryOwnEditPage
repo={repo}
authenticatedUser={{ siteAdmin: true, permissions: emptyPermissions }}
useBreadcrumb={useBreadcrumb}
/>
)}
</WebStory>
)
Expand Down Expand Up @@ -106,7 +123,11 @@ const populatedResponse: MockedResponse<GetIngestedCodeownersResult, GetIngested
export const PopulatedNonAdmin: StoryFn = () => (
<WebStory mocks={[populatedResponse]}>
{({ useBreadcrumb }) => (
<RepositoryOwnEditPage repo={repo} authenticatedUser={{ siteAdmin: false }} useBreadcrumb={useBreadcrumb} />
<RepositoryOwnEditPage
repo={repo}
authenticatedUser={{ siteAdmin: false, permissions: emptyPermissions }}
useBreadcrumb={useBreadcrumb}
/>
)}
</WebStory>
)
Expand All @@ -115,7 +136,11 @@ PopulatedNonAdmin.storyName = 'Populated (non-admin)'
export const PopulatedAdmin: StoryFn = () => (
<WebStory mocks={[populatedResponse]}>
{({ useBreadcrumb }) => (
<RepositoryOwnEditPage repo={repo} authenticatedUser={{ siteAdmin: true }} useBreadcrumb={useBreadcrumb} />
<RepositoryOwnEditPage
repo={repo}
authenticatedUser={{ siteAdmin: true, permissions: ownershipAssignPermissions }}
useBreadcrumb={useBreadcrumb}
/>
)}
</WebStory>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const Default: StoryFn = () => (
{...noopBlockCallbacks}
id="file-block-1"
input={fileBlockInput}
output={of(HIGHLIGHTED_FILE_LINES_LONG[0])}
output={of(HIGHLIGHTED_FILE_LINES_LONG)}
isSelected={true}
isReadOnly={false}
showMenu={false}
Expand All @@ -62,7 +62,7 @@ export const EditMode: StoryFn = () => (
{...noopBlockCallbacks}
id="file-block-1"
input={{ repositoryName: '', filePath: '', revision: 'main', lineRange: { startLine: 1, endLine: 10 } }}
output={of(HIGHLIGHTED_FILE_LINES_LONG[0])}
output={of(HIGHLIGHTED_FILE_LINES_LONG)}
isSelected={true}
isReadOnly={false}
showMenu={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const Default: StoryFn = () => (
searchContextsEnabled={true}
ownEnabled={true}
telemetryService={NOOP_TELEMETRY_SERVICE}
fetchHighlightedFileLineRanges={() => of(HIGHLIGHTED_FILE_LINES_LONG)}
fetchHighlightedFileLineRanges={() => of([HIGHLIGHTED_FILE_LINES_LONG])}
settingsCascade={EMPTY_SETTINGS_CASCADE}
platformContext={NOOP_PLATFORM_CONTEXT}
/>
Expand All @@ -87,7 +87,7 @@ export const Selected: StoryFn = () => (
searchContextsEnabled={true}
ownEnabled={true}
telemetryService={NOOP_TELEMETRY_SERVICE}
fetchHighlightedFileLineRanges={() => of(HIGHLIGHTED_FILE_LINES_LONG)}
fetchHighlightedFileLineRanges={() => of([HIGHLIGHTED_FILE_LINES_LONG])}
settingsCascade={EMPTY_SETTINGS_CASCADE}
authenticatedUser={null}
platformContext={NOOP_PLATFORM_CONTEXT}
Expand All @@ -112,7 +112,7 @@ export const ReadOnlySelected: StoryFn = () => (
searchContextsEnabled={true}
ownEnabled={true}
telemetryService={NOOP_TELEMETRY_SERVICE}
fetchHighlightedFileLineRanges={() => of(HIGHLIGHTED_FILE_LINES_LONG)}
fetchHighlightedFileLineRanges={() => of([HIGHLIGHTED_FILE_LINES_LONG])}
settingsCascade={EMPTY_SETTINGS_CASCADE}
authenticatedUser={null}
platformContext={NOOP_PLATFORM_CONTEXT}
Expand Down
4 changes: 2 additions & 2 deletions client/web/src/notebooks/notebook/NotebookComponent.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Default: StoryFn = () => (
ownEnabled={true}
telemetryService={NOOP_TELEMETRY_SERVICE}
streamSearch={() => NEVER}
fetchHighlightedFileLineRanges={() => of(HIGHLIGHTED_FILE_LINES_LONG)}
fetchHighlightedFileLineRanges={() => of([HIGHLIGHTED_FILE_LINES_LONG])}
onSerializeBlocks={() => {}}
blocks={blocks}
settingsCascade={EMPTY_SETTINGS_CASCADE}
Expand All @@ -72,7 +72,7 @@ export const DefaultReadOnly: StoryFn = () => (
ownEnabled={true}
telemetryService={NOOP_TELEMETRY_SERVICE}
streamSearch={() => NEVER}
fetchHighlightedFileLineRanges={() => of(HIGHLIGHTED_FILE_LINES_LONG)}
fetchHighlightedFileLineRanges={() => of([HIGHLIGHTED_FILE_LINES_LONG])}
onSerializeBlocks={() => {}}
blocks={blocks}
settingsCascade={EMPTY_SETTINGS_CASCADE}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,74 +55,74 @@ const filters: Filter[] = [
label: 'github.com/test/this-is-a-very-long-repo-name',
value: 'repo:^github\\.com/test/this-is-a-very-long-repo-name$',
count: 5,
limitHit: false,
exhaustive: true,
kind: 'repo',
},
{
label: 'gitlab.com/sourcegraph/sourcegraph',
value: 'repo:^gitlab\\.com/sourcegraph/sourcegraph$',
count: 201,
limitHit: true,
exhaustive: false,
kind: 'repo',
},
{
label: 'github.com/microsoft/vscode',
value: 'repo:^github\\.com/microsoft/vscode$',
count: 10,
limitHit: true,
exhaustive: false,
kind: 'repo',
},
{
label: 'bitbucket.org/com/test',
value: 'repo:^bitbucket\\.org/com/test$',
count: 1,
limitHit: true,
exhaustive: false,
kind: 'repo',
},
{
label: 'bitbucket.org/org/test',
value: 'repo:^bitbucket\\.org/org/test$',
count: 1,
limitHit: true,
exhaustive: false,
kind: 'repo',
},
{
label: 'gitlab.sgdev.org/example/test',
value: 'repo:^gitlab\\.sgdev\\.org/example/test$',
count: 10,
limitHit: true,
exhaustive: false,
kind: 'repo',
},

{
label: 'lang:go',
value: 'lang:go',
count: 500,
limitHit: true,
exhaustive: false,
kind: 'lang',
},

{
label: 'lang:verylonglanguagenameloremipsumdolor',
value: 'lang:verylonglanguagenameloremipsumdolor',
count: 241,
limitHit: false,
exhaustive: true,
kind: 'lang',
},

{
label: '-file:_test\\.go$',
value: '-file:_test\\.go$',
count: 1230,
limitHit: false,
exhaustive: true,
kind: 'file',
},

...['TypeScript', 'JavaScript', 'C++', 'C', 'C#', 'Python', 'Ruby', 'Haskell', 'Java'].map(lang => ({
label: lang,
value: `lang:${lang.toLowerCase()}`,
count: 10,
limitHit: true,
exhaustive: false,
kind: 'lang' as Filter['kind'],
})),
]
Expand Down

0 comments on commit f2e8167

Please sign in to comment.