@@ -4,6 +4,7 @@ import { WildcardMockLink, MATCH_ANY_PARAMETERS } from 'wildcard-mock-link'
44import { getDocumentNode } from '@sourcegraph/http-client'
55import { EMPTY_SETTINGS_CASCADE } from '@sourcegraph/shared/src/settings/settings'
66import { MockedTestProvider } from '@sourcegraph/shared/src/testing/apollo'
7+ import { updateJSContextBatchChangesLicense } from '@sourcegraph/shared/src/testing/batches'
78
89import { WebStory } from '../../../components/WebStory'
910import { GlobalChangesetsStatsResult } from '../../../graphql-operations'
@@ -18,8 +19,8 @@ import { BatchChangeListPage } from './BatchChangeListPage'
1819import {
1920 BATCH_CHANGES_BY_NAMESPACE_RESULT ,
2021 BATCH_CHANGES_RESULT ,
21- getLicenseAndUsageInfoResult ,
2222 NO_BATCH_CHANGES_RESULT ,
23+ getLicenseAndUsageInfoResult ,
2324} from './testData'
2425
2526const decorator : DecoratorFn = story => < div className = "p-3 container" > { story ( ) } </ div >
@@ -89,23 +90,27 @@ interface Args {
8990 isApp : boolean
9091}
9192
92- export const ListOfBatchChanges : Story < Args > = args => (
93- < WebStory >
94- { props => (
95- < MockedTestProvider link = { buildMocks ( ) } >
96- < BatchChangeListPage
97- { ...props }
98- headingElement = "h1"
99- canCreate = { args . canCreate || "You don't have permission to create batch changes" }
100- settingsCascade = { EMPTY_SETTINGS_CASCADE }
101- isSourcegraphDotCom = { args . isDotCom }
102- isSourcegraphApp = { args . isApp }
103- authenticatedUser = { null }
104- />
105- </ MockedTestProvider >
106- ) }
107- </ WebStory >
108- )
93+ export const ListOfBatchChanges : Story < Args > = args => {
94+ updateJSContextBatchChangesLicense ( 'full' )
95+
96+ return (
97+ < WebStory >
98+ { props => (
99+ < MockedTestProvider link = { buildMocks ( ) } >
100+ < BatchChangeListPage
101+ { ...props }
102+ headingElement = "h1"
103+ canCreate = { args . canCreate || "You don't have permission to create batch changes" }
104+ settingsCascade = { EMPTY_SETTINGS_CASCADE }
105+ isSourcegraphDotCom = { args . isDotCom }
106+ isSourcegraphApp = { args . isApp }
107+ authenticatedUser = { null }
108+ />
109+ </ MockedTestProvider >
110+ ) }
111+ </ WebStory >
112+ )
113+ }
109114ListOfBatchChanges . argTypes = {
110115 canCreate : {
111116 name : 'can create batch changes' ,
@@ -126,109 +131,129 @@ ListOfBatchChanges.argTypes = {
126131
127132ListOfBatchChanges . storyName = 'List of batch changes'
128133
129- export const ListOfBatchChangesSpecificNamespace : Story = ( ) => (
130- < WebStory >
131- { props => (
132- < MockedTestProvider link = { MOCKS_FOR_NAMESPACE } >
133- < BatchChangeListPage
134- { ...props }
135- headingElement = "h1"
136- canCreate = { true }
137- namespaceID = "test-12345"
138- settingsCascade = { EMPTY_SETTINGS_CASCADE }
139- isSourcegraphDotCom = { false }
140- isSourcegraphApp = { false }
141- authenticatedUser = { null }
142- />
143- </ MockedTestProvider >
144- ) }
145- </ WebStory >
146- )
134+ export const ListOfBatchChangesSpecificNamespace : Story = ( ) => {
135+ updateJSContextBatchChangesLicense ( 'full' )
136+
137+ return (
138+ < WebStory >
139+ { props => (
140+ < MockedTestProvider link = { MOCKS_FOR_NAMESPACE } >
141+ < BatchChangeListPage
142+ { ...props }
143+ headingElement = "h1"
144+ canCreate = { true }
145+ namespaceID = "test-12345"
146+ settingsCascade = { EMPTY_SETTINGS_CASCADE }
147+ isSourcegraphDotCom = { false }
148+ isSourcegraphApp = { false }
149+ authenticatedUser = { null }
150+ />
151+ </ MockedTestProvider >
152+ ) }
153+ </ WebStory >
154+ )
155+ }
147156
148157ListOfBatchChangesSpecificNamespace . storyName = 'List of batch changes, for a specific namespace'
149158
150- export const ListOfBatchChangesServerSideExecutionEnabled : Story = ( ) => (
151- < WebStory >
152- { props => (
153- < MockedTestProvider link = { buildMocks ( ) } >
154- < BatchChangeListPage
155- { ...props }
156- headingElement = "h1"
157- canCreate = { true }
158- settingsCascade = { {
159- ...EMPTY_SETTINGS_CASCADE ,
160- final : {
161- experimentalFeatures : { batchChangesExecution : true } ,
162- } ,
163- } }
164- isSourcegraphDotCom = { false }
165- isSourcegraphApp = { false }
166- authenticatedUser = { null }
167- />
168- </ MockedTestProvider >
169- ) }
170- </ WebStory >
171- )
159+ export const ListOfBatchChangesServerSideExecutionEnabled : Story = ( ) => {
160+ updateJSContextBatchChangesLicense ( 'full' )
161+
162+ return (
163+ < WebStory >
164+ { props => (
165+ < MockedTestProvider link = { buildMocks ( ) } >
166+ < BatchChangeListPage
167+ { ...props }
168+ headingElement = "h1"
169+ canCreate = { true }
170+ settingsCascade = { {
171+ ...EMPTY_SETTINGS_CASCADE ,
172+ final : {
173+ experimentalFeatures : { batchChangesExecution : true } ,
174+ } ,
175+ } }
176+ isSourcegraphDotCom = { false }
177+ isSourcegraphApp = { false }
178+ authenticatedUser = { null }
179+ />
180+ </ MockedTestProvider >
181+ ) }
182+ </ WebStory >
183+ )
184+ }
172185
173186ListOfBatchChangesServerSideExecutionEnabled . storyName = 'List of batch changes, server-side execution enabled'
174187
175- export const LicensingNotEnforced : Story = ( ) => (
176- < WebStory >
177- { props => (
178- < MockedTestProvider link = { buildMocks ( false ) } >
179- < BatchChangeListPage
180- { ...props }
181- headingElement = "h1"
182- canCreate = { true }
183- settingsCascade = { EMPTY_SETTINGS_CASCADE }
184- isSourcegraphDotCom = { false }
185- isSourcegraphApp = { false }
186- authenticatedUser = { null }
187- />
188- </ MockedTestProvider >
189- ) }
190- </ WebStory >
191- )
188+ export const LicensingNotEnforced : Story = ( ) => {
189+ updateJSContextBatchChangesLicense ( 'limited' )
190+
191+ return (
192+ < WebStory >
193+ { props => (
194+ < MockedTestProvider link = { buildMocks ( false ) } >
195+ < BatchChangeListPage
196+ { ...props }
197+ headingElement = "h1"
198+ canCreate = { true }
199+ settingsCascade = { EMPTY_SETTINGS_CASCADE }
200+ isSourcegraphDotCom = { false }
201+ isSourcegraphApp = { false }
202+ authenticatedUser = { null }
203+ />
204+ </ MockedTestProvider >
205+ ) }
206+ </ WebStory >
207+ )
208+ }
192209
193210LicensingNotEnforced . storyName = 'Licensing not enforced'
194211
195- export const NoBatchChanges : Story = ( ) => (
196- < WebStory >
197- { props => (
198- < MockedTestProvider link = { buildMocks ( true , false ) } >
199- < BatchChangeListPage
200- { ...props }
201- headingElement = "h1"
202- canCreate = { true }
203- settingsCascade = { EMPTY_SETTINGS_CASCADE }
204- isSourcegraphDotCom = { false }
205- isSourcegraphApp = { false }
206- authenticatedUser = { null }
207- />
208- </ MockedTestProvider >
209- ) }
210- </ WebStory >
211- )
212+ export const NoBatchChanges : Story = ( ) => {
213+ updateJSContextBatchChangesLicense ( 'full' )
214+
215+ return (
216+ < WebStory >
217+ { props => (
218+ < MockedTestProvider link = { buildMocks ( true , false ) } >
219+ < BatchChangeListPage
220+ { ...props }
221+ headingElement = "h1"
222+ canCreate = { true }
223+ settingsCascade = { EMPTY_SETTINGS_CASCADE }
224+ isSourcegraphDotCom = { false }
225+ isSourcegraphApp = { false }
226+ authenticatedUser = { null }
227+ />
228+ </ MockedTestProvider >
229+ ) }
230+ </ WebStory >
231+ )
232+ }
212233
213234NoBatchChanges . storyName = 'No batch changes'
214235
215- export const AllBatchChangesTabEmpty : Story = ( ) => (
216- < WebStory >
217- { props => (
218- < MockedTestProvider link = { buildMocks ( true , true , false ) } >
219- < BatchChangeListPage
220- { ...props }
221- headingElement = "h1"
222- canCreate = { true }
223- openTab = "batchChanges"
224- settingsCascade = { EMPTY_SETTINGS_CASCADE }
225- isSourcegraphDotCom = { false }
226- isSourcegraphApp = { false }
227- authenticatedUser = { null }
228- />
229- </ MockedTestProvider >
230- ) }
231- </ WebStory >
232- )
236+ export const AllBatchChangesTabEmpty : Story = ( ) => {
237+ updateJSContextBatchChangesLicense ( 'full' )
238+
239+ return (
240+ < WebStory >
241+ { props => (
242+ < MockedTestProvider link = { buildMocks ( true , true , false ) } >
243+ < BatchChangeListPage
244+ { ...props }
245+ headingElement = "h1"
246+ canCreate = { true }
247+ openTab = "batchChanges"
248+ settingsCascade = { EMPTY_SETTINGS_CASCADE }
249+ isSourcegraphDotCom = { false }
250+ isSourcegraphApp = { false }
251+ authenticatedUser = { null }
252+ />
253+ </ MockedTestProvider >
254+ ) }
255+ </ WebStory >
256+ )
257+ }
233258
234259AllBatchChangesTabEmpty . storyName = 'All batch changes tab empty'
0 commit comments