@@ -149,7 +149,7 @@ export function getArgvValue<ParseFuncReturnType>(
149149 * Creates a it function for the test file
150150 * @TODO : improve this
151151 */
152- export function itFunction ( { clip, clipSelector, folders : { baselineFolder } , framework, skipStories, storyData, storybookUrl } : CreateItContent ) {
152+ export function itFunction ( { additionalSearchParams , clip, clipSelector, folders : { baselineFolder } , framework, skipStories, storyData, storybookUrl } : CreateItContent ) {
153153 const { id } = storyData
154154 const screenshotType = clip ? 'n element' : ' viewport'
155155 const DEFAULT_IT_TEXT = 'it'
@@ -179,6 +179,7 @@ export function itFunction({ clip, clipSelector, folders: { baselineFolder }, fr
179179 clipSelector: '${ clipSelector } ',
180180 id: '${ id } ',
181181 storybookUrl: '${ storybookUrl } ',
182+ additionalSearchParams: new URLSearchParams('${ additionalSearchParams . toString ( ) } '),
182183 });
183184 ${ clip
184185 ? `await expect($('${ clipSelector } ')).toMatchElementSnapshot('${ id } -element', ${ JSON . stringify ( methodOptions ) } )`
@@ -206,11 +207,11 @@ export function writeTestFile(directoryPath: string, fileID: string, testContent
206207 * Create the test content
207208 */
208209export function createTestContent (
209- { clip, clipSelector, folders, framework, skipStories, stories, storybookUrl } : CreateTestContent ,
210+ { additionalSearchParams , clip, clipSelector, folders, framework, skipStories, stories, storybookUrl } : CreateTestContent ,
210211 // For testing purposes only
211212 itFunc = itFunction
212213) : string {
213- const itFunctionOptions = { clip, clipSelector, folders, framework, skipStories, storybookUrl }
214+ const itFunctionOptions = { additionalSearchParams , clip, clipSelector, folders, framework, skipStories, storybookUrl }
214215
215216 return stories . reduce ( ( acc , storyData ) => acc + itFunc ( { ...itFunctionOptions , storyData } ) , '' )
216217}
@@ -226,12 +227,21 @@ export async function waitForStorybookComponentToBeLoaded(
226227 const isStorybook = isStorybookModeFunc ( )
227228 if ( isStorybook ) {
228229 const {
230+ additionalSearchParams,
229231 clipSelector = process . env . VISUAL_STORYBOOK_CLIP_SELECTOR ,
230232 id,
231233 url = process . env . VISUAL_STORYBOOK_URL ,
232234 timeout = 11000 ,
233235 } = options
234- await browser . url ( `${ url } iframe.html?id=${ id } ` )
236+ const baseUrl = new URL ( 'iframe.html' , url )
237+ const searchParams = new URLSearchParams ( { id } )
238+ if ( additionalSearchParams ) {
239+ for ( const [ key , value ] of additionalSearchParams ) {
240+ searchParams . append ( key , value )
241+ }
242+ }
243+ baseUrl . search = searchParams . toString ( )
244+ await browser . url ( baseUrl . toString ( ) )
235245 await $ ( clipSelector as string ) . waitForDisplayed ( )
236246 await browser . executeAsync ( async ( timeout , done ) => {
237247 let timedOut = false
@@ -304,14 +314,14 @@ function filterStories(storiesJson: Stories): StorybookData[] {
304314 * Create the test files
305315 */
306316export function createTestFiles (
307- { clip, clipSelector, directoryPath, folders, framework, numShards, skipStories, storiesJson, storybookUrl } : CreateTestFileOptions ,
317+ { additionalSearchParams , clip, clipSelector, directoryPath, folders, framework, numShards, skipStories, storiesJson, storybookUrl } : CreateTestFileOptions ,
308318 // For testing purposes only
309319 createTestCont = createTestContent ,
310320 createFileD = createFileData ,
311321 writeTestF = writeTestFile
312322) {
313323 const fileNamePrefix = 'visual-storybook'
314- const createTestContentData = { clip, clipSelector, folders, framework, skipStories, stories : storiesJson , storybookUrl }
324+ const createTestContentData = { additionalSearchParams , clip, clipSelector, folders, framework, skipStories, stories : storiesJson , storybookUrl }
315325
316326 if ( numShards === 1 ) {
317327 const testContent = createTestCont ( createTestContentData )
0 commit comments