From 87d3be61afc108754912f311d560af854b4a2305 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 16 Jan 2026 16:47:22 -0800 Subject: [PATCH 1/7] lint: Add lint rule for calls to renderHook and derivitives --- eslint.config.mjs | 1 + static/eslint/eslintPluginSentry/index.mjs | 2 + .../no-renderHook-arrow-function.mjs | 237 ++++++++++++++++++ .../no-renderHook-arrow-function.spec.ts | 107 ++++++++ 4 files changed, 347 insertions(+) create mode 100644 static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs create mode 100644 static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts diff --git a/eslint.config.mjs b/eslint.config.mjs index b1eb70e3062fdf..898ee413491c10 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -426,6 +426,7 @@ export default typescript.config([ plugins: {'@sentry': sentryPlugin}, rules: { '@sentry/no-static-translations': 'error', + '@sentry/no-renderHook-arrow-function': 'error', }, }, { diff --git a/static/eslint/eslintPluginSentry/index.mjs b/static/eslint/eslintPluginSentry/index.mjs index 9e5723c7672da3..ee2abb246472e4 100644 --- a/static/eslint/eslintPluginSentry/index.mjs +++ b/static/eslint/eslintPluginSentry/index.mjs @@ -1,5 +1,7 @@ +import noRenderHookArrowFunction from './no-renderHook-arrow-function.mjs'; import noStaticTranslations from './no-static-translations.mjs'; export const rules = { + 'no-renderHook-arrow-function': noRenderHookArrowFunction, 'no-static-translations': noStaticTranslations, }; diff --git a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs new file mode 100644 index 00000000000000..e1d52297ae7bf8 --- /dev/null +++ b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs @@ -0,0 +1,237 @@ +const RENDER_HOOK_FNS = ['renderHook', 'renderHookWithProviders']; + +/** + * @type {import('eslint').Rule.RuleModule} + */ +const noRenderHookArrowFunction = { + meta: { + type: 'problem', + docs: { + description: + 'Disallow passing anonymous arrow functions to renderHook() when initialProps should be used instead', + recommended: true, + }, + schema: [], + messages: { + unnecessaryArrowFunction: + 'Pass the hook directly and use initialProps for arguments: renderHook({{hookName}}, {initialProps: {{props}}})', + arrowFunctionWithoutParams: + 'Pass the hook directly instead of wrapping it in an arrow function: renderHook({{hookName}})', + }, + fixable: 'code', + }, + + create(context) { + return { + CallExpression(node) { + const callee = node.callee; + + // Check if it's renderHook or renderHookWithProviders + if (!callee || callee.type !== 'Identifier') return; + if (!RENDER_HOOK_FNS.includes(callee.name)) return; + if (node.arguments.length === 0) return; + + const firstArg = node.arguments[0]; + + // Check if the first argument is an arrow function + if (firstArg.type !== 'ArrowFunctionExpression') return; + + const arrowFn = firstArg; + const arrowParams = arrowFn.params; + + // Get the body of the arrow function + let body = arrowFn.body; + + // If body is a block statement, get the return statement + if (body.type === 'BlockStatement') { + const returnStatement = body.body.find(stmt => stmt.type === 'ReturnStatement'); + if (!returnStatement?.argument) return; + body = returnStatement.argument; + } + + // Check if the body is a call expression (calling a hook) + if (body.type !== 'CallExpression') return; + + const hookCall = body; + const hookCallee = hookCall.callee; + + // Get the hook name + let hookName = ''; + if (hookCallee.type === 'Identifier') { + hookName = hookCallee.name; + } else if ( + hookCallee.type === 'MemberExpression' && + hookCallee.property.type === 'Identifier' + ) { + hookName = context.sourceCode.getText(hookCallee); + } else { + return; + } + + // Check if the arrow function doesn't use its parameters + // If it has no parameters, it's definitely unnecessary + if (arrowParams.length === 0) { + context.report({ + node: firstArg, + messageId: 'arrowFunctionWithoutParams', + data: { + hookName, + }, + fix(fixer) { + // Simple case: no arguments to the hook + if (hookCall.arguments.length === 0) { + return fixer.replaceText(firstArg, hookName); + } + + // Complex case: hook has arguments that should become initialProps + const hookArgs = hookCall.arguments.map(arg => + context.sourceCode.getText(arg) + ); + + // Format initialProps value + // Single argument: initialProps: foo + // Multiple arguments: initialProps: [foo, bar] + const initialPropsValue = + hookArgs.length === 1 ? hookArgs[0] : `[${hookArgs.join(', ')}]`; + + const secondArg = node.arguments[1]; + + if (!secondArg) { + // No second argument exists, create one + return [ + fixer.replaceText(firstArg, hookName), + fixer.insertTextAfter( + firstArg, + `, {initialProps: ${initialPropsValue}}` + ), + ]; + } + if (secondArg.type === 'ObjectExpression') { + // Second argument is an object, check if initialProps already exists + const hasInitialProps = secondArg.properties.some( + prop => + prop.type === 'Property' && + prop.key.type === 'Identifier' && + prop.key.name === 'initialProps' + ); + + if (!hasInitialProps) { + // Add initialProps to the object + const lastProp = secondArg.properties[secondArg.properties.length - 1]; + return [ + fixer.replaceText(firstArg, hookName), + lastProp + ? fixer.insertTextAfter( + lastProp, + `, initialProps: ${initialPropsValue}` + ) + : fixer.insertTextAfterRange( + [secondArg.range[0], secondArg.range[0] + 1], + `initialProps: ${initialPropsValue}, ` + ), + ]; + } + } + + // Can't auto-fix if we can't determine how to handle existing second argument + return fixer.replaceText(firstArg, hookName); + }, + }); + return; + } + + // If the arrow function has parameters, check if they're actually used + const arrowParamNames = arrowParams + .map(param => { + if (param.type === 'Identifier') { + return param.name; + } + return null; + }) + .filter(Boolean); + + // Check if any of the arrow function parameters are used in the hook call + const usesArrowParams = hookCall.arguments.some(arg => { + return containsIdentifier(arg, arrowParamNames); + }); + + // If the arrow function parameters are used in the hook call, this is the correct pattern + // e.g., renderHook(p => useHotkeys(p), {initialProps: [...]}) + if (usesArrowParams) { + return; + } + + // If we get here, the arrow function has parameters but doesn't use them + // This is the incorrect pattern + const hookArgs = hookCall.arguments.map(arg => context.sourceCode.getText(arg)); + const propsText = hookArgs.length > 0 ? hookArgs.join(', ') : '...'; + + context.report({ + node: firstArg, + messageId: 'unnecessaryArrowFunction', + data: { + hookName, + props: propsText, + }, + fix(fixer) { + // Same fix logic as above + if (hookCall.arguments.length === 0) { + return fixer.replaceText(firstArg, hookName); + } + + const hookArgsForFix = hookCall.arguments.map(arg => + context.sourceCode.getText(arg) + ); + const initialPropsValue = + hookArgsForFix.length === 1 + ? hookArgsForFix[0] + : `[${hookArgsForFix.join(', ')}]`; + + const secondArg = node.arguments[1]; + + if (!secondArg) { + return [ + fixer.replaceText(firstArg, hookName), + fixer.insertTextAfter(firstArg, `, {initialProps: ${initialPropsValue}}`), + ]; + } + + return fixer.replaceText(firstArg, hookName); + }, + }); + }, + }; + }, +}; + +/** + * Check if an AST node contains an identifier with one of the given names + */ +function containsIdentifier(node, names) { + if (!node) return false; + + if (node.type === 'Identifier') { + return names.includes(node.name); + } + + // Recursively check all properties of the node + for (const key in node) { + if (key === 'parent' || key === 'loc' || key === 'range') continue; + + const value = node[key]; + + if (Array.isArray(value)) { + if (value.some(item => containsIdentifier(item, names))) { + return true; + } + } else if (value && typeof value === 'object') { + if (containsIdentifier(value, names)) { + return true; + } + } + } + + return false; +} + +export default noRenderHookArrowFunction; diff --git a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts new file mode 100644 index 00000000000000..c97d2df0ec0ef5 --- /dev/null +++ b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts @@ -0,0 +1,107 @@ +import {RuleTester} from 'eslint'; + +import noRenderHookArrowFunction from './no-renderHook-arrow-function.mjs'; + +const ruleTester = new RuleTester({ + languageOptions: { + ecmaVersion: 2022, + sourceType: 'module', + }, +}); + +ruleTester.run('no-renderHook-arrow-function', noRenderHookArrowFunction, { + valid: [ + { + code: 'renderHook(useMyHook)', + name: 'Hook passed directly without arguments', + }, + { + code: 'renderHook(useMyHook, {initialProps: props})', + name: 'Hook passed directly with initialProps', + }, + { + code: 'renderHook(p => useMyHook(p), {initialProps: props})', + name: 'Arrow function that uses its parameter (correct pattern)', + }, + { + code: 'renderHook((p) => useMyHook(p.foo), {initialProps: {foo: "bar"}})', + name: 'Arrow function that uses destructured parameter', + }, + { + code: 'renderHookWithProviders(useMyHook)', + name: 'renderHookWithProviders with hook passed directly', + }, + { + code: 'renderHookWithProviders(p => useMyHook(p), {initialProps: props})', + name: 'renderHookWithProviders with arrow function using parameter', + }, + ], + invalid: [ + { + code: 'renderHook(() => useMyHook())', + output: 'renderHook(useMyHook)', + errors: [ + { + messageId: 'arrowFunctionWithoutParams', + data: {hookName: 'useMyHook'}, + }, + ], + name: 'Arrow function with no parameters calling hook with no args', + }, + { + code: 'renderHook(() => useMyHook(props))', + output: 'renderHook(useMyHook, {initialProps: props})', + errors: [ + { + messageId: 'arrowFunctionWithoutParams', + data: {hookName: 'useMyHook'}, + }, + ], + name: 'Arrow function with no parameters calling hook with static args', + }, + { + code: 'renderHook(() => useMyHook(orgSlug), {wrapper})', + output: 'renderHook(useMyHook, {wrapper, initialProps: orgSlug})', + errors: [ + { + messageId: 'arrowFunctionWithoutParams', + data: {hookName: 'useMyHook'}, + }, + ], + name: 'Arrow function with hook call and existing options object', + }, + { + code: 'renderHookWithProviders(() => useMyHook(DemoTour.RELEASES))', + output: 'renderHookWithProviders(useMyHook, {initialProps: DemoTour.RELEASES})', + errors: [ + { + messageId: 'arrowFunctionWithoutParams', + data: {hookName: 'useMyHook'}, + }, + ], + name: 'renderHookWithProviders with arrow function', + }, + { + code: 'renderHook((props) => useMyHook(staticValue))', + output: 'renderHook(useMyHook, {initialProps: staticValue})', + errors: [ + { + messageId: 'unnecessaryArrowFunction', + data: {hookName: 'useMyHook', props: 'staticValue'}, + }, + ], + name: 'Arrow function with parameter but not using it', + }, + { + code: 'renderHook((_unused) => useMyHook(foo, bar))', + output: 'renderHook(useMyHook, {initialProps: [foo, bar]})', + errors: [ + { + messageId: 'unnecessaryArrowFunction', + data: {hookName: 'useMyHook', props: 'foo, bar'}, + }, + ], + name: 'Arrow function with unused parameter and multiple hook args', + }, + ], +}); From 084f5993f8aba0dee9be2134cc9ac9bbeafc60dc Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 16 Jan 2026 18:05:47 -0800 Subject: [PATCH 2/7] initial lint rule to remove extra wrappers at renderHook calls --- .../no-renderHook-arrow-function.mjs | 182 +++++++++++------- .../no-renderHook-arrow-function.spec.ts | 53 ++++- 2 files changed, 160 insertions(+), 75 deletions(-) diff --git a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs index e1d52297ae7bf8..66e85ca18c40df 100644 --- a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs +++ b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs @@ -78,77 +78,61 @@ const noRenderHookArrowFunction = { hookName, }, fix(fixer) { - // Simple case: no arguments to the hook + // Auto-fix when hook has zero arguments if (hookCall.arguments.length === 0) { return fixer.replaceText(firstArg, hookName); } - // Complex case: hook has arguments that should become initialProps - const hookArgs = hookCall.arguments.map(arg => - context.sourceCode.getText(arg) - ); + // Auto-fix when hook has exactly one argument + if (hookCall.arguments.length === 1) { + const hookArg = context.sourceCode.getText(hookCall.arguments[0]); + const secondArg = node.arguments[1]; - // Format initialProps value - // Single argument: initialProps: foo - // Multiple arguments: initialProps: [foo, bar] - const initialPropsValue = - hookArgs.length === 1 ? hookArgs[0] : `[${hookArgs.join(', ')}]`; - - const secondArg = node.arguments[1]; - - if (!secondArg) { - // No second argument exists, create one - return [ - fixer.replaceText(firstArg, hookName), - fixer.insertTextAfter( - firstArg, - `, {initialProps: ${initialPropsValue}}` - ), - ]; - } - if (secondArg.type === 'ObjectExpression') { - // Second argument is an object, check if initialProps already exists - const hasInitialProps = secondArg.properties.some( - prop => - prop.type === 'Property' && - prop.key.type === 'Identifier' && - prop.key.name === 'initialProps' - ); - - if (!hasInitialProps) { - // Add initialProps to the object - const lastProp = secondArg.properties[secondArg.properties.length - 1]; + if (!secondArg) { + // No second argument exists, create one return [ fixer.replaceText(firstArg, hookName), - lastProp - ? fixer.insertTextAfter( - lastProp, - `, initialProps: ${initialPropsValue}` - ) - : fixer.insertTextAfterRange( - [secondArg.range[0], secondArg.range[0] + 1], - `initialProps: ${initialPropsValue}, ` - ), + fixer.insertTextAfter(firstArg, `, {initialProps: ${hookArg}}`), ]; } + + if (secondArg.type === 'ObjectExpression') { + // Second argument is an object, check if initialProps already exists + const hasInitialProps = secondArg.properties.some( + prop => + prop.type === 'Property' && + prop.key.type === 'Identifier' && + prop.key.name === 'initialProps' + ); + + if (!hasInitialProps) { + // Add initialProps to the object + const lastProp = secondArg.properties[secondArg.properties.length - 1]; + return [ + fixer.replaceText(firstArg, hookName), + lastProp + ? fixer.insertTextAfter(lastProp, `, initialProps: ${hookArg}`) + : fixer.insertTextAfterRange( + [secondArg.range[0], secondArg.range[0] + 1], + `initialProps: ${hookArg}, ` + ), + ]; + } + } } - // Can't auto-fix if we can't determine how to handle existing second argument - return fixer.replaceText(firstArg, hookName); + // Don't auto-fix for multiple arguments - requires manual intervention + return null; }, }); return; } // If the arrow function has parameters, check if they're actually used - const arrowParamNames = arrowParams - .map(param => { - if (param.type === 'Identifier') { - return param.name; - } - return null; - }) - .filter(Boolean); + const arrowParamNames = []; + for (const param of arrowParams) { + extractIdentifierNames(param, arrowParamNames); + } // Check if any of the arrow function parameters are used in the hook call const usesArrowParams = hookCall.arguments.some(arg => { @@ -174,29 +158,51 @@ const noRenderHookArrowFunction = { props: propsText, }, fix(fixer) { - // Same fix logic as above + // Auto-fix when hook has zero arguments if (hookCall.arguments.length === 0) { return fixer.replaceText(firstArg, hookName); } - const hookArgsForFix = hookCall.arguments.map(arg => - context.sourceCode.getText(arg) - ); - const initialPropsValue = - hookArgsForFix.length === 1 - ? hookArgsForFix[0] - : `[${hookArgsForFix.join(', ')}]`; - - const secondArg = node.arguments[1]; - - if (!secondArg) { - return [ - fixer.replaceText(firstArg, hookName), - fixer.insertTextAfter(firstArg, `, {initialProps: ${initialPropsValue}}`), - ]; + // Auto-fix when hook has exactly one argument + if (hookCall.arguments.length === 1) { + const hookArg = context.sourceCode.getText(hookCall.arguments[0]); + const secondArg = node.arguments[1]; + + if (!secondArg) { + // No second argument exists, create one + return [ + fixer.replaceText(firstArg, hookName), + fixer.insertTextAfter(firstArg, `, {initialProps: ${hookArg}}`), + ]; + } + + if (secondArg.type === 'ObjectExpression') { + // Second argument is an object, check if initialProps already exists + const hasInitialProps = secondArg.properties.some( + prop => + prop.type === 'Property' && + prop.key.type === 'Identifier' && + prop.key.name === 'initialProps' + ); + + if (!hasInitialProps) { + // Add initialProps to the object + const lastProp = secondArg.properties[secondArg.properties.length - 1]; + return [ + fixer.replaceText(firstArg, hookName), + lastProp + ? fixer.insertTextAfter(lastProp, `, initialProps: ${hookArg}`) + : fixer.insertTextAfterRange( + [secondArg.range[0], secondArg.range[0] + 1], + `initialProps: ${hookArg}, ` + ), + ]; + } + } } - return fixer.replaceText(firstArg, hookName); + // Don't auto-fix for multiple arguments - requires manual intervention + return null; }, }); }, @@ -204,6 +210,40 @@ const noRenderHookArrowFunction = { }, }; +/** + * Extract all identifier names from a parameter pattern + * Handles simple identifiers, object destructuring, and array destructuring + */ +function extractIdentifierNames(param, names) { + if (!param) return; + + if (param.type === 'Identifier') { + names.push(param.name); + } else if (param.type === 'ObjectPattern') { + // Handle object destructuring like {fact, dep} or {a: b, c} + for (const prop of param.properties) { + if (prop.type === 'Property') { + extractIdentifierNames(prop.value, names); + } else if (prop.type === 'RestElement') { + extractIdentifierNames(prop.argument, names); + } + } + } else if (param.type === 'ArrayPattern') { + // Handle array destructuring like [a, b] + for (const element of param.elements) { + if (element) { + extractIdentifierNames(element, names); + } + } + } else if (param.type === 'RestElement') { + // Handle rest parameters like ...rest + extractIdentifierNames(param.argument, names); + } else if (param.type === 'AssignmentPattern') { + // Handle default parameters like a = 5 + extractIdentifierNames(param.left, names); + } +} + /** * Check if an AST node contains an identifier with one of the given names */ diff --git a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts index c97d2df0ec0ef5..a3007c5e904a34 100644 --- a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts +++ b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts @@ -35,6 +35,18 @@ ruleTester.run('no-renderHook-arrow-function', noRenderHookArrowFunction, { code: 'renderHookWithProviders(p => useMyHook(p), {initialProps: props})', name: 'renderHookWithProviders with arrow function using parameter', }, + { + code: 'renderHook(({fact, dep}) => useMemoWithPrevious(fact, [dep]), {initialProps: {fact: factory, dep: firstDep}})', + name: 'Arrow function with destructured object parameters that are used', + }, + { + code: 'renderHook(([a, b]) => useMyHook(a, b), {initialProps: [1, 2]})', + name: 'Arrow function with destructured array parameters that are used', + }, + { + code: 'renderHook(({a: renamed}) => useMyHook(renamed), {initialProps: {a: value}})', + name: 'Arrow function with renamed destructured parameter that is used', + }, ], invalid: [ { @@ -46,7 +58,7 @@ ruleTester.run('no-renderHook-arrow-function', noRenderHookArrowFunction, { data: {hookName: 'useMyHook'}, }, ], - name: 'Arrow function with no parameters calling hook with no args', + name: 'Arrow function with no parameters calling hook with no args (auto-fixable)', }, { code: 'renderHook(() => useMyHook(props))', @@ -57,7 +69,7 @@ ruleTester.run('no-renderHook-arrow-function', noRenderHookArrowFunction, { data: {hookName: 'useMyHook'}, }, ], - name: 'Arrow function with no parameters calling hook with static args', + name: 'Arrow function with no parameters calling hook with single arg', }, { code: 'renderHook(() => useMyHook(orgSlug), {wrapper})', @@ -94,14 +106,47 @@ ruleTester.run('no-renderHook-arrow-function', noRenderHookArrowFunction, { }, { code: 'renderHook((_unused) => useMyHook(foo, bar))', - output: 'renderHook(useMyHook, {initialProps: [foo, bar]})', + output: null, // Can't auto-fix multiple arguments errors: [ { messageId: 'unnecessaryArrowFunction', data: {hookName: 'useMyHook', props: 'foo, bar'}, }, ], - name: 'Arrow function with unused parameter and multiple hook args', + name: 'Arrow function with unused parameter and multiple hook args (no auto-fix)', + }, + { + code: 'renderHook((props) => useMyHook(value), {wrapper})', + output: 'renderHook(useMyHook, {wrapper, initialProps: value})', + errors: [ + { + messageId: 'unnecessaryArrowFunction', + data: {hookName: 'useMyHook', props: 'value'}, + }, + ], + name: 'Arrow function with unused parameter and existing options object', + }, + { + code: 'renderHook((p) => useMyHook(a, b), {wrapper, otherOption: true})', + output: null, // Can't auto-fix multiple arguments + errors: [ + { + messageId: 'unnecessaryArrowFunction', + data: {hookName: 'useMyHook', props: 'a, b'}, + }, + ], + name: 'Arrow function with unused parameter, multiple args, and existing options (no auto-fix)', + }, + { + code: 'renderHook(() => useMyHook(a, b))', + output: null, // Can't auto-fix multiple arguments + errors: [ + { + messageId: 'arrowFunctionWithoutParams', + data: {hookName: 'useMyHook'}, + }, + ], + name: 'Arrow function with no params calling hook with multiple args (no auto-fix)', }, ], }); From d29691caba3caeedbfd552493c01bdd86185f6ca Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Sat, 17 Jan 2026 14:32:25 -0800 Subject: [PATCH 3/7] handle cases where the hook should be a component actually --- .../no-renderHook-arrow-function.mjs | 315 ++++++++++++++++-- .../no-renderHook-arrow-function.spec.ts | 106 ++++++ 2 files changed, 400 insertions(+), 21 deletions(-) diff --git a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs index 66e85ca18c40df..f458ee48282b6c 100644 --- a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs +++ b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.mjs @@ -1,5 +1,86 @@ const RENDER_HOOK_FNS = ['renderHook', 'renderHookWithProviders']; +/** + * Type guard to check if a node is an Identifier + * @param {import('estree').Node | null | undefined} node + * @returns {node is import('estree').Identifier} + */ +function isIdentifier(node) { + return node?.type === 'Identifier'; +} + +/** + * Type guard to check if a node is a CallExpression + * @param {import('estree').Node | null | undefined} node + * @returns {node is import('estree').CallExpression} + */ +function isCallExpression(node) { + return node?.type === 'CallExpression'; +} + +/** + * Type guard to check if a node is an ObjectExpression + * @param {import('estree').Node | null | undefined} node + * @returns {node is import('estree').ObjectExpression} + */ +function isObjectExpression(node) { + return node?.type === 'ObjectExpression'; +} + +/** + * Type guard to check if a node is a BlockStatement + * @param {import('estree').Node | null | undefined} node + * @returns {node is import('estree').BlockStatement} + */ +function isBlockStatement(node) { + return node?.type === 'BlockStatement'; +} + +/** + * Type guard to check if a node is a ReturnStatement + * @param {import('estree').Statement} node + * @returns {node is import('estree').ReturnStatement} + */ +function isReturnStatement(node) { + return node.type === 'ReturnStatement'; +} + +/** + * Type guard to check if a node is a MemberExpression + * @param {import('estree').Node | null | undefined} node + * @returns {node is import('estree').MemberExpression} + */ +function isMemberExpression(node) { + return node?.type === 'MemberExpression'; +} + +/** + * Type guard to check if a Property has an Identifier key + * @param {import('estree').Property | import('estree').SpreadElement} prop + * @returns {prop is import('estree').Property & {key: import('estree').Identifier}} + */ +function isPropertyWithIdentifierKey(prop) { + return prop.type === 'Property' && prop.key.type === 'Identifier'; +} + +/** + * Type guard to check if a node is an ImportDeclaration + * @param {import('estree').ModuleDeclaration | import('estree').Statement | import('estree').Directive} node + * @returns {node is import('estree').ImportDeclaration} + */ +function isImportDeclaration(node) { + return node.type === 'ImportDeclaration'; +} + +/** + * Type guard to check if an import specifier is an ImportSpecifier with Identifier imported name + * @param {import('estree').ImportSpecifier | import('estree').ImportDefaultSpecifier | import('estree').ImportNamespaceSpecifier} spec + * @returns {spec is import('estree').ImportSpecifier & {imported: import('estree').Identifier}} + */ +function isImportSpecifierWithIdentifier(spec) { + return spec.type === 'ImportSpecifier' && spec.imported.type === 'Identifier'; +} + /** * @type {import('eslint').Rule.RuleModule} */ @@ -17,21 +98,32 @@ const noRenderHookArrowFunction = { 'Pass the hook directly and use initialProps for arguments: renderHook({{hookName}}, {initialProps: {{props}}})', arrowFunctionWithoutParams: 'Pass the hook directly instead of wrapping it in an arrow function: renderHook({{hookName}})', + useComponentRenderInstead: + 'Convert to a component render() test instead of using renderHook() with multiple statements', }, fixable: 'code', }, + /** + * @param {import('eslint').Rule.RuleContext} context + * @returns {import('eslint').Rule.RuleListener} + */ create(context) { return { + /** + * @param {import('estree').CallExpression} node + */ + // @ts-expect-error - Type mismatch between estree versions (ESLint adds NodeParentExtension) CallExpression(node) { const callee = node.callee; // Check if it's renderHook or renderHookWithProviders - if (!callee || callee.type !== 'Identifier') return; + if (!isIdentifier(callee)) return; if (!RENDER_HOOK_FNS.includes(callee.name)) return; if (node.arguments.length === 0) return; const firstArg = node.arguments[0]; + if (!firstArg) return; // Check if the first argument is an arrow function if (firstArg.type !== 'ArrowFunctionExpression') return; @@ -42,27 +134,112 @@ const noRenderHookArrowFunction = { // Get the body of the arrow function let body = arrowFn.body; - // If body is a block statement, get the return statement - if (body.type === 'BlockStatement') { - const returnStatement = body.body.find(stmt => stmt.type === 'ReturnStatement'); + // If body is a block statement, check for multiple statements + if (isBlockStatement(body)) { + // Count non-return statements + const nonReturnStatements = body.body.filter(stmt => !isReturnStatement(stmt)); + + // If there are multiple statements (besides the return), suggest component render + if (nonReturnStatements.length > 0) { + context.report({ + node: firstArg, + messageId: 'useComponentRenderInstead', + /** + * @param {import('eslint').Rule.RuleFixer} fixer + * @returns {import('eslint').Rule.Fix[]} + */ + fix(fixer) { + // Generate a unique component name based on the hook name if we can find it + // @ts-expect-error - body is narrowed to BlockStatement but TS doesn't recognize it + const returnStatement = body.body.find(isReturnStatement); + let componentName = 'TestComponent'; + + if (isCallExpression(returnStatement?.argument)) { + const hookCallee = returnStatement.argument.callee; + if (isIdentifier(hookCallee)) { + // Convert useMyHook -> MyHook + componentName = hookCallee.name.replace(/^use/, ''); + } + } + + // Get the entire renderHook call statement for proper indentation + const renderHookCallNode = node; + const sourceCode = context.sourceCode; + + // Find the statement node that contains the renderHook call + let statementNode = renderHookCallNode; + // @ts-expect-error - parent property exists on ESLint AST nodes + while (statementNode.parent && statementNode.parent.type !== 'Program') { + // @ts-expect-error - parent property exists on ESLint AST nodes + if (statementNode.parent.type === 'ExpressionStatement') { + // @ts-expect-error - parent property exists on ESLint AST nodes + statementNode = statementNode.parent; + break; + } + // @ts-expect-error - parent property exists on ESLint AST nodes + statementNode = statementNode.parent; + } + + // Get the indentation of the current line + const lineStart = sourceCode.getIndexFromLoc({ + // @ts-expect-error - statementNode.loc could be null but we verify it exists + line: statementNode.loc.start.line, + column: 0, + }); + // @ts-expect-error - statementNode.range could be undefined but we verify it exists + const statementStart = statementNode.range[0]; + const indentation = sourceCode.text.slice(lineStart, statementStart); + + // Extract statements from the body and rebuild with correct indentation + // @ts-expect-error - body is narrowed to BlockStatement but TS doesn't recognize it + const bodyStatements = body.body.map(stmt => { + const stmtText = sourceCode.getText(stmt); + return `${indentation} ${stmtText}`; + }); + + // Build the component function + const componentDef = `function ${componentName}() {\n${bodyStatements.join('\n')}\n${indentation}}\n${indentation}`; + + // Replace the entire renderHook call with render call + const renderCall = `render(<${componentName} />)`; + + const fixes = [ + // @ts-expect-error - Type mismatch between estree versions + fixer.insertTextBefore(statementNode, componentDef), + // @ts-expect-error - Type mismatch between estree versions + fixer.replaceText(renderHookCallNode, renderCall), + ]; + + // Check if we need to add the render import + const importFix = ensureRenderImport(context, sourceCode, fixer); + if (importFix) { + fixes.unshift(importFix); + } + + return fixes; + }, + }); + return; + } + + // Single statement block - get the return statement + const returnStatement = body.body.find(isReturnStatement); if (!returnStatement?.argument) return; body = returnStatement.argument; } // Check if the body is a call expression (calling a hook) - if (body.type !== 'CallExpression') return; + if (!isCallExpression(body)) return; const hookCall = body; const hookCallee = hookCall.callee; // Get the hook name let hookName = ''; - if (hookCallee.type === 'Identifier') { + if (isIdentifier(hookCallee)) { hookName = hookCallee.name; - } else if ( - hookCallee.type === 'MemberExpression' && - hookCallee.property.type === 'Identifier' - ) { + } else if (isMemberExpression(hookCallee) && isIdentifier(hookCallee.property)) { + // @ts-expect-error - Type mismatch between estree versions hookName = context.sourceCode.getText(hookCallee); } else { return; @@ -77,42 +254,53 @@ const noRenderHookArrowFunction = { data: { hookName, }, + /** + * @param {import('eslint').Rule.RuleFixer} fixer + * @returns {import('eslint').Rule.Fix | import('eslint').Rule.Fix[] | null} + */ fix(fixer) { // Auto-fix when hook has zero arguments if (hookCall.arguments.length === 0) { + // @ts-expect-error - Type mismatch between estree versions return fixer.replaceText(firstArg, hookName); } // Auto-fix when hook has exactly one argument if (hookCall.arguments.length === 1) { + // @ts-expect-error - Type mismatch between estree versions const hookArg = context.sourceCode.getText(hookCall.arguments[0]); const secondArg = node.arguments[1]; if (!secondArg) { // No second argument exists, create one return [ + // @ts-expect-error - Type mismatch between estree versions fixer.replaceText(firstArg, hookName), + // @ts-expect-error - Type mismatch between estree versions fixer.insertTextAfter(firstArg, `, {initialProps: ${hookArg}}`), ]; } - if (secondArg.type === 'ObjectExpression') { + if (isObjectExpression(secondArg)) { // Second argument is an object, check if initialProps already exists const hasInitialProps = secondArg.properties.some( prop => - prop.type === 'Property' && - prop.key.type === 'Identifier' && + isPropertyWithIdentifierKey(prop) && prop.key.name === 'initialProps' ); if (!hasInitialProps) { // Add initialProps to the object - const lastProp = secondArg.properties[secondArg.properties.length - 1]; + const lastProp = + secondArg.properties[secondArg.properties.length - 1]; return [ + // @ts-expect-error - Type mismatch between estree versions fixer.replaceText(firstArg, hookName), lastProp - ? fixer.insertTextAfter(lastProp, `, initialProps: ${hookArg}`) + ? // @ts-expect-error - Type mismatch between estree versions + fixer.insertTextAfter(lastProp, `, initialProps: ${hookArg}`) : fixer.insertTextAfterRange( + // @ts-expect-error - range could be undefined but we verify it exists [secondArg.range[0], secondArg.range[0] + 1], `initialProps: ${hookArg}, ` ), @@ -129,6 +317,7 @@ const noRenderHookArrowFunction = { } // If the arrow function has parameters, check if they're actually used + /** @type {string[]} */ const arrowParamNames = []; for (const param of arrowParams) { extractIdentifierNames(param, arrowParamNames); @@ -147,7 +336,10 @@ const noRenderHookArrowFunction = { // If we get here, the arrow function has parameters but doesn't use them // This is the incorrect pattern - const hookArgs = hookCall.arguments.map(arg => context.sourceCode.getText(arg)); + const hookArgs = hookCall.arguments.map(arg => + // @ts-expect-error - Type mismatch between estree versions + context.sourceCode.getText(arg) + ); const propsText = hookArgs.length > 0 ? hookArgs.join(', ') : '...'; context.report({ @@ -157,42 +349,51 @@ const noRenderHookArrowFunction = { hookName, props: propsText, }, + /** + * @param {import('eslint').Rule.RuleFixer} fixer + * @returns {import('eslint').Rule.Fix | import('eslint').Rule.Fix[] | null} + */ fix(fixer) { // Auto-fix when hook has zero arguments if (hookCall.arguments.length === 0) { + // @ts-expect-error - Type mismatch between estree versions return fixer.replaceText(firstArg, hookName); } // Auto-fix when hook has exactly one argument if (hookCall.arguments.length === 1) { + // @ts-expect-error - Type mismatch between estree versions const hookArg = context.sourceCode.getText(hookCall.arguments[0]); const secondArg = node.arguments[1]; if (!secondArg) { // No second argument exists, create one return [ + // @ts-expect-error - Type mismatch between estree versions fixer.replaceText(firstArg, hookName), + // @ts-expect-error - Type mismatch between estree versions fixer.insertTextAfter(firstArg, `, {initialProps: ${hookArg}}`), ]; } - if (secondArg.type === 'ObjectExpression') { + if (isObjectExpression(secondArg)) { // Second argument is an object, check if initialProps already exists const hasInitialProps = secondArg.properties.some( prop => - prop.type === 'Property' && - prop.key.type === 'Identifier' && - prop.key.name === 'initialProps' + isPropertyWithIdentifierKey(prop) && prop.key.name === 'initialProps' ); if (!hasInitialProps) { // Add initialProps to the object const lastProp = secondArg.properties[secondArg.properties.length - 1]; return [ + // @ts-expect-error - Type mismatch between estree versions fixer.replaceText(firstArg, hookName), lastProp - ? fixer.insertTextAfter(lastProp, `, initialProps: ${hookArg}`) + ? // @ts-expect-error - Type mismatch between estree versions + fixer.insertTextAfter(lastProp, `, initialProps: ${hookArg}`) : fixer.insertTextAfterRange( + // @ts-expect-error - range could be undefined but we verify it exists [secondArg.range[0], secondArg.range[0] + 1], `initialProps: ${hookArg}, ` ), @@ -213,6 +414,9 @@ const noRenderHookArrowFunction = { /** * Extract all identifier names from a parameter pattern * Handles simple identifiers, object destructuring, and array destructuring + * @param {import('estree').Pattern | null | undefined} param - The parameter pattern to extract from + * @param {string[]} names - Array to collect identifier names into + * @returns {void} */ function extractIdentifierNames(param, names) { if (!param) return; @@ -246,6 +450,9 @@ function extractIdentifierNames(param, names) { /** * Check if an AST node contains an identifier with one of the given names + * @param {import('estree').Node | null | undefined} node - The AST node to check + * @param {string[]} names - Array of identifier names to look for + * @returns {boolean} True if any of the names are found in the node tree */ function containsIdentifier(node, names) { if (!node) return false; @@ -258,6 +465,7 @@ function containsIdentifier(node, names) { for (const key in node) { if (key === 'parent' || key === 'loc' || key === 'range') continue; + // @ts-expect-error - Dynamic property access on AST node const value = node[key]; if (Array.isArray(value)) { @@ -274,4 +482,69 @@ function containsIdentifier(node, names) { return false; } +/** + * Ensure that 'render' is imported from 'sentry-test/reactTestingLibrary' + * Returns a Fix object if an import needs to be added, null otherwise + * @param {import('eslint').Rule.RuleContext} _context - The rule context + * @param {import('eslint').SourceCode} sourceCode - The source code object + * @param {import('eslint').Rule.RuleFixer} fixer - The fixer object + * @returns {import('eslint').Rule.Fix | null} A fix to add the import, or null if not needed + */ +function ensureRenderImport(_context, sourceCode, fixer) { + const TESTING_LIBRARY_MODULE = 'sentry-test/reactTestingLibrary'; + const ast = sourceCode.ast; + + // Find all import declarations + // @ts-expect-error - Type guard should narrow but type system doesn't recognize it + const imports = ast.body.filter(isImportDeclaration); + + // Check if there's already an import from sentry-test/reactTestingLibrary + const testingLibraryImport = imports.find( + node => node.source.value === TESTING_LIBRARY_MODULE + ); + + if (testingLibraryImport) { + // Check if 'render' is already imported + const hasRenderImport = testingLibraryImport.specifiers.some( + spec => isImportSpecifierWithIdentifier(spec) && spec.imported.name === 'render' + ); + + if (hasRenderImport) { + // Already imported, no fix needed + return null; + } + + // Add 'render' to the existing import + // Find the last specifier to add after it + const lastSpecifier = + testingLibraryImport.specifiers[testingLibraryImport.specifiers.length - 1]; + + if (lastSpecifier) { + return fixer.insertTextAfter(lastSpecifier, ', render'); + } + } + + // No import from sentry-test/reactTestingLibrary exists, create a new one + // Find the position to insert (after the last import, or at the beginning) + const lastImport = imports[imports.length - 1]; + + if (lastImport) { + return fixer.insertTextAfter( + lastImport, + `\nimport {render} from '${TESTING_LIBRARY_MODULE}';` + ); + } + + // No imports at all, insert at the beginning of the file + const firstNode = ast.body[0]; + if (firstNode) { + return fixer.insertTextBefore( + firstNode, + `import {render} from '${TESTING_LIBRARY_MODULE}';\n\n` + ); + } + + return null; +} + export default noRenderHookArrowFunction; diff --git a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts index a3007c5e904a34..4e3bd28afae0f6 100644 --- a/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts +++ b/static/eslint/eslintPluginSentry/no-renderHook-arrow-function.spec.ts @@ -6,6 +6,11 @@ const ruleTester = new RuleTester({ languageOptions: { ecmaVersion: 2022, sourceType: 'module', + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + }, }, }); @@ -148,5 +153,106 @@ ruleTester.run('no-renderHook-arrow-function', noRenderHookArrowFunction, { ], name: 'Arrow function with no params calling hook with multiple args (no auto-fix)', }, + { + code: `renderHook(() => { + const x = 1; + const y = 2; + return useMyHook(x + y); +})`, + output: `import {render} from 'sentry-test/reactTestingLibrary'; + +function MyHook() { + const x = 1; + const y = 2; + return useMyHook(x + y); +} +render()`, + errors: [ + { + messageId: 'useComponentRenderInstead', + }, + ], + name: 'Arrow function with multiple statements should convert to component render', + }, + { + code: `renderHook(() => { + const value = 123; + return useMyHook(value); +})`, + output: `import {render} from 'sentry-test/reactTestingLibrary'; + +function MyHook() { + const value = 123; + return useMyHook(value); +} +render()`, + errors: [ + { + messageId: 'useComponentRenderInstead', + }, + ], + name: 'Arrow function with single variable declaration should convert to component render', + }, + { + code: `renderHookWithProviders(() => { + const state = useState(); + return useMyHook(state); +})`, + output: `import {render} from 'sentry-test/reactTestingLibrary'; + +function MyHook() { + const state = useState(); + return useMyHook(state); +} +render()`, + errors: [ + { + messageId: 'useComponentRenderInstead', + }, + ], + name: 'renderHookWithProviders with multiple statements should convert to component render', + }, + { + code: `import {screen, userEvent} from 'sentry-test/reactTestingLibrary'; + +renderHook(() => { + const value = 123; + return useMyHook(value); +})`, + output: `import {screen, userEvent, render} from 'sentry-test/reactTestingLibrary'; + +function MyHook() { + const value = 123; + return useMyHook(value); +} +render()`, + errors: [ + { + messageId: 'useComponentRenderInstead', + }, + ], + name: 'Should add render to existing import from sentry-test/reactTestingLibrary', + }, + { + code: `import {render} from 'sentry-test/reactTestingLibrary'; + +renderHook(() => { + const value = 123; + return useMyHook(value); +})`, + output: `import {render} from 'sentry-test/reactTestingLibrary'; + +function MyHook() { + const value = 123; + return useMyHook(value); +} +render()`, + errors: [ + { + messageId: 'useComponentRenderInstead', + }, + ], + name: 'Should not duplicate render import if already present', + }, ], }); From 8a471c26a3d12cbe0cd8f80f65129a8fe39b198a Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Sat, 17 Jan 2026 15:13:55 -0800 Subject: [PATCH 4/7] apply lint fixes --- .../app/actionCreators/savedSearches.spec.tsx | 7 +- .../app/bootstrap/boostrapRequests.spec.tsx | 22 +-- static/app/components/acl/useRole.spec.tsx | 16 +-- .../charts/useChartXRangeSelection.spec.tsx | 70 ++++------ .../components/core/layout/styles.spec.tsx | 44 +++--- .../components/core/renderToString.spec.tsx | 4 +- .../useMutateOnboardingTasks.spec.tsx | 2 +- .../app/components/prevent/summary.spec.tsx | 16 +-- .../useIsOverflowing.spec.tsx | 6 +- .../useSyncScrollMargin.spec.ts | 5 +- .../useSyncWrapperWidth.spec.ts | 4 +- .../replays/replayLiveIndicator.spec.tsx | 45 +++---- .../searchQueryBuilder/hooks.spec.tsx | 9 +- .../workflowEngine/form/useFormField.spec.tsx | 20 +-- static/app/utils/api/apiOptions.spec.tsx | 7 +- static/app/utils/demoMode/demoTours.spec.tsx | 22 +-- .../list/useListItemCheckboxState.spec.ts | 21 +-- .../hooks/useProfileFunctionTrends.spec.tsx | 14 +- .../hooks/useProfileFunctions.spec.tsx | 10 +- .../utils/url/urlParamBatchContext.spec.tsx | 2 +- .../app/utils/url/useQueryParamState.spec.tsx | 33 +++-- static/app/utils/useIsMountedRef.spec.tsx | 19 +-- static/app/utils/useIsSentryEmployee.spec.tsx | 6 +- .../app/utils/useLocalStorageState.spec.tsx | 8 +- static/app/utils/useMaxPickableDays.spec.tsx | 39 +++--- .../app/utils/useUpdateOrganization.spec.tsx | 8 +- static/app/utils/useUserTeams.spec.tsx | 2 +- .../hooks/useCacheBuilderState.spec.tsx | 6 +- .../hooks/useWidgetBuilderState.spec.tsx | 126 +++++++++--------- .../hooks/useMetricDetectorAnomalies.spec.tsx | 5 +- .../useMetricDetectorAnomalyPeriods.spec.tsx | 5 +- ...seMetricDetectorAnomalyThresholds.spec.tsx | 28 ++-- .../hooks/useCrossEventQueries.spec.tsx | 10 +- .../hooks/useExploreAggregatesTable.spec.tsx | 20 ++- .../hooks/useExploreSpansTable.spec.tsx | 18 ++- .../hooks/useExploreTimeseries.spec.tsx | 18 ++- .../useGetTraceItemAttributeValues.spec.tsx | 10 +- .../hooks/useProgressiveQuery.spec.tsx | 10 +- .../explore/hooks/useSortByFields.spec.tsx | 18 ++- .../hooks/useTraceItemAttributeKeys.spec.tsx | 20 ++- .../explore/hooks/useVisualizeFields.spec.tsx | 12 +- .../logs/useLogsAggregatesTable.spec.tsx | 7 +- .../views/explore/logs/useLogsQuery.spec.tsx | 24 ++-- .../explore/logs/useLogsTimeseries.spec.tsx | 7 +- .../explore/logs/useSaveAsItems.spec.tsx | 28 ++-- .../explore/logs/useVirtualStreaming.spec.tsx | 20 +-- .../hooks/useMetricAggregatesTable.spec.tsx | 9 +- .../hooks/useMetricSamplesTable.spec.tsx | 18 ++- .../hooks/useMetricTimeseries.spec.tsx | 9 +- .../metrics/multiMetricsQueryParams.spec.tsx | 6 +- .../metrics/useSaveAsMetricItems.spec.tsx | 28 ++-- .../hooks/useMultiQueryTable.spec.tsx | 5 +- .../hooks/useMultiQueryTimeseries.spec.tsx | 5 +- .../explore/queryParams/context.spec.tsx | 18 ++- .../agents/hooks/useTableCursor.spec.tsx | 12 +- .../streamline/hooks/useEventQuery.spec.tsx | 6 +- .../views/onboarding/useConfigureSdk.spec.tsx | 8 +- .../traceApi/useTrace.spec.tsx | 10 +- .../traceApi/useTraceMeta.spec.tsx | 16 +-- .../traceApi/useTraceTree.spec.tsx | 28 ++-- .../useGetActiveIntegratedOrgs.spec.tsx | 12 +- .../tests/queries/useGetTestResults.spec.tsx | 27 ++-- .../prevent/tests/queries/useRepo.spec.tsx | 4 +- .../useInfiniteRepositoryTokens.spec.tsx | 55 ++++---- .../useRegenerateRepositoryToken.spec.tsx | 6 +- .../detail/ai/useReplaySummary.spec.tsx | 28 ++-- .../detail/trace/useReplayTraces.spec.tsx | 4 +- .../hooks/useBlockNavigation.spec.tsx | 32 ++--- .../hooks/useSeerExplorer.spec.tsx | 14 +- static/gsAdmin/views/customerDetails.spec.tsx | 16 +-- static/gsApp/hooks/dashboardsLimit.spec.tsx | 16 +-- static/gsApp/hooks/genAiAccess.spec.tsx | 24 ++-- .../gsApp/hooks/useMaxPickableDays.spec.tsx | 100 ++++++-------- .../hooks/useMetricDetectorLimit.spec.tsx | 12 +- .../hooks/useProductBillingAccess.spec.tsx | 20 +-- 75 files changed, 643 insertions(+), 758 deletions(-) diff --git a/static/app/actionCreators/savedSearches.spec.tsx b/static/app/actionCreators/savedSearches.spec.tsx index 4781c141f9dabb..eebb6a24366807 100644 --- a/static/app/actionCreators/savedSearches.spec.tsx +++ b/static/app/actionCreators/savedSearches.spec.tsx @@ -36,12 +36,11 @@ describe('useFetchRecentSearches', () => { }); const {result} = renderHookWithProviders( - () => - useFetchRecentSearches({ + useFetchRecentSearches, + {organization, initialProps: { savedSearchType: SavedSearchType.TRACEMETRIC, namespace, - }), - {organization} + }} ); await waitFor(() => expect(result.current.isSuccess).toBe(true)); diff --git a/static/app/bootstrap/boostrapRequests.spec.tsx b/static/app/bootstrap/boostrapRequests.spec.tsx index 513364952825a0..ad3c6aadb43107 100644 --- a/static/app/bootstrap/boostrapRequests.spec.tsx +++ b/static/app/bootstrap/boostrapRequests.spec.tsx @@ -49,7 +49,7 @@ describe('useBootstrapOrganizationQuery', () => { query: {detailed: 0, include_feature_flags: 1}, }); - const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.data).toBeDefined()); expect(JSON.stringify(OrganizationStore.get().organization)).toEqual( @@ -64,7 +64,7 @@ describe('useBootstrapOrganizationQuery', () => { body: {}, }); - const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.error).toBeDefined()); expect(OrganizationStore.get().organization).toBeNull(); @@ -75,7 +75,7 @@ describe('useBootstrapOrganizationQuery', () => { }); it('does not fetch when orgSlug is null', () => { - const {result} = renderHook(() => useBootstrapOrganizationQuery(null), {wrapper}); + const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: null}); expect(result.current.data).toBeUndefined(); }); @@ -84,7 +84,7 @@ describe('useBootstrapOrganizationQuery', () => { orgSlug: org.slug, organization: Promise.resolve>([org, undefined, undefined]), }; - const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.data).toBeDefined()); expect(window.__sentry_preload?.organization).toBeUndefined(); }); @@ -105,7 +105,7 @@ describe('useBootstrapOrganizationQuery', () => { query: {detailed: 0, include_feature_flags: 1}, }); - const {result} = renderHook(() => useBootstrapOrganizationQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.data).toBeDefined()); expect(JSON.stringify(OrganizationStore.get().organization?.features)).toEqual( JSON.stringify(['enable-issues']) @@ -141,7 +141,7 @@ describe('useBootstrapTeamsQuery', () => { }, }); - const {result} = renderHook(() => useBootstrapTeamsQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.data).toBeDefined()); expect(TeamStore.getState().teams).toEqual(mockTeams); @@ -154,14 +154,14 @@ describe('useBootstrapTeamsQuery', () => { statusCode: 500, }); - const {result} = renderHook(() => useBootstrapTeamsQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.error).toBeDefined()); expect(TeamStore.getState().teams).toEqual([]); }); it('does not fetch when orgSlug is null', () => { - const {result} = renderHook(() => useBootstrapTeamsQuery(null), {wrapper}); + const {result} = renderHook(useBootstrapTeamsQuery, {wrapper, initialProps: null}); expect(result.current.data).toBeUndefined(); }); }); @@ -186,7 +186,7 @@ describe('useBootstrapProjectsQuery', () => { }, }); - const {result} = renderHook(() => useBootstrapProjectsQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapProjectsQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.data).toBeDefined()); expect(ProjectsStore.getState().projects).toEqual(mockProjects); @@ -198,14 +198,14 @@ describe('useBootstrapProjectsQuery', () => { statusCode: 500, }); - const {result} = renderHook(() => useBootstrapProjectsQuery(orgSlug), {wrapper}); + const {result} = renderHook(useBootstrapProjectsQuery, {wrapper, initialProps: orgSlug}); await waitFor(() => expect(result.current.error).toBeDefined()); expect(ProjectsStore.getState().projects).toEqual([]); }); it('does not fetch when orgSlug is null', () => { - const {result} = renderHook(() => useBootstrapProjectsQuery(null), {wrapper}); + const {result} = renderHook(useBootstrapProjectsQuery, {wrapper, initialProps: null}); expect(result.current.data).toBeUndefined(); }); }); diff --git a/static/app/components/acl/useRole.spec.tsx b/static/app/components/acl/useRole.spec.tsx index 9b1f7d67ff2b8c..7fe5d47dc22e97 100644 --- a/static/app/components/acl/useRole.spec.tsx +++ b/static/app/components/acl/useRole.spec.tsx @@ -24,8 +24,8 @@ describe('useRole', () => { }); it('has a sufficient role', () => { - const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), { - organization, + const {result} = renderHookWithProviders(useRole, { + organization, initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(true); expect(result.current.roleRequired).toBe('admin'); @@ -37,8 +37,8 @@ describe('useRole', () => { orgRole: 'member', }); OrganizationStore.onUpdate(org, {replace: true}); - const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), { - organization: org, + const {result} = renderHookWithProviders(useRole, { + organization: org, initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(false); }); @@ -50,8 +50,8 @@ describe('useRole', () => { access: ['org:superuser'], }); OrganizationStore.onUpdate(org, {replace: true}); - const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), { - organization: org, + const {result} = renderHookWithProviders(useRole, { + organization: org, initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(true); }); @@ -59,8 +59,8 @@ describe('useRole', () => { it('handles no organization.orgRoleList', () => { const org = {...organization, orgRoleList: []}; OrganizationStore.onUpdate(org, {replace: true}); - const {result} = renderHookWithProviders(() => useRole({role: 'attachmentsRole'}), { - organization: org, + const {result} = renderHookWithProviders(useRole, { + organization: org, initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(false); }); diff --git a/static/app/components/charts/useChartXRangeSelection.spec.tsx b/static/app/components/charts/useChartXRangeSelection.spec.tsx index 51ae3dd2d2c048..51adc33c8f9b1a 100644 --- a/static/app/components/charts/useChartXRangeSelection.spec.tsx +++ b/static/app/components/charts/useChartXRangeSelection.spec.tsx @@ -40,10 +40,9 @@ describe('useChartXRangeSelection', () => { describe('initial state', () => { it('should return brush configuration when not disabled', () => { - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, - }) + }} ); expect(result.current.brush).toBeDefined(); @@ -51,11 +50,10 @@ describe('useChartXRangeSelection', () => { }); it('should return undefined brush when disabled', () => { - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, disabled: true, - }) + }} ); expect(result.current.brush).toBeUndefined(); @@ -67,11 +65,10 @@ describe('useChartXRangeSelection', () => { it('should hide tooltip when brush starts', () => { const onSelectionStart = jest.fn(); - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, onSelectionStart, - }) + }} ); act(() => { @@ -88,11 +85,10 @@ describe('useChartXRangeSelection', () => { const disconnectSpy = jest.fn(); jest.spyOn(require('echarts'), 'disconnect').mockImplementation(disconnectSpy); - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, chartsGroupName: 'test-group', - }) + }} ); act(() => { @@ -144,11 +140,10 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, onSelectionEnd, - }) + }} ); const mockEvent = { @@ -213,11 +208,10 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, onSelectionEnd, - }) + }} ); const mockEvent = { @@ -276,11 +270,10 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, chartsGroupName: 'test-group', - }) + }} ); const mockEvent = { @@ -328,11 +321,10 @@ describe('useChartXRangeSelection', () => {
Action Menu
)); - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, actionMenuRenderer, - }) + }} ); act(() => { @@ -390,13 +382,12 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, actionMenuRenderer: _params => (
Action Menu
), - }) + }} ); act(() => { @@ -423,10 +414,9 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - renderHook(() => - useChartXRangeSelection({ + renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, - }) + }} ); await waitFor(() => { @@ -508,11 +498,10 @@ describe('useChartXRangeSelection', () => { panelId: 'initial-panel-id', }; - renderHook(() => - useChartXRangeSelection({ + renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, initialSelection, - }) + }} ); await waitFor(() => { @@ -713,11 +702,10 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, onInsideSelectionClick, - }) + }} ); // Create a selection first @@ -794,11 +782,10 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, onOutsideSelectionClick, - }) + }} ); // Create a selection first @@ -873,11 +860,10 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(() => - useChartXRangeSelection({ + const {result} = renderHook(useChartXRangeSelection, {initialProps: { chartRef: mockChartRef, onOutsideSelectionClick, - }) + }} ); // Create a selection first diff --git a/static/app/components/core/layout/styles.spec.tsx b/static/app/components/core/layout/styles.spec.tsx index 216bc458b755e9..e81a4167002dde 100644 --- a/static/app/components/core/layout/styles.spec.tsx +++ b/static/app/components/core/layout/styles.spec.tsx @@ -58,8 +58,8 @@ const setupMediaQueries = ( describe('useResponsivePropValue', () => { it('returns identity for non-responsive values', () => { - const {result} = renderHook(() => useResponsivePropValue('hello'), { - wrapper: createWrapper(), + const {result} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), initialProps: 'hello', }); expect(result.current).toBe('hello'); @@ -79,8 +79,8 @@ describe('useResponsivePropValue', () => { md: 'medium', }; - const {result} = renderHook(() => useResponsivePropValue(responsiveValue), { - wrapper: createWrapper(), + const {result} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), initialProps: responsiveValue, }); expect(result.current).toBe('medium'); @@ -99,8 +99,8 @@ describe('useResponsivePropValue', () => { md: 'medium', }; - const {result} = renderHook(() => useResponsivePropValue(responsiveValue), { - wrapper: createWrapper(), + const {result} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), initialProps: responsiveValue, }); expect(result.current).toBe('medium'); @@ -117,8 +117,8 @@ describe('useResponsivePropValue', () => { sm: 'small', }; - const {result} = renderHook(() => useResponsivePropValue(responsiveValue), { - wrapper: createWrapper(), + const {result} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), initialProps: responsiveValue, }); expect(result.current).toBe('small'); @@ -138,8 +138,8 @@ describe('useResponsivePropValue', () => { lg: 'large', }; - const {result} = renderHook(() => useResponsivePropValue(responsiveValue), { - wrapper: createWrapper(), + const {result} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), initialProps: responsiveValue, }); expect(result.current).toBe('small'); @@ -159,8 +159,8 @@ describe('useResponsivePropValue', () => { lg: undefined, }; - const {result} = renderHook(() => useResponsivePropValue(responsiveValue), { - wrapper: createWrapper(), + const {result} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), initialProps: responsiveValue, }); expect(result.current).toBe('medium'); @@ -169,8 +169,8 @@ describe('useResponsivePropValue', () => { it('throws an error when no breakpoints are defined in responsive prop', () => { expect(() => - renderHook(() => useResponsivePropValue({}), { - wrapper: createWrapper(), + renderHook(useResponsivePropValue, { + wrapper: createWrapper(), initialProps: {}, }) ).toThrow('Responsive prop must contain at least one breakpoint'); }); @@ -189,7 +189,7 @@ describe('useActiveBreakpoint', () => { xl: false, }); - const {result} = renderHook(() => useActiveBreakpoint(), { + const {result} = renderHook(useActiveBreakpoint, { wrapper: createWrapper(), }); @@ -206,7 +206,7 @@ describe('useActiveBreakpoint', () => { xl: false, }); - const {result} = renderHook(() => useActiveBreakpoint(), { + const {result} = renderHook(useActiveBreakpoint, { wrapper: createWrapper(), }); @@ -218,7 +218,7 @@ describe('useActiveBreakpoint', () => { const matchMediaSpy = jest.fn(() => mockMatchMedia(false)); window.matchMedia = matchMediaSpy; - renderHook(() => useActiveBreakpoint(), { + renderHook(useActiveBreakpoint, { wrapper: createWrapper(), }); @@ -243,7 +243,7 @@ describe('useActiveBreakpoint', () => { xl: true, }); - const {result} = renderHook(() => useActiveBreakpoint(), { + const {result} = renderHook(useActiveBreakpoint, { wrapper: createWrapper(), }); @@ -285,9 +285,9 @@ describe('useActiveBreakpoint', () => { }); const {result} = renderHook( - () => useResponsivePropValue({xs: 'small', md: 'medium', lg: 'large'}), + useResponsivePropValue, { - wrapper: createWrapper(), + wrapper: createWrapper(), initialProps: {xs: 'small', md: 'medium', lg: 'large'}, } ); @@ -336,9 +336,9 @@ describe('useActiveBreakpoint', () => { })); const {unmount} = renderHook( - () => useResponsivePropValue({xs: 'small', md: 'medium'}), + useResponsivePropValue, { - wrapper: createWrapper(), + wrapper: createWrapper(), initialProps: {xs: 'small', md: 'medium'}, } ); diff --git a/static/app/components/core/renderToString.spec.tsx b/static/app/components/core/renderToString.spec.tsx index afb90abceb61e9..1ea59650557072 100644 --- a/static/app/components/core/renderToString.spec.tsx +++ b/static/app/components/core/renderToString.spec.tsx @@ -15,7 +15,7 @@ describe('renderToString', () => { return
Hello, World!
; } - const {result} = renderHook(() => useRenderToString()); + const {result} = renderHook(useRenderToString); const string = await act(() => result.current()); @@ -26,7 +26,7 @@ describe('renderToString', () => { return SuccessTag; } - const {result} = renderHook(() => useRenderToString(), { + const {result} = renderHook(useRenderToString, { wrapper: ({children}) => {children}, }); diff --git a/static/app/components/onboarding/useMutateOnboardingTasks.spec.tsx b/static/app/components/onboarding/useMutateOnboardingTasks.spec.tsx index 0664b765e0f89c..61457452b2b256 100644 --- a/static/app/components/onboarding/useMutateOnboardingTasks.spec.tsx +++ b/static/app/components/onboarding/useMutateOnboardingTasks.spec.tsx @@ -29,7 +29,7 @@ describe('useMutateOnboardingTasks', () => { body: testTask, }); - const {result} = renderHookWithProviders(() => useMutateOnboardingTasks(), { + const {result} = renderHookWithProviders(useMutateOnboardingTasks, { organization, }); diff --git a/static/app/components/prevent/summary.spec.tsx b/static/app/components/prevent/summary.spec.tsx index f70ca212aaaea4..75fb23146b53af 100644 --- a/static/app/components/prevent/summary.spec.tsx +++ b/static/app/components/prevent/summary.spec.tsx @@ -17,16 +17,16 @@ function createWrapper(initialEntries: string) { describe('useCreateSummaryFilterLink', () => { describe('when the filter is not applied', () => { it('returns isFiltered as false', () => { - const {result} = renderHook(() => useCreateSummaryFilterLink('slowestTests'), { - wrapper: createWrapper('/'), + const {result} = renderHook(useCreateSummaryFilterLink, { + wrapper: createWrapper('/'), initialProps: 'slowestTests', }); expect(result.current.isFiltered).toBeFalsy(); }); it('returns the link with search param', () => { - const {result} = renderHook(() => useCreateSummaryFilterLink('slowestTests'), { - wrapper: createWrapper('/'), + const {result} = renderHook(useCreateSummaryFilterLink, { + wrapper: createWrapper('/'), initialProps: 'slowestTests', }); expect(result.current.filterLink).toEqual( @@ -37,16 +37,16 @@ describe('useCreateSummaryFilterLink', () => { describe('when the filter is applied', () => { it('returns isFiltered as true', () => { - const {result} = renderHook(() => useCreateSummaryFilterLink('slowestTests'), { - wrapper: createWrapper('/?filterBy=slowestTests'), + const {result} = renderHook(useCreateSummaryFilterLink, { + wrapper: createWrapper('/?filterBy=slowestTests'), initialProps: 'slowestTests', }); expect(result.current.isFiltered).toBeTruthy(); }); it('returns the link without search param', () => { - const {result} = renderHook(() => useCreateSummaryFilterLink('slowestTests'), { - wrapper: createWrapper('/?filterBy=slowestTests'), + const {result} = renderHook(useCreateSummaryFilterLink, { + wrapper: createWrapper('/?filterBy=slowestTests'), initialProps: 'slowestTests', }); expect(result.current.filterLink).toEqual(expect.objectContaining({query: {}})); diff --git a/static/app/components/prevent/virtualRenderers/useIsOverflowing.spec.tsx b/static/app/components/prevent/virtualRenderers/useIsOverflowing.spec.tsx index c8c71a1dba834a..c062a176572dc9 100644 --- a/static/app/components/prevent/virtualRenderers/useIsOverflowing.spec.tsx +++ b/static/app/components/prevent/virtualRenderers/useIsOverflowing.spec.tsx @@ -35,7 +35,7 @@ global.window.ResizeObserver = ResizeObserverMock; describe('useIsOverflowing', () => { describe('ref is null', () => { it('returns false if the ref is null', () => { - const {result} = renderHook(() => useIsOverflowing({current: null})); + const {result} = renderHook(useIsOverflowing, {initialProps: {current: null}}); expect(result.current).toBe(false); }); }); @@ -49,7 +49,7 @@ describe('useIsOverflowing', () => { it('returns false', () => { // @ts-expect-error - testing ref not being null - const {result} = renderHook(() => useIsOverflowing({current: {}})); + const {result} = renderHook(useIsOverflowing, {initialProps: {current: {}}}); expect(result.current).toBe(false); }); }); @@ -62,7 +62,7 @@ describe('useIsOverflowing', () => { it('returns true', () => { // @ts-expect-error - testing ref not being null - const {result} = renderHook(() => useIsOverflowing({current: {}})); + const {result} = renderHook(useIsOverflowing, {initialProps: {current: {}}}); expect(result.current).toBe(true); }); }); diff --git a/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts b/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts index c4c53e4cc81e4f..c5cedc7185fc02 100644 --- a/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts +++ b/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts @@ -24,7 +24,7 @@ global.window.ResizeObserver = ResizeObserverMock; describe('useSyncScrollMargin', () => { describe('overlayRef is null', () => { it('returns undefined', () => { - const {result} = renderHook(() => useSyncScrollMargin({current: null})); + const {result} = renderHook(useSyncScrollMargin, {initialProps: {current: null}}); expect(result.current).toBeUndefined(); }); @@ -32,8 +32,7 @@ describe('useSyncScrollMargin', () => { describe('overlayRef is set', () => { it('returns the scroll margin', () => { - const {result} = renderHook(() => - useSyncScrollMargin({current: {} as HTMLDivElement}) + const {result} = renderHook(useSyncScrollMargin, {initialProps: {current: {} as HTMLDivElement}} ); expect(result.current).toBe(100); diff --git a/static/app/components/prevent/virtualRenderers/useSyncWrapperWidth.spec.ts b/static/app/components/prevent/virtualRenderers/useSyncWrapperWidth.spec.ts index 5e5eeef72f5db7..5fe10b8a31f55e 100644 --- a/static/app/components/prevent/virtualRenderers/useSyncWrapperWidth.spec.ts +++ b/static/app/components/prevent/virtualRenderers/useSyncWrapperWidth.spec.ts @@ -24,7 +24,7 @@ global.window.ResizeObserver = ResizeObserverMock; describe('useSyncWrapperWidth', () => { describe('wrapperRefState is null', () => { it('returns the wrapper width as 100%', () => { - const {result} = renderHook(() => useSyncWrapperWidth()); + const {result} = renderHook(useSyncWrapperWidth); expect(result.current.wrapperWidth).toBe('100%'); }); @@ -32,7 +32,7 @@ describe('useSyncWrapperWidth', () => { describe('wrapperRefState is set', () => { it('returns the wrapper width from the ResizeObserver entry', () => { - const {result} = renderHook(() => useSyncWrapperWidth()); + const {result} = renderHook(useSyncWrapperWidth); act(() => { result.current.setWrapperRefState({} as HTMLDivElement); diff --git a/static/app/components/replays/replayLiveIndicator.spec.tsx b/static/app/components/replays/replayLiveIndicator.spec.tsx index 25e21426dd50d6..54342deae9c4aa 100644 --- a/static/app/components/replays/replayLiveIndicator.spec.tsx +++ b/static/app/components/replays/replayLiveIndicator.spec.tsx @@ -28,11 +28,10 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 60_000); // 1 minute ago const finishedAt = new Date(now); // just now - const {result} = renderHook(() => - useLiveBadge({ + const {result} = renderHook(useLiveBadge, {initialProps: { startedAt, finishedAt, - }) + }} ); expect(result.current.isLive).toBe(true); @@ -43,11 +42,10 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 10 * 60_000); // 10 minutes ago const finishedAt = new Date(now - 6 * 60_000); // 6 minutes ago (more than 5 min threshold) - const {result} = renderHook(() => - useLiveBadge({ + const {result} = renderHook(useLiveBadge, {initialProps: { startedAt, finishedAt, - }) + }} ); expect(result.current.isLive).toBe(false); @@ -58,11 +56,10 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 2 * 60 * 60_000); // 2 hours ago const finishedAt = new Date(now); // just now - const {result} = renderHook(() => - useLiveBadge({ + const {result} = renderHook(useLiveBadge, {initialProps: { startedAt, finishedAt, - }) + }} ); expect(result.current.isLive).toBe(false); @@ -73,11 +70,10 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 60_000); // 1 minute ago const finishedAt = new Date(now); // just now - const {result} = renderHook(() => - useLiveBadge({ + const {result} = renderHook(useLiveBadge, {initialProps: { startedAt, finishedAt, - }) + }} ); expect(result.current.isLive).toBe(true); @@ -94,11 +90,10 @@ describe('useLiveBadge', () => { const now = Date.now(); const startedAt = new Date(now - 60_000); - const {result} = renderHook(() => - useLiveBadge({ + const {result} = renderHook(useLiveBadge, {initialProps: { startedAt, finishedAt: null, - }) + }} ); expect(result.current.isLive).toBe(false); @@ -124,8 +119,8 @@ describe('useLiveRefresh', () => { }); it('should not show refresh button when replay is undefined', () => { - const {result} = renderHook(() => useLiveRefresh({replay: undefined}), { - wrapper: createWrapper(), + const {result} = renderHook(useLiveRefresh, { + wrapper: createWrapper(), initialProps: {replay: undefined}, }); expect(result.current.shouldShowRefreshButton).toBe(false); @@ -142,8 +137,8 @@ describe('useLiveRefresh', () => { body: {data: replay}, }); - const {result} = renderHook(() => useLiveRefresh({replay}), { - wrapper: createWrapper(), + const {result} = renderHook(useLiveRefresh, { + wrapper: createWrapper(), initialProps: {replay}, }); // Initial state - no refresh button since polled and current are equal @@ -168,8 +163,8 @@ describe('useLiveRefresh', () => { body: {data: updatedReplay}, }); - const {result} = renderHook(() => useLiveRefresh({replay}), { - wrapper: createWrapper(), + const {result} = renderHook(useLiveRefresh, { + wrapper: createWrapper(), initialProps: {replay}, }); // Wait for the API call to complete and state to update @@ -190,8 +185,8 @@ describe('useLiveRefresh', () => { body: {data: {...replay, count_segments: 10}}, }); - renderHook(() => useLiveRefresh({replay}), { - wrapper: createWrapper(), + renderHook(useLiveRefresh, { + wrapper: createWrapper(), initialProps: {replay}, }); // Advance time past polling interval @@ -215,8 +210,8 @@ describe('useLiveRefresh', () => { body: {data: replay}, }); - const {result} = renderHook(() => useLiveRefresh({replay}), { - wrapper: createWrapper(), + const {result} = renderHook(useLiveRefresh, { + wrapper: createWrapper(), initialProps: {replay}, }); result.current.doRefresh(); diff --git a/static/app/components/searchQueryBuilder/hooks.spec.tsx b/static/app/components/searchQueryBuilder/hooks.spec.tsx index 69675522c17516..d7ae71f6881e7f 100644 --- a/static/app/components/searchQueryBuilder/hooks.spec.tsx +++ b/static/app/components/searchQueryBuilder/hooks.spec.tsx @@ -4,13 +4,12 @@ import {useCaseInsensitivity} from 'sentry/components/searchQueryBuilder/hooks'; describe('useCaseSensitivity', () => { it('should return the correct case sensitivity', () => { - const {result: noCaseSensitivity} = renderHookWithProviders(() => - useCaseInsensitivity() + const {result: noCaseSensitivity} = renderHookWithProviders(useCaseInsensitivity ); expect(noCaseSensitivity.current[0]).toBeNull(); const {result: caseSensitivityFalse} = renderHookWithProviders( - () => useCaseInsensitivity(), + useCaseInsensitivity, { initialRouterConfig: { location: {pathname: '/', query: {}}, @@ -20,14 +19,14 @@ describe('useCaseSensitivity', () => { expect(caseSensitivityFalse.current[0]).toBeNull(); const {result: caseSensitivityTrue} = renderHookWithProviders( - () => useCaseInsensitivity(), + useCaseInsensitivity, {initialRouterConfig: {location: {pathname: '/', query: {caseInsensitive: '1'}}}} ); expect(caseSensitivityTrue.current[0]).toBe(true); }); it('should set the case sensitivity', async () => { - const {router, result} = renderHookWithProviders(() => useCaseInsensitivity()); + const {router, result} = renderHookWithProviders(useCaseInsensitivity); expect(router.location.query.caseInsensitive).toBeUndefined(); diff --git a/static/app/components/workflowEngine/form/useFormField.spec.tsx b/static/app/components/workflowEngine/form/useFormField.spec.tsx index f19810054a4777..4226206b2e1723 100644 --- a/static/app/components/workflowEngine/form/useFormField.spec.tsx +++ b/static/app/components/workflowEngine/form/useFormField.spec.tsx @@ -19,8 +19,8 @@ describe('useFormField', () => { it('returns field values and handles updates correctly', () => { model.setInitialData({targetField: 'initial', otherField: 'other'}); - const {result} = renderHook(() => useFormField('targetField'), { - wrapper: withFormContext, + const {result} = renderHook(useFormField, { + wrapper: withFormContext, initialProps: 'targetField', }); expect(result.current).toBe('initial'); @@ -37,14 +37,14 @@ describe('useFormField', () => { }); it('handles undefined values and type parameters', () => { - const {result: undefinedResult} = renderHook(() => useFormField('nonexistent'), { - wrapper: withFormContext, + const {result: undefinedResult} = renderHook(useFormField, { + wrapper: withFormContext, initialProps: 'nonexistent', }); expect(undefinedResult.current).toBe(''); model.setInitialData({numberField: 42}); - const {result: typedResult} = renderHook(() => useFormField('numberField'), { - wrapper: withFormContext, + const {result: typedResult} = renderHook(useFormField, { + wrapper: withFormContext, initialProps: 'numberField', }); expect(typedResult.current).toBe(42); expect(typeof typedResult.current).toBe('number'); @@ -52,8 +52,8 @@ describe('useFormField', () => { it('handles fields that are added after subscription', () => { // Start with a hook subscribed to a field that doesn't exist yet - const {result} = renderHook(() => useFormField('laterField'), { - wrapper: withFormContext, + const {result} = renderHook(useFormField, { + wrapper: withFormContext, initialProps: 'laterField', }); // Initially should return empty string for non-existent field @@ -78,8 +78,8 @@ describe('useFormField', () => { it('handles fields that are removed after subscription', () => { model.setInitialData({targetField: 'initial'}); - const {result} = renderHook(() => useFormField('targetField'), { - wrapper: withFormContext, + const {result} = renderHook(useFormField, { + wrapper: withFormContext, initialProps: 'targetField', }); expect(result.current).toBe('initial'); diff --git a/static/app/utils/api/apiOptions.spec.tsx b/static/app/utils/api/apiOptions.spec.tsx index 215b566aa7513b..08a5be469e0602 100644 --- a/static/app/utils/api/apiOptions.spec.tsx +++ b/static/app/utils/api/apiOptions.spec.tsx @@ -88,7 +88,7 @@ describe('apiOptions', () => { body: ['Project 1', 'Project 2'], }); - const {result} = renderHook(() => useQuery(options), {wrapper}); + const {result} = renderHook(useQuery, {wrapper, initialProps: options}); await waitFor(() => result.current.isSuccess); @@ -110,9 +110,8 @@ describe('apiOptions', () => { }); const {result} = renderHook( - () => - useQuery({...options, select: selectWithHeaders(['Link', 'X-Hits'] as const)}), - {wrapper} + useQuery, + {wrapper, initialProps: {...options, select: selectWithHeaders(['Link', 'X-Hits'] as const)}} ); await waitFor(() => result.current.isSuccess); diff --git a/static/app/utils/demoMode/demoTours.spec.tsx b/static/app/utils/demoMode/demoTours.spec.tsx index fbdba7042be06b..7fc10d4bb4f1be 100644 --- a/static/app/utils/demoMode/demoTours.spec.tsx +++ b/static/app/utils/demoMode/demoTours.spec.tsx @@ -105,7 +105,7 @@ describe('DemoTours', () => { it('returns null when used outside provider', () => { jest.spyOn(console, 'error').mockImplementation(() => {}); - const {result} = renderHookWithProviders(() => useDemoTour(DemoTour.RELEASES)); + const {result} = renderHookWithProviders(useDemoTour, {initialProps: DemoTour.RELEASES}); expect(result.current).toBeNull(); @@ -113,8 +113,8 @@ describe('DemoTours', () => { }); it('provides tour context when used inside provider', () => { - const {result} = renderHookWithProviders(() => useDemoTour(DemoTour.RELEASES), { - additionalWrapper: createWrapper(), + const {result} = renderHookWithProviders(useDemoTour, { + additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, }); const tour = result.current; @@ -128,8 +128,8 @@ describe('DemoTours', () => { }); it('handles tour actions', () => { - const {result} = renderHookWithProviders(() => useDemoTour(DemoTour.RELEASES), { - additionalWrapper: createWrapper(), + const {result} = renderHookWithProviders(useDemoTour, { + additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, }); const tour = result.current; @@ -160,18 +160,18 @@ describe('DemoTours', () => { it('maintains separate state for different tours', () => { const {result: sideBarResult} = renderHookWithProviders( - () => useDemoTour(DemoTour.RELEASES), + useDemoTour, { - additionalWrapper: createWrapper(), + additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, } ); const sidebarTour = sideBarResult.current; const {result: issuesResult} = renderHookWithProviders( - () => useDemoTour(DemoTour.ISSUES), + useDemoTour, { - additionalWrapper: createWrapper(), + additionalWrapper: createWrapper(), initialProps: DemoTour.ISSUES, } ); @@ -213,8 +213,8 @@ describe('DemoTours', () => { }); it('correctly advances through tour steps', () => { - const {result} = renderHookWithProviders(() => useDemoTour(DemoTour.RELEASES), { - additionalWrapper: createWrapper(), + const {result} = renderHookWithProviders(useDemoTour, { + additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, }); const sidebarTour = result.current; diff --git a/static/app/utils/list/useListItemCheckboxState.spec.ts b/static/app/utils/list/useListItemCheckboxState.spec.ts index 5901b2dd9cf818..c71a586d0f87bd 100644 --- a/static/app/utils/list/useListItemCheckboxState.spec.ts +++ b/static/app/utils/list/useListItemCheckboxState.spec.ts @@ -8,8 +8,7 @@ const queryKey: ApiQueryKey = ['test']; describe('useListItemCheckboxContext', () => { describe('All hits are already known', () => { it('should return the correct initial state', () => { - const {result} = renderHook(() => - useListItemCheckboxContext({hits: 3, knownIds: ['1', '2', '3'], queryKey}) + const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} ); expect(result.current).toEqual({ countSelected: 0, @@ -27,8 +26,7 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting an individual item when all hits are known', () => { - const {result} = renderHook(() => - useListItemCheckboxContext({hits: 3, knownIds: ['1', '2', '3'], queryKey}) + const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} ); // Initially nothing is selected @@ -83,8 +81,7 @@ describe('useListItemCheckboxContext', () => { }); it('sets isAllSelected to true when all items are selected', () => { - const {result} = renderHook(() => - useListItemCheckboxContext({hits: 3, knownIds: ['1', '2', '3'], queryKey}) + const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} ); // Initially nothing is selected @@ -107,8 +104,7 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting all items with selectAll', () => { - const {result} = renderHook(() => - useListItemCheckboxContext({hits: 3, knownIds: ['1', '2', '3'], queryKey}) + const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} ); // Initially nothing is selected @@ -151,8 +147,7 @@ describe('useListItemCheckboxContext', () => { describe('More hits to load', () => { it('should return the correct initial state', () => { - const {result} = renderHook(() => - useListItemCheckboxContext({hits: 10, knownIds: ['1', '2', '3'], queryKey}) + const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}} ); expect(result.current).toEqual({ countSelected: 0, @@ -170,8 +165,7 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting individual items when there are more hits to load', () => { - const {result} = renderHook(() => - useListItemCheckboxContext({hits: 10, knownIds: ['1', '2', '3'], queryKey}) + const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}} ); // Initially nothing is selected @@ -240,8 +234,7 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting all items with selectAll', () => { - const {result} = renderHook(() => - useListItemCheckboxContext({hits: 10, knownIds: ['1', '2', '3'], queryKey}) + const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}} ); // Initially nothing is selected diff --git a/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx b/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx index 4ec3f6b033bfdd..9bde3941a62b68 100644 --- a/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx +++ b/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx @@ -30,12 +30,11 @@ describe('useProfileFunctionTrendss', () => { }); const hook = renderHook( - () => - useProfileFunctionTrends({ + useProfileFunctionTrends, + {wrapper: TestContext, initialProps: { trendFunction: 'p95()', trendType: 'regression', - }), - {wrapper: TestContext} + }} ); expect(hook.result.current).toMatchObject( expect.objectContaining({ @@ -51,12 +50,11 @@ describe('useProfileFunctionTrendss', () => { }); const hook = renderHook( - () => - useProfileFunctionTrends({ + useProfileFunctionTrends, + {wrapper: TestContext, initialProps: { trendFunction: 'p95()', trendType: 'regression', - }), - {wrapper: TestContext} + }} ); expect(hook.result.current.isPending).toBe(true); expect(hook.result.current.isFetched).toBe(false); diff --git a/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx b/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx index 12356011977695..8bf9a117329000 100644 --- a/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx +++ b/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx @@ -13,15 +13,14 @@ describe('useProfileFunctions', () => { body: {data: []}, }); - const hook = renderHookWithProviders(() => - useProfileFunctions({ + const hook = renderHookWithProviders(useProfileFunctions, {initialProps: { fields: ['count()'], referrer: '', sort: { key: 'count()', order: 'desc', }, - }) + }} ); expect(hook.result.current).toMatchObject( expect.objectContaining({ @@ -36,15 +35,14 @@ describe('useProfileFunctions', () => { body: {data: []}, }); - const hook = renderHookWithProviders(() => - useProfileFunctions({ + const hook = renderHookWithProviders(useProfileFunctions, {initialProps: { fields: ['count()'], referrer: '', sort: { key: 'count()', order: 'desc', }, - }) + }} ); expect(hook.result.current.isPending).toBe(true); expect(hook.result.current.isFetched).toBe(false); diff --git a/static/app/utils/url/urlParamBatchContext.spec.tsx b/static/app/utils/url/urlParamBatchContext.spec.tsx index e16659281ec12d..e47d3e3a4e9f23 100644 --- a/static/app/utils/url/urlParamBatchContext.spec.tsx +++ b/static/app/utils/url/urlParamBatchContext.spec.tsx @@ -33,7 +33,7 @@ describe('UrlParamBatchProvider', () => { it('should batch updates to the URL query params', () => { setWindowLocation('http://localhost/'); - const {result} = renderHook(() => useUrlBatchContext(), { + const {result} = renderHook(useUrlBatchContext, { wrapper: UrlParamBatchProvider, }); const {batchUrlParamUpdates} = result.current; diff --git a/static/app/utils/url/useQueryParamState.spec.tsx b/static/app/utils/url/useQueryParamState.spec.tsx index c1fc8237617afa..63f45604911c1e 100644 --- a/static/app/utils/url/useQueryParamState.spec.tsx +++ b/static/app/utils/url/useQueryParamState.spec.tsx @@ -30,8 +30,8 @@ describe('useQueryParamState', () => { LocationFixture({query: {testField: 'initial state'}}) ); - const {result} = renderHook(() => useQueryParamState({fieldName: 'testField'}), { - wrapper: UrlParamBatchProvider, + const {result} = renderHook(useQueryParamState, { + wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField'}, }); expect(result.current[0]).toBe('initial state'); @@ -41,8 +41,8 @@ describe('useQueryParamState', () => { const mockedNavigate = jest.fn(); mockedUseNavigate.mockReturnValue(mockedNavigate); - const {result} = renderHook(() => useQueryParamState({fieldName: 'testField'}), { - wrapper: UrlParamBatchProvider, + const {result} = renderHook(useQueryParamState, { + wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField'}, }); act(() => { @@ -85,9 +85,9 @@ describe('useQueryParamState', () => { const testDeserializer = (value: string) => `${value.toUpperCase()} - decoded`; const {result} = renderHook( - () => useQueryParamState({fieldName: 'testField', deserializer: testDeserializer}), + useQueryParamState, { - wrapper: UrlParamBatchProvider, + wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', deserializer: testDeserializer}, } ); @@ -108,9 +108,9 @@ describe('useQueryParamState', () => { `${value.value} - ${value.count} - ${value.isActive}`; const {result} = renderHook( - () => useQueryParamState({fieldName: 'testField', serializer: testSerializer}), + useQueryParamState, { - wrapper: UrlParamBatchProvider, + wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', serializer: testSerializer}, } ); @@ -134,14 +134,13 @@ describe('useQueryParamState', () => { mockedUseNavigate.mockReturnValue(mockedNavigate); const {result} = renderHook( - () => - useQueryParamState({ + useQueryParamState, + { + wrapper: UrlParamBatchProvider, initialProps: { fieldName: 'sort', decoder: decodeSorts, serializer: value => value.map(formatSort), - }), - { - wrapper: UrlParamBatchProvider, + }, } ); @@ -166,9 +165,9 @@ describe('useQueryParamState', () => { ); const {result, rerender} = renderHook( - () => useQueryParamState({fieldName: 'testField', syncStateWithUrl: false}), + useQueryParamState, { - wrapper: UrlParamBatchProvider, + wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', syncStateWithUrl: false}, } ); @@ -191,9 +190,9 @@ describe('useQueryParamState', () => { ); const {result, rerender} = renderHook( - () => useQueryParamState({fieldName: 'testField', syncStateWithUrl: true}), + useQueryParamState, { - wrapper: UrlParamBatchProvider, + wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', syncStateWithUrl: true}, } ); diff --git a/static/app/utils/useIsMountedRef.spec.tsx b/static/app/utils/useIsMountedRef.spec.tsx index 9a76c76e6e17bc..e200aeef02b387 100644 --- a/static/app/utils/useIsMountedRef.spec.tsx +++ b/static/app/utils/useIsMountedRef.spec.tsx @@ -1,31 +1,32 @@ -import {renderHook} from 'sentry-test/reactTestingLibrary'; +import {renderHook, render} from 'sentry-test/reactTestingLibrary'; import {useIsMountedRef} from './useIsMountedRef'; describe('useIsMounted', () => { it('should return a ref', () => { - const {result} = renderHook(() => useIsMountedRef()); + const {result} = renderHook(useIsMountedRef); expect(result.current).toBeInstanceOf(Object); }); + function TestComponent() { + const isMountedRef = useIsMountedRef(); + return isMountedRef.current; + } it('should return false within first render', () => { - const {result} = renderHook(() => { - const isMountedRef = useIsMountedRef(); - return isMountedRef.current; - }); + const {result} = render(); expect(result.current).toBe(false); }); it('should return true after mount', () => { - const {result} = renderHook(() => useIsMountedRef()); + const {result} = renderHook(useIsMountedRef); expect(result.current.current).toBe(true); }); it('should return same function on each render', () => { - const {result, rerender} = renderHook(() => useIsMountedRef()); + const {result, rerender} = renderHook(useIsMountedRef); const fn1 = result.current; rerender(); @@ -38,7 +39,7 @@ describe('useIsMounted', () => { }); it('should return false after component unmount', () => { - const {result, unmount} = renderHook(() => useIsMountedRef()); + const {result, unmount} = renderHook(useIsMountedRef); expect(result.current.current).toBe(true); diff --git a/static/app/utils/useIsSentryEmployee.spec.tsx b/static/app/utils/useIsSentryEmployee.spec.tsx index 7a9d8482f9cc32..3cfba6dce79554 100644 --- a/static/app/utils/useIsSentryEmployee.spec.tsx +++ b/static/app/utils/useIsSentryEmployee.spec.tsx @@ -22,7 +22,7 @@ describe('useIsSentryEmployee', () => { }) ); - const {result} = renderHook(() => useIsSentryEmployee()); + const {result} = renderHook(useIsSentryEmployee); expect(result.current).toBe(true); }); @@ -43,7 +43,7 @@ describe('useIsSentryEmployee', () => { }) ); - const {result} = renderHook(() => useIsSentryEmployee()); + const {result} = renderHook(useIsSentryEmployee); expect(result.current).toBe(false); }); @@ -63,7 +63,7 @@ describe('useIsSentryEmployee', () => { }) ); - const {result} = renderHook(() => useIsSentryEmployee()); + const {result} = renderHook(useIsSentryEmployee); expect(result.current).toBe(false); }); diff --git a/static/app/utils/useLocalStorageState.spec.tsx b/static/app/utils/useLocalStorageState.spec.tsx index 696108aa20b727..1fc2decdc04b94 100644 --- a/static/app/utils/useLocalStorageState.spec.tsx +++ b/static/app/utils/useLocalStorageState.spec.tsx @@ -1,4 +1,4 @@ -import {act, renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; +import {act, renderHook, waitFor, render} from 'sentry-test/reactTestingLibrary'; import localStorageWrapper from 'sentry/utils/localStorage'; import {useLocalStorageState} from 'sentry/utils/useLocalStorageState'; @@ -14,10 +14,10 @@ describe('useLocalStorageState', () => { it('throws if key is not a string', () => { expect(() => { - renderHook(() => { - // @ts-expect-error force incorrect usage + function TestComponent() { useLocalStorageState({}, 'default value'); - }); + } + render(); }).toThrow('useLocalStorage: key must be a string'); }); diff --git a/static/app/utils/useMaxPickableDays.spec.tsx b/static/app/utils/useMaxPickableDays.spec.tsx index b2abdb03ed48d0..5da991d8d6c809 100644 --- a/static/app/utils/useMaxPickableDays.spec.tsx +++ b/static/app/utils/useMaxPickableDays.spec.tsx @@ -8,10 +8,9 @@ import {useMaxPickableDays} from './useMaxPickableDays'; describe('useMaxPickableDays', () => { it('returns 90/90 for transactions', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.TRANSACTIONS], - }) + }} ); expect(result.current).toEqual({ @@ -21,10 +20,9 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for replays', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.REPLAYS], - }) + }} ); expect(result.current).toEqual({ @@ -34,10 +32,9 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for spans without flag', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.SPANS], - }) + }} ); expect(result.current).toEqual({ @@ -49,12 +46,11 @@ describe('useMaxPickableDays', () => { it('returns 90/90 for spans with flag', () => { const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ - dataCategories: [DataCategory.SPANS], - }), + useMaxPickableDays, { - organization: OrganizationFixture({features: ['visibility-explore-range-high']}), + organization: OrganizationFixture({features: ['visibility-explore-range-high']}), initialProps: { + dataCategories: [DataCategory.SPANS], + }, } ); @@ -66,10 +62,9 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for tracemetrics', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.TRACE_METRICS], - }) + }} ); expect(result.current).toEqual({ @@ -80,10 +75,9 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for logs', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.LOG_BYTE, DataCategory.LOG_ITEM], - }) + }} ); expect(result.current).toEqual({ @@ -94,8 +88,7 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for many without flag', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [ DataCategory.SPANS, DataCategory.SPANS_INDEXED, @@ -103,7 +96,7 @@ describe('useMaxPickableDays', () => { DataCategory.LOG_BYTE, DataCategory.LOG_ITEM, ], - }) + }} ); expect(result.current).toEqual({ diff --git a/static/app/utils/useUpdateOrganization.spec.tsx b/static/app/utils/useUpdateOrganization.spec.tsx index cbdff4e09681af..3bfd58374ffcc4 100644 --- a/static/app/utils/useUpdateOrganization.spec.tsx +++ b/static/app/utils/useUpdateOrganization.spec.tsx @@ -37,10 +37,10 @@ describe('useUpdateOrganization', () => { body: updatedOrganization, }); - const {result} = renderHook(() => useUpdateOrganization(organization), { + const {result} = renderHook(useUpdateOrganization, { wrapper: ({children}) => ( {children} - ), + ), initialProps: organization, }); // Verify initial state @@ -81,10 +81,10 @@ describe('useUpdateOrganization', () => { body: {detail: 'Internal Server Error'}, }); - const {result} = renderHook(() => useUpdateOrganization(organization), { + const {result} = renderHook(useUpdateOrganization, { wrapper: ({children}) => ( {children} - ), + ), initialProps: organization, }); // Verify initial state diff --git a/static/app/utils/useUserTeams.spec.tsx b/static/app/utils/useUserTeams.spec.tsx index f6319a17b308d9..eb45305231446c 100644 --- a/static/app/utils/useUserTeams.spec.tsx +++ b/static/app/utils/useUserTeams.spec.tsx @@ -89,7 +89,7 @@ describe('useUserTeams', () => { }); OrganizationStore.onUpdate(organization, {replace: true}); - const {result} = renderHookWithProviders(() => useUserTeams(), {organization: org}); + const {result} = renderHookWithProviders(useUserTeams, {organization: org}); const {teams} = result.current; expect(teams).toHaveLength(2); diff --git a/static/app/views/dashboards/widgetBuilder/hooks/useCacheBuilderState.spec.tsx b/static/app/views/dashboards/widgetBuilder/hooks/useCacheBuilderState.spec.tsx index 43a0bb07b73b15..5a8962147fab70 100644 --- a/static/app/views/dashboards/widgetBuilder/hooks/useCacheBuilderState.spec.tsx +++ b/static/app/views/dashboards/widgetBuilder/hooks/useCacheBuilderState.spec.tsx @@ -76,7 +76,7 @@ describe('useCacheBuilderState', () => { dispatch: jest.fn(), }); - const {result} = renderHook(() => useCacheBuilderState(), { + const {result} = renderHook(useCacheBuilderState, { wrapper: Wrapper, }); @@ -133,7 +133,7 @@ describe('useCacheBuilderState', () => { JSON.stringify(convertBuilderStateToWidget(cachedWidget)) ); - const {result} = renderHook(() => useCacheBuilderState(), { + const {result} = renderHook(useCacheBuilderState, { wrapper: Wrapper, }); @@ -189,7 +189,7 @@ describe('useCacheBuilderState', () => { JSON.stringify(convertBuilderStateToWidget(cachedWidget)) ); - const {result} = renderHook(() => useCacheBuilderState(), { + const {result} = renderHook(useCacheBuilderState, { wrapper: Wrapper, }); diff --git a/static/app/views/dashboards/widgetBuilder/hooks/useWidgetBuilderState.spec.tsx b/static/app/views/dashboards/widgetBuilder/hooks/useWidgetBuilderState.spec.tsx index 2379001fd196c1..a91152a44d46cf 100644 --- a/static/app/views/dashboards/widgetBuilder/hooks/useWidgetBuilderState.spec.tsx +++ b/static/app/views/dashboards/widgetBuilder/hooks/useWidgetBuilderState.spec.tsx @@ -42,7 +42,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -51,7 +51,7 @@ describe('useWidgetBuilderState', () => { }); it('sets the new title and description in the query params', () => { - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); act(() => { @@ -85,7 +85,7 @@ describe('useWidgetBuilderState', () => { }); it('does not update the url when the updateUrl option is false', () => { - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -110,7 +110,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -124,7 +124,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -132,7 +132,7 @@ describe('useWidgetBuilderState', () => { }); it('sets the display type in the query params', () => { - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -164,7 +164,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -221,7 +221,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -283,7 +283,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -355,7 +355,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -410,7 +410,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -465,7 +465,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -520,7 +520,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -560,7 +560,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -581,7 +581,7 @@ describe('useWidgetBuilderState', () => { LocationFixture({query: {selectedAggregate: '0'}}) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -608,7 +608,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -638,7 +638,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -665,7 +665,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -690,7 +690,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -719,7 +719,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -745,7 +745,7 @@ describe('useWidgetBuilderState', () => { it('resets limit when the display type is switched to table', () => { mockedUsedLocation.mockReturnValue(LocationFixture({query: {limit: '3'}})); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -777,7 +777,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -805,7 +805,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -828,7 +828,7 @@ describe('useWidgetBuilderState', () => { LocationFixture({query: {dataset: WidgetType.ISSUE}}) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -836,7 +836,7 @@ describe('useWidgetBuilderState', () => { }); it('sets the dataset in the query params', () => { - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -860,7 +860,7 @@ describe('useWidgetBuilderState', () => { it('returns errors as the default dataset', () => { mockedUsedLocation.mockReturnValue(LocationFixture({query: {dataset: 'invalid'}})); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -874,7 +874,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -905,7 +905,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -946,7 +946,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -984,7 +984,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1016,7 +1016,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1048,7 +1048,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1075,7 +1075,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1102,7 +1102,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1132,7 +1132,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1155,7 +1155,7 @@ describe('useWidgetBuilderState', () => { LocationFixture({query: {field: ['event.type', 'potato', 'count()']}}) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1182,7 +1182,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1219,7 +1219,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1253,7 +1253,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1284,7 +1284,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1307,7 +1307,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1337,7 +1337,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1364,7 +1364,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1393,7 +1393,7 @@ describe('useWidgetBuilderState', () => { }, }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1420,7 +1420,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1456,7 +1456,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1489,7 +1489,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1523,7 +1523,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1562,7 +1562,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1608,7 +1608,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1647,7 +1647,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1675,7 +1675,7 @@ describe('useWidgetBuilderState', () => { }, }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1707,7 +1707,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1733,7 +1733,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1762,7 +1762,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1789,7 +1789,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1818,7 +1818,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1845,7 +1845,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1883,7 +1883,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1936,7 +1936,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -1979,7 +1979,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -2022,7 +2022,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); @@ -2084,7 +2084,7 @@ describe('useWidgetBuilderState', () => { }) ); - const {result} = renderHook(() => useWidgetBuilderState(), { + const {result} = renderHook(useWidgetBuilderState, { wrapper: WidgetBuilderProvider, }); diff --git a/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx b/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx index 74bab682b9a1dd..8f1a38fbddb848 100644 --- a/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx +++ b/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx @@ -56,8 +56,7 @@ describe('useMetricDetectorAnomalies', () => { }, ]; - const {result} = renderHookWithProviders(() => - useMetricDetectorAnomalies({ + const {result} = renderHookWithProviders(useMetricDetectorAnomalies, {initialProps: { series, historicalSeries, thresholdType: AlertRuleThresholdType.ABOVE, @@ -65,7 +64,7 @@ describe('useMetricDetectorAnomalies', () => { interval: 900, // 15 minutes projectId: '1', enabled: true, - }) + }} ); await waitFor(() => { diff --git a/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx b/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx index 1f56ffc51f5b03..f621d14738a855 100644 --- a/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx +++ b/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx @@ -74,8 +74,7 @@ describe('useMetricDetectorAnomalyPeriods', () => { }, ]; - const {result} = renderHookWithProviders(() => - useMetricDetectorAnomalyPeriods({ + const {result} = renderHookWithProviders(useMetricDetectorAnomalyPeriods, {initialProps: { series, detectorDataset: DetectorDataset.ERRORS, dataset: Dataset.ERRORS, @@ -90,7 +89,7 @@ describe('useMetricDetectorAnomalyPeriods', () => { sensitivity: AlertRuleSensitivity.MEDIUM, isLoadingSeries: false, enabled: true, - }) + }} ); await waitFor(() => { diff --git a/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx b/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx index 32ec7c05c570e1..d079971fea5916 100644 --- a/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx +++ b/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx @@ -27,15 +27,14 @@ describe('useMetricDetectorAnomalyThresholds', () => { ]; renderHookWithProviders( - () => - useMetricDetectorAnomalyThresholds({ + useMetricDetectorAnomalyThresholds, + {organization, initialProps: { detectorId: '123', detectionType: 'static', startTimestamp: 1609459200, endTimestamp: 1609545600, series, - }), - {organization} + }} ); expect(anomalyDataRequest).not.toHaveBeenCalled(); @@ -69,15 +68,14 @@ describe('useMetricDetectorAnomalyThresholds', () => { ]; renderHookWithProviders( - () => - useMetricDetectorAnomalyThresholds({ + useMetricDetectorAnomalyThresholds, + {organization, initialProps: { detectorId: '123', detectionType: 'dynamic', startTimestamp: 1609459200, endTimestamp: 1609545600, series, - }), - {organization} + }} ); await waitFor(() => { @@ -103,15 +101,14 @@ describe('useMetricDetectorAnomalyThresholds', () => { ]; renderHookWithProviders( - () => - useMetricDetectorAnomalyThresholds({ + useMetricDetectorAnomalyThresholds, + {organization, initialProps: { detectorId: '123', detectionType: undefined, startTimestamp: 1609459200, endTimestamp: 1609545600, series, - }), - {organization} + }} ); expect(anomalyDataRequest).not.toHaveBeenCalled(); @@ -146,16 +143,15 @@ describe('useMetricDetectorAnomalyThresholds', () => { ]; renderHookWithProviders( - () => - useMetricDetectorAnomalyThresholds({ + useMetricDetectorAnomalyThresholds, + {organization, initialProps: { detectorId: '123', detectionType: 'dynamic', startTimestamp: 1609459200, endTimestamp: 1609545600, series, isLegacyAlert: true, - }), - {organization} + }} ); await waitFor(() => { diff --git a/static/app/views/explore/hooks/useCrossEventQueries.spec.tsx b/static/app/views/explore/hooks/useCrossEventQueries.spec.tsx index 9553839ffd48af..35f02d5e6f3d19 100644 --- a/static/app/views/explore/hooks/useCrossEventQueries.spec.tsx +++ b/static/app/views/explore/hooks/useCrossEventQueries.spec.tsx @@ -57,7 +57,7 @@ function Wrapper(crossEvents?: CrossEvent[]) { describe('useCrossEventQueries', () => { it('returns undefined if there are no cross event queries', () => { - const {result} = renderHookWithProviders(() => useCrossEventQueries(), { + const {result} = renderHookWithProviders(useCrossEventQueries, { additionalWrapper: Wrapper(), }); @@ -65,7 +65,7 @@ describe('useCrossEventQueries', () => { }); it('returns undefined if cross event queries array is empty', () => { - const {result} = renderHookWithProviders(() => useCrossEventQueries(), { + const {result} = renderHookWithProviders(useCrossEventQueries, { additionalWrapper: Wrapper([]), }); @@ -73,7 +73,7 @@ describe('useCrossEventQueries', () => { }); it('returns object of array of queries', () => { - const {result} = renderHookWithProviders(() => useCrossEventQueries(), { + const {result} = renderHookWithProviders(useCrossEventQueries, { additionalWrapper: Wrapper([ {type: 'logs', query: 'test:a'}, {type: 'metrics', query: 'test:b'}, @@ -90,7 +90,7 @@ describe('useCrossEventQueries', () => { }); it('appends queries with the same types', () => { - const {result} = renderHookWithProviders(() => useCrossEventQueries(), { + const {result} = renderHookWithProviders(useCrossEventQueries, { additionalWrapper: Wrapper([ {type: 'spans', query: 'test:a'}, {type: 'spans', query: 'test:b'}, @@ -107,7 +107,7 @@ describe('useCrossEventQueries', () => { }); it('ignores queries with invalid types', () => { - const {result} = renderHookWithProviders(() => useCrossEventQueries(), { + const {result} = renderHookWithProviders(useCrossEventQueries, { additionalWrapper: Wrapper([ {type: 'logs', query: 'test:a'}, {type: 'invalid' as any, query: 'test:b'}, diff --git a/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx b/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx index 1ace82f0062c0b..e9073bbb5fda96 100644 --- a/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx +++ b/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx @@ -46,14 +46,13 @@ describe('useExploreAggregatesTable', () => { method: 'GET', }); renderHookWithProviders( - () => - useExploreAggregatesTable({ + useExploreAggregatesTable, + { + additionalWrapper: Wrapper, initialProps: { query: 'test value', enabled: true, limit: 100, - }), - { - additionalWrapper: Wrapper, + }, } ); @@ -97,12 +96,7 @@ describe('useExploreAggregatesTable', () => { }); renderHookWithProviders( - () => - useExploreAggregatesTable({ - query: 'test value', - enabled: true, - limit: 100, - }), + useExploreAggregatesTable, { additionalWrapper: Wrapper, initialRouterConfig: { @@ -112,6 +106,10 @@ describe('useExploreAggregatesTable', () => { extrapolate: '0', }, }, + }, initialProps: { + query: 'test value', + enabled: true, + limit: 100, }, } ); diff --git a/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx b/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx index 18d30f3249c946..263c8c52ab200b 100644 --- a/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx +++ b/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx @@ -47,13 +47,12 @@ describe('useExploreSpansTable', () => { method: 'GET', }); renderHookWithProviders( - () => - useExploreSpansTable({ + useExploreSpansTable, + {additionalWrapper: Wrapper, initialProps: { query: 'test value', enabled: true, limit: 10, - }), - {additionalWrapper: Wrapper} + }} ); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); @@ -104,12 +103,7 @@ describe('useExploreSpansTable', () => { }); renderHookWithProviders( - () => - useExploreSpansTable({ - query: 'test value', - enabled: true, - limit: 10, - }), + useExploreSpansTable, { additionalWrapper: Wrapper, initialRouterConfig: { @@ -119,6 +113,10 @@ describe('useExploreSpansTable', () => { extrapolate: '0', }, }, + }, initialProps: { + query: 'test value', + enabled: true, + limit: 10, }, } ); diff --git a/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx b/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx index 0cf47f25d7abb7..fef4e39b5457a4 100644 --- a/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx +++ b/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx @@ -61,13 +61,12 @@ describe('useExploreTimeseries', () => { method: 'GET', }); renderHookWithProviders( - () => - useExploreTimeseries({ + useExploreTimeseries, + { + additionalWrapper: Wrapper, initialProps: { query: 'test value', enabled: true, - }), - { - additionalWrapper: Wrapper, + }, } ); @@ -111,11 +110,7 @@ describe('useExploreTimeseries', () => { }); renderHookWithProviders( - () => - useExploreTimeseries({ - query: 'test value', - enabled: true, - }), + useExploreTimeseries, { additionalWrapper: Wrapper, initialRouterConfig: { @@ -125,6 +120,9 @@ describe('useExploreTimeseries', () => { extrapolate: '0', }, }, + }, initialProps: { + query: 'test value', + enabled: true, }, } ); diff --git a/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx b/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx index 1e9e9329e85a2d..539b9a069e58a8 100644 --- a/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx +++ b/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx @@ -45,11 +45,10 @@ describe('useGetTraceItemAttributeValues', () => { ], }); - const {result} = renderHookWithProviders(() => - useGetTraceItemAttributeValues({ + const {result} = renderHookWithProviders(useGetTraceItemAttributeValues, {initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }) + }} ); const tag = { @@ -88,11 +87,10 @@ describe('useGetTraceItemAttributeValues', () => { ], }); - const {result} = renderHookWithProviders(() => - useGetTraceItemAttributeValues({ + const {result} = renderHookWithProviders(useGetTraceItemAttributeValues, {initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'number', - }) + }} ); const tag = { diff --git a/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx b/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx index 6b7ed822b47b00..a16f083bd90c10 100644 --- a/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx +++ b/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx @@ -82,8 +82,7 @@ describe('useProgressiveQuery', () => { }, ], }); - renderHookWithProviders(() => - useProgressiveQuery({ + renderHookWithProviders(useProgressiveQuery, {initialProps: { queryHookImplementation: useMockHookImpl, queryHookArgs: {enabled: true, query: 'test value'}, queryOptions: { @@ -92,7 +91,7 @@ describe('useProgressiveQuery', () => { return defined(results.data) && results.data.meta.dataScanned === 'partial'; }, }, - }) + }} ); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); @@ -133,8 +132,7 @@ describe('useProgressiveQuery', () => { }, ], }); - renderHookWithProviders(() => - useProgressiveQuery({ + renderHookWithProviders(useProgressiveQuery, {initialProps: { queryHookImplementation: useMockHookImpl, queryHookArgs: {enabled: true, query: 'test value'}, queryOptions: { @@ -143,7 +141,7 @@ describe('useProgressiveQuery', () => { return false; }, }, - }) + }} ); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); diff --git a/static/app/views/explore/hooks/useSortByFields.spec.tsx b/static/app/views/explore/hooks/useSortByFields.spec.tsx index d5543347b3d706..8d1b046f4f4d3e 100644 --- a/static/app/views/explore/hooks/useSortByFields.spec.tsx +++ b/static/app/views/explore/hooks/useSortByFields.spec.tsx @@ -46,8 +46,9 @@ describe('useSortByFields', () => { it('returns a valid list of field options in samples mode', () => { const {result} = renderHook( - () => - useSortByFields({ + useSortByFields, + { + wrapper: createWrapper(organization), initialProps: { fields: [ 'id', 'span.op', @@ -59,9 +60,7 @@ describe('useSortByFields', () => { groupBys: [], yAxes: ['avg(span.duration)'], mode: Mode.SAMPLES, - }), - { - wrapper: createWrapper(organization), + }, } ); @@ -77,15 +76,14 @@ describe('useSortByFields', () => { it('returns a valid list of field options in aggregate mode', () => { const {result} = renderHook( - () => - useSortByFields({ + useSortByFields, + { + wrapper: createWrapper(organization), initialProps: { fields: ['span.op', 'span.description'], groupBys: ['span.op'], yAxes: ['avg(span.duration)'], mode: Mode.AGGREGATE, - }), - { - wrapper: createWrapper(organization), + }, } ); diff --git a/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx b/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx index 7b1ec259009490..2846783c2450b5 100644 --- a/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx +++ b/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx @@ -64,11 +64,10 @@ describe('useTraceItemAttributeKeys', () => { mockAttributeKeys ); - const {result} = renderHookWithProviders(() => - useTraceItemAttributeKeys({ + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }) + }} ); await waitFor(() => expect(result.current.isLoading).toBe(false)); @@ -119,11 +118,10 @@ describe('useTraceItemAttributeKeys', () => { 'number' ); - const {result} = renderHookWithProviders(() => - useTraceItemAttributeKeys({ + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'number', - }) + }} ); await waitFor(() => expect(result.current.isLoading).toBe(false)); @@ -173,11 +171,10 @@ describe('useTraceItemAttributeKeys', () => { mockTraceItemAttributeKeysApi(organization.slug, attributesWithInvalidChars); - const {result} = renderHookWithProviders(() => - useTraceItemAttributeKeys({ + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }) + }} ); await waitFor(() => expect(result.current.isLoading).toBe(false)); @@ -227,11 +224,10 @@ describe('useTraceItemAttributeKeys', () => { testAttributeKeys ); - const {result} = renderHookWithProviders(() => - useTraceItemAttributeKeys({ + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }) + }} ); await waitFor(() => expect(result.current.isLoading).toBe(false)); diff --git a/static/app/views/explore/hooks/useVisualizeFields.spec.tsx b/static/app/views/explore/hooks/useVisualizeFields.spec.tsx index e78d753b9816fe..5e93c48fe54c13 100644 --- a/static/app/views/explore/hooks/useVisualizeFields.spec.tsx +++ b/static/app/views/explore/hooks/useVisualizeFields.spec.tsx @@ -57,8 +57,8 @@ describe('useVisualizeFields', () => { }); it('returns numeric fields', () => { - const {result} = renderHook(() => useWrapper('avg(score.ttfb)'), { - wrapper: createWrapper(organization), + const {result} = renderHook(useWrapper, { + wrapper: createWrapper(organization), initialProps: 'avg(score.ttfb)', }); expect(result.current.map(field => field.value)).toEqual([ @@ -69,16 +69,16 @@ describe('useVisualizeFields', () => { }); it('returns numeric fields for count', () => { - const {result} = renderHook(() => useWrapper('count(span.duration)'), { - wrapper: createWrapper(organization), + const {result} = renderHook(useWrapper, { + wrapper: createWrapper(organization), initialProps: 'count(span.duration)', }); expect(result.current.map(field => field.value)).toEqual(['span.duration']); }); it('returns string fields for count_unique', () => { - const {result} = renderHook(() => useWrapper('count_unique(foobar)'), { - wrapper: createWrapper(organization), + const {result} = renderHook(useWrapper, { + wrapper: createWrapper(organization), initialProps: 'count_unique(foobar)', }); expect(result.current.map(field => field.value)).toEqual( diff --git a/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx b/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx index 59eee3a3967c05..122bfd90989fc8 100644 --- a/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx +++ b/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx @@ -59,12 +59,11 @@ describe('useLogsAggregatesTable', () => { }); renderHookWithProviders( - () => - useLogsAggregatesTable({ + useLogsAggregatesTable, + {additionalWrapper: Wrapper, initialProps: { enabled: true, limit: 100, - }), - {additionalWrapper: Wrapper} + }} ); expect(mockNormalRequest).toHaveBeenCalledTimes(1); diff --git a/static/app/views/explore/logs/useLogsQuery.spec.tsx b/static/app/views/explore/logs/useLogsQuery.spec.tsx index 1c61c4d9e51286..b5fc08cde8915d 100644 --- a/static/app/views/explore/logs/useLogsQuery.spec.tsx +++ b/static/app/views/explore/logs/useLogsQuery.spec.tsx @@ -115,7 +115,7 @@ describe('useInfiniteLogsQuery', () => { ); } - const {result, rerender} = renderHookWithProviders(() => useInfiniteLogsQuery(), { + const {result, rerender} = renderHookWithProviders(useInfiniteLogsQuery, { additionalWrapper: createWrapper(), organization, }); @@ -205,7 +205,7 @@ describe('useInfiniteLogsQuery', () => { headers: linkHeaders, }); - const {result, rerender} = renderHookWithProviders(() => useInfiniteLogsQuery(), { + const {result, rerender} = renderHookWithProviders(useInfiniteLogsQuery, { additionalWrapper: createWrapper(), organization, }); @@ -288,8 +288,8 @@ describe('useInfiniteLogsQuery', () => { ], }); - renderHookWithProviders(() => useInfiniteLogsQuery({}), { - additionalWrapper: createWrapper(), + renderHookWithProviders(useInfiniteLogsQuery, { + additionalWrapper: createWrapper(), initialProps: {}, }); expect(mockNormalRequest).toHaveBeenCalledTimes(1); @@ -381,9 +381,9 @@ describe('useInfiniteLogsQuery', () => { ].map(response => MockApiClient.addMockResponse(response)); const {result} = renderHookWithProviders( - () => useInfiniteLogsQuery({highFidelity: true, maxAutoFetches: 3}), + useInfiniteLogsQuery, { - additionalWrapper: createWrapper(), + additionalWrapper: createWrapper(), initialProps: {highFidelity: true, maxAutoFetches: 3}, } ); @@ -434,9 +434,9 @@ describe('useInfiniteLogsQuery', () => { ].map(response => MockApiClient.addMockResponse(response)); const {result} = renderHookWithProviders( - () => useInfiniteLogsQuery({highFidelity: true, maxAutoFetches: 3}), + useInfiniteLogsQuery, { - additionalWrapper: createWrapper(), + additionalWrapper: createWrapper(), initialProps: {highFidelity: true, maxAutoFetches: 3}, } ); @@ -682,7 +682,7 @@ describe('Virtual Streaming Integration (Auto Refresh Behaviour)', () => { headers: linkHeaders, }); - const {result} = renderHookWithProviders(() => useInfiniteLogsQuery(), { + const {result} = renderHookWithProviders(useInfiniteLogsQuery, { additionalWrapper: createWrapper({autoRefresh: 'enabled'}), organization, }); @@ -710,7 +710,7 @@ describe('Virtual Streaming Integration (Auto Refresh Behaviour)', () => { headers: linkHeaders, }); - const {result} = renderHookWithProviders(() => useInfiniteLogsQuery(), { + const {result} = renderHookWithProviders(useInfiniteLogsQuery, { additionalWrapper: createWrapper({autoRefresh: 'idle'}), organization, }); @@ -767,7 +767,7 @@ describe('Virtual Streaming Integration (Auto Refresh Behaviour)', () => { headers: linkHeaders, }); - const {result} = renderHookWithProviders(() => useInfiniteLogsQuery(), { + const {result} = renderHookWithProviders(useInfiniteLogsQuery, { additionalWrapper: createWrapper({autoRefresh: 'enabled'}), organization, }); @@ -829,7 +829,7 @@ describe('Virtual Streaming Integration (Auto Refresh Behaviour)', () => { headers: linkHeaders, }); - const {result} = renderHookWithProviders(() => useInfiniteLogsQuery(), { + const {result} = renderHookWithProviders(useInfiniteLogsQuery, { additionalWrapper: createWrapper({autoRefresh: 'idle'}), // Disable auto refresh to avoid virtual streaming filtering organization, }); diff --git a/static/app/views/explore/logs/useLogsTimeseries.spec.tsx b/static/app/views/explore/logs/useLogsTimeseries.spec.tsx index 2686e72567be38..5c733f1179627c 100644 --- a/static/app/views/explore/logs/useLogsTimeseries.spec.tsx +++ b/static/app/views/explore/logs/useLogsTimeseries.spec.tsx @@ -74,8 +74,8 @@ describe('useLogsTimeseries', () => { }); renderHookWithProviders( - () => - useLogsTimeseries({ + useLogsTimeseries, + {additionalWrapper: Wrapper, initialProps: { enabled: true, timeseriesIngestDelay: 0n, tableData: { @@ -104,8 +104,7 @@ describe('useLogsTimeseries', () => { canResumeAutoFetch: false, resumeAutoFetch: () => {}, }, - }), - {additionalWrapper: Wrapper} + }} ); expect(mockNormalRequest).toHaveBeenCalledTimes(1); diff --git a/static/app/views/explore/logs/useSaveAsItems.spec.tsx b/static/app/views/explore/logs/useSaveAsItems.spec.tsx index a14f03761582f6..6de86a7b9f2859 100644 --- a/static/app/views/explore/logs/useSaveAsItems.spec.tsx +++ b/static/app/views/explore/logs/useSaveAsItems.spec.tsx @@ -105,16 +105,15 @@ describe('useSaveAsItems', () => { it('should open save query modal when save as new query is clicked', () => { const {result} = renderHookWithProviders( - () => - useSaveAsItems({ + useSaveAsItems, + {additionalWrapper: createWrapper(), initialProps: { visualizes: [new VisualizeFunction('count()')], groupBys: ['message.template'], interval: '5m', mode: Mode.AGGREGATE, search: new MutableSearch('message:"test error"'), sortBys: [{field: 'timestamp', kind: 'desc'}], - }), - {additionalWrapper: createWrapper()} + }} ); const saveAsItems = result.current; @@ -163,16 +162,15 @@ describe('useSaveAsItems', () => { ); const {result} = renderHookWithProviders( - () => - useSaveAsItems({ + useSaveAsItems, + {additionalWrapper: createWrapper(), initialProps: { visualizes: [new VisualizeFunction('count()')], groupBys: ['message.template'], interval: '5m', mode: Mode.AGGREGATE, search: new MutableSearch('message:"test"'), sortBys: [{field: 'timestamp', kind: 'desc'}], - }), - {additionalWrapper: createWrapper()} + }} ); await waitFor(() => { @@ -195,16 +193,15 @@ describe('useSaveAsItems', () => { ); const {result} = renderHookWithProviders( - () => - useSaveAsItems({ + useSaveAsItems, + {additionalWrapper: createWrapper(), initialProps: { visualizes: [new VisualizeFunction('count()')], groupBys: ['message.template'], interval: '5m', mode: Mode.AGGREGATE, search: new MutableSearch('message:"test"'), sortBys: [{field: 'timestamp', kind: 'desc'}], - }), - {additionalWrapper: createWrapper()} + }} ); const saveAsItems = result.current; @@ -215,8 +212,8 @@ describe('useSaveAsItems', () => { it('should call saveQuery with correct parameters when modal saves', async () => { const {result} = renderHookWithProviders( - () => - useSaveAsItems({ + useSaveAsItems, + {additionalWrapper: createWrapper(), initialProps: { visualizes: [new VisualizeFunction('count()')], groupBys: ['message.template'], // Note: useSaveQuery uses the value returned by useChartInterval() @@ -225,8 +222,7 @@ describe('useSaveAsItems', () => { mode: Mode.AGGREGATE, search: new MutableSearch('message:"test error"'), sortBys: [{field: 'timestamp', kind: 'desc'}], - }), - {additionalWrapper: createWrapper()} + }} ); const saveAsItems = result.current; diff --git a/static/app/views/explore/logs/useVirtualStreaming.spec.tsx b/static/app/views/explore/logs/useVirtualStreaming.spec.tsx index bb56977454cc03..672162459556da 100644 --- a/static/app/views/explore/logs/useVirtualStreaming.spec.tsx +++ b/static/app/views/explore/logs/useVirtualStreaming.spec.tsx @@ -103,8 +103,8 @@ describe('useVirtualStreaming', () => { ]); const {result} = renderHookWithProviders( - () => useVirtualStreaming({data: mockData}), - {additionalWrapper: createWrapper({autoRefresh: 'enabled'}), organization} + useVirtualStreaming, + {additionalWrapper: createWrapper({autoRefresh: 'enabled'}), organization, initialProps: {data: mockData}} ); await waitFor(() => { @@ -128,8 +128,8 @@ describe('useVirtualStreaming', () => { ]); const {result} = renderHookWithProviders( - () => useVirtualStreaming({data: mockData}), - {additionalWrapper: createWrapper({autoRefresh: 'idle'}), organization} + useVirtualStreaming, + {additionalWrapper: createWrapper({autoRefresh: 'idle'}), organization, initialProps: {data: mockData}} ); expect(result.current.virtualStreamedTimestamp).toBeUndefined(); @@ -145,9 +145,9 @@ describe('useVirtualStreaming', () => { }), ]); - renderHookWithProviders(() => useVirtualStreaming({data: mockData}), { + renderHookWithProviders(useVirtualStreaming, { additionalWrapper: createWrapper({autoRefresh: 'enabled'}), - organization, + organization, initialProps: {data: mockData}, }); await waitFor(() => { @@ -166,8 +166,8 @@ describe('useVirtualStreaming', () => { ]); const {unmount} = renderHookWithProviders( - () => useVirtualStreaming({data: mockData}), - {additionalWrapper: createWrapper({autoRefresh: 'enabled'})} + useVirtualStreaming, + {additionalWrapper: createWrapper({autoRefresh: 'enabled'}), initialProps: {data: mockData}} ); await waitFor(() => { @@ -177,9 +177,9 @@ describe('useVirtualStreaming', () => { unmount(); // Re-render with disabled autorefresh - renderHookWithProviders(() => useVirtualStreaming({data: mockData}), { + renderHookWithProviders(useVirtualStreaming, { additionalWrapper: createWrapper({autoRefresh: 'idle'}), - organization, + organization, initialProps: {data: mockData}, }); await waitFor(() => { diff --git a/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx b/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx index ab0900c70700f1..2e03da07442809 100644 --- a/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx +++ b/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx @@ -42,17 +42,16 @@ describe('useMetricAggregatesTable', () => { method: 'GET', }); renderHookWithProviders( - () => - useMetricAggregatesTable({ + useMetricAggregatesTable, + { + additionalWrapper: MockMetricQueryParamsContext, initialProps: { traceMetric: { name: 'test metric', type: 'counter', }, limit: 100, enabled: true, - }), - { - additionalWrapper: MockMetricQueryParamsContext, + }, } ); diff --git a/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx b/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx index 9a431f99822af8..6a6a09c608119b 100644 --- a/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx +++ b/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx @@ -55,8 +55,9 @@ describe('useMetricSamplesTable', () => { method: 'GET', }); renderHookWithProviders( - () => - useMetricSamplesTable({ + useMetricSamplesTable, + { + additionalWrapper: MockMetricQueryParamsContext, initialProps: { traceMetric: { name: 'test metric', type: 'counter', @@ -64,9 +65,7 @@ describe('useMetricSamplesTable', () => { fields: [], limit: 100, ingestionDelaySeconds: 0, - }), - { - additionalWrapper: MockMetricQueryParamsContext, + }, } ); @@ -106,8 +105,9 @@ describe('useMetricSamplesTable', () => { }); renderHookWithProviders( - () => - useMetricSamplesTable({ + useMetricSamplesTable, + { + additionalWrapper: MockMetricQueryParamsContext, initialProps: { traceMetric: { name: 'test.metric', type: 'counter', @@ -115,9 +115,7 @@ describe('useMetricSamplesTable', () => { fields: ['trace', 'timestamp'], limit: 50, ingestionDelaySeconds: 0, - }), - { - additionalWrapper: MockMetricQueryParamsContext, + }, } ); diff --git a/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx b/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx index ee83741187907f..77dc9d4cf3079a 100644 --- a/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx +++ b/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx @@ -56,13 +56,12 @@ describe('useMetricTimeseries', () => { method: 'GET', }); renderHookWithProviders( - () => - useMetricTimeseries({ + useMetricTimeseries, + { + additionalWrapper: MockMetricQueryParamsContext, initialProps: { traceMetric: {name: 'test metric', type: 'counter'}, enabled: true, - }), - { - additionalWrapper: MockMetricQueryParamsContext, + }, } ); diff --git a/static/app/views/explore/metrics/multiMetricsQueryParams.spec.tsx b/static/app/views/explore/metrics/multiMetricsQueryParams.spec.tsx index b581af5b310273..e72640a5149b34 100644 --- a/static/app/views/explore/metrics/multiMetricsQueryParams.spec.tsx +++ b/static/app/views/explore/metrics/multiMetricsQueryParams.spec.tsx @@ -16,7 +16,7 @@ function Wrapper({children}: {children: ReactNode}) { describe('MultiMetricsQueryParamsProvider', () => { it('sets defaults', () => { - const {result} = renderHookWithProviders(() => useMultiMetricsQueryParams(), { + const {result} = renderHookWithProviders(useMultiMetricsQueryParams, { additionalWrapper: Wrapper, }); @@ -44,7 +44,7 @@ describe('MultiMetricsQueryParamsProvider', () => { }); it('updates to compatible aggregate when changing metrics', () => { - const {result} = renderHookWithProviders(() => useMultiMetricsQueryParams(), { + const {result} = renderHookWithProviders(useMultiMetricsQueryParams, { additionalWrapper: Wrapper, }); @@ -82,7 +82,7 @@ describe('MultiMetricsQueryParamsProvider', () => { }); it('updates incompatible aggregate when changing metrics', () => { - const {result} = renderHookWithProviders(() => useMultiMetricsQueryParams(), { + const {result} = renderHookWithProviders(useMultiMetricsQueryParams, { additionalWrapper: Wrapper, }); diff --git a/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx b/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx index 03f8667d566e02..72d3d11d6a6de8 100644 --- a/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx +++ b/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx @@ -65,11 +65,10 @@ describe('useSaveAsMetricItems', () => { it('should open save query modal when save as new query is clicked', () => { const {result} = renderHook( - () => - useSaveAsMetricItems({ + useSaveAsMetricItems, + {wrapper: createWrapper(), initialProps: { interval: '5m', - }), - {wrapper: createWrapper()} + }} ); const saveAsItems = result.current; @@ -116,11 +115,10 @@ describe('useSaveAsMetricItems', () => { ); const {result} = renderHook( - () => - useSaveAsMetricItems({ + useSaveAsMetricItems, + {wrapper: createWrapper(), initialProps: { interval: '5m', - }), - {wrapper: createWrapper()} + }} ); await waitFor(() => { @@ -141,11 +139,10 @@ describe('useSaveAsMetricItems', () => { ); const {result} = renderHook( - () => - useSaveAsMetricItems({ + useSaveAsMetricItems, + {wrapper: createWrapper(), initialProps: { interval: '5m', - }), - {wrapper: createWrapper()} + }} ); const saveAsItems = result.current; @@ -160,10 +157,7 @@ describe('useSaveAsMetricItems', () => { }); const {result} = renderHook( - () => - useSaveAsMetricItems({ - interval: '5m', - }), + useSaveAsMetricItems, { wrapper: function ({children}: {children?: React.ReactNode}) { return ( @@ -173,6 +167,8 @@ describe('useSaveAsMetricItems', () => { ); + }, initialProps: { + interval: '5m', }, } ); diff --git a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx index 218ac42488e359..9651affef121f7 100644 --- a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx +++ b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx @@ -88,14 +88,13 @@ describe('useMultiQueryTable', () => { ], method: 'GET', }); - renderHookWithProviders(() => - hook({ + renderHookWithProviders(hook, {initialProps: { enabled: true, groupBys: [], query: 'test value', sortBys: [], yAxes: [], - }) + }} ); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); diff --git a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx index d1fdddfbd5bbe5..1b21be6beef561 100644 --- a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx +++ b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx @@ -70,11 +70,10 @@ describe('useMultiQueryTimeseries', () => { ], method: 'GET', }); - renderHookWithProviders(() => - useMultiQueryTimeseries({ + renderHookWithProviders(useMultiQueryTimeseries, {initialProps: { enabled: true, index: 0, - }) + }} ); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); diff --git a/static/app/views/explore/queryParams/context.spec.tsx b/static/app/views/explore/queryParams/context.spec.tsx index 9f5e0ef389342c..231edcafa92e53 100644 --- a/static/app/views/explore/queryParams/context.spec.tsx +++ b/static/app/views/explore/queryParams/context.spec.tsx @@ -1,6 +1,6 @@ import {useMemo, type ReactNode} from 'react'; -import {renderHookWithProviders} from 'sentry-test/reactTestingLibrary'; +import {renderHookWithProviders, render} from 'sentry-test/reactTestingLibrary'; import {useResettableState} from 'sentry/utils/useResettableState'; import { @@ -57,7 +57,7 @@ describe('QueryParamsContext', () => { describe('crossEvents', () => { describe('useQueryParamsCrossEvents', () => { it('should return the crossEvents', () => { - const {result} = renderHookWithProviders(() => useQueryParamsCrossEvents(), { + const {result} = renderHookWithProviders(useQueryParamsCrossEvents, { additionalWrapper: Wrapper, }); @@ -67,14 +67,12 @@ describe('QueryParamsContext', () => { describe('useSetQueryParamsCrossEvents', () => { it('should set the crossEvents', () => { - renderHookWithProviders( - () => { - const setCrossEvents = useSetQueryParamsCrossEvents(); - setCrossEvents([{query: 'bar', type: 'logs'}]); - return useQueryParamsCrossEvents(); - }, - {additionalWrapper: Wrapper} - ); + function QueryParamsCrossEvents() { + const setCrossEvents = useSetQueryParamsCrossEvents(); + setCrossEvents([{query: 'bar', type: 'logs'}]); + return useQueryParamsCrossEvents(); + } + render(); expect(mockSetQueryParams).toHaveBeenCalled(); expect(mockSetQueryParams).toHaveBeenCalledWith({ diff --git a/static/app/views/insights/pages/agents/hooks/useTableCursor.spec.tsx b/static/app/views/insights/pages/agents/hooks/useTableCursor.spec.tsx index 3f1ef6f59d2b40..434e98a649009e 100644 --- a/static/app/views/insights/pages/agents/hooks/useTableCursor.spec.tsx +++ b/static/app/views/insights/pages/agents/hooks/useTableCursor.spec.tsx @@ -4,7 +4,7 @@ import {useTableCursor} from 'sentry/views/insights/pages/agents/hooks/useTableC describe('useTableCursor', () => { it('should return undefined cursor when query param is not present', () => { - const {result} = renderHookWithProviders(() => useTableCursor(), { + const {result} = renderHookWithProviders(useTableCursor, { initialRouterConfig: { location: { pathname: '/', @@ -17,7 +17,7 @@ describe('useTableCursor', () => { }); it('should return cursor value from query params', () => { - const {result} = renderHookWithProviders(() => useTableCursor(), { + const {result} = renderHookWithProviders(useTableCursor, { initialRouterConfig: { location: { pathname: '/', @@ -30,7 +30,7 @@ describe('useTableCursor', () => { }); it('should update cursor value when setCursor is called', async () => { - const {result, router} = renderHookWithProviders(() => useTableCursor(), { + const {result, router} = renderHookWithProviders(useTableCursor, { initialRouterConfig: { location: { pathname: '/', @@ -53,7 +53,7 @@ describe('useTableCursor', () => { }); it('should replace old cursor with new cursor value', async () => { - const {result, router} = renderHookWithProviders(() => useTableCursor(), { + const {result, router} = renderHookWithProviders(useTableCursor, { initialRouterConfig: { location: { pathname: '/', @@ -76,7 +76,7 @@ describe('useTableCursor', () => { }); it('should clear cursor when unsetCursor is called', async () => { - const {result, router} = renderHookWithProviders(() => useTableCursor(), { + const {result, router} = renderHookWithProviders(useTableCursor, { initialRouterConfig: { location: { pathname: '/', @@ -99,7 +99,7 @@ describe('useTableCursor', () => { }); it('should handle undefined cursor in setCursor (e.g., navigating to first page)', async () => { - const {result, router} = renderHookWithProviders(() => useTableCursor(), { + const {result, router} = renderHookWithProviders(useTableCursor, { initialRouterConfig: { location: { pathname: '/', diff --git a/static/app/views/issueDetails/streamline/hooks/useEventQuery.spec.tsx b/static/app/views/issueDetails/streamline/hooks/useEventQuery.spec.tsx index 207006f94c94ca..c07625ecc63b69 100644 --- a/static/app/views/issueDetails/streamline/hooks/useEventQuery.spec.tsx +++ b/static/app/views/issueDetails/streamline/hooks/useEventQuery.spec.tsx @@ -11,7 +11,7 @@ describe('useEventQuery', () => { it('filters issue tokens from event queries', () => { const validQuery = `${tagKey}:${tagValue} device.family:[iphone,pixel]`; - const {result: onlyIssueTokens} = renderHookWithProviders(() => useEventQuery(), { + const {result: onlyIssueTokens} = renderHookWithProviders(useEventQuery, { initialRouterConfig: { location: { pathname: '/issues/1234/', @@ -22,7 +22,7 @@ describe('useEventQuery', () => { }); expect(onlyIssueTokens.current).toBe(''); - const {result: combinedTokens} = renderHookWithProviders(() => useEventQuery(), { + const {result: combinedTokens} = renderHookWithProviders(useEventQuery, { initialRouterConfig: { location: { pathname: '/issues/1234/', @@ -33,7 +33,7 @@ describe('useEventQuery', () => { }); expect(combinedTokens.current).toBe(validQuery); - const {result: onlyEventTokens} = renderHookWithProviders(() => useEventQuery(), { + const {result: onlyEventTokens} = renderHookWithProviders(useEventQuery, { initialRouterConfig: { location: { pathname: '/issues/1234/', diff --git a/static/app/views/onboarding/useConfigureSdk.spec.tsx b/static/app/views/onboarding/useConfigureSdk.spec.tsx index 2d439987de32e5..a4e708edd09956 100644 --- a/static/app/views/onboarding/useConfigureSdk.spec.tsx +++ b/static/app/views/onboarding/useConfigureSdk.spec.tsx @@ -79,13 +79,13 @@ describe('useConfigureSdk', () => { }); it('returns loading state correctly', () => { - const {result} = renderHookWithProviders(() => useConfigureSdk({onComplete})); + const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); expect(result.current.isLoadingData).toBe(true); }); it('opens the framework suggestion modal if platform is supported', async () => { - const {result} = renderHookWithProviders(() => useConfigureSdk({onComplete})); + const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); await act(async () => { await result.current.configureSdk(frameworkModalSupportedPlatform); @@ -95,7 +95,7 @@ describe('useConfigureSdk', () => { }); it('does not open the framework suggestion modal if platform is not supported', async () => { - const {result} = renderHookWithProviders(() => useConfigureSdk({onComplete})); + const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); await act(async () => { await result.current.configureSdk(notFrameworkModalSupportedPlatform); @@ -106,7 +106,7 @@ describe('useConfigureSdk', () => { }); it('creates project only once even if called multiple times', async () => { - const {result} = renderHookWithProviders(() => useConfigureSdk({onComplete})); + const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); mockCreateProject.mockImplementation( () => new Promise(resolve => setTimeout(resolve, 10)) diff --git a/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx b/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx index 9361fc6a4681e1..2b3845598257d3 100644 --- a/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx +++ b/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx @@ -48,10 +48,9 @@ describe('useTrace', () => { body: [], }); - renderHookWithProviders(() => - useTrace({ + renderHookWithProviders(useTrace, {initialProps: { traceSlug: 'test-trace-id', - }) + }} ); // Wait for the hook to make the API call @@ -134,10 +133,9 @@ describe('useTrace', () => { body: [], }); - renderHookWithProviders(() => - useTrace({ + renderHookWithProviders(useTrace, {initialProps: { traceSlug: 'trace-test-id', - }) + }} ); await waitFor(() => { diff --git a/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx b/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx index 2835ab1e8fd105..15bc3139ee5796 100644 --- a/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx +++ b/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx @@ -82,8 +82,8 @@ describe('useTraceMeta', () => { }, }); - const {result} = renderHookWithProviders(() => useTraceMeta(mockedReplayTraces), { - organization, + const {result} = renderHookWithProviders(useTraceMeta, { + organization, initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ @@ -170,8 +170,8 @@ describe('useTraceMeta', () => { }, }); - const {result} = renderHookWithProviders(() => useTraceMeta(mockedReplayTraces), { - organization: org, + const {result} = renderHookWithProviders(useTraceMeta, { + organization: org, initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ @@ -222,8 +222,8 @@ describe('useTraceMeta', () => { statusCode: 400, }); - const {result} = renderHookWithProviders(() => useTraceMeta(mockedReplayTraces), { - organization, + const {result} = renderHookWithProviders(useTraceMeta, { + organization, initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ @@ -290,8 +290,8 @@ describe('useTraceMeta', () => { }, }); - const {result} = renderHookWithProviders(() => useTraceMeta(mockedReplayTraces), { - organization, + const {result} = renderHookWithProviders(useTraceMeta, { + organization, initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ diff --git a/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx b/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx index 51189c27276c57..8d042ebbe6efdc 100644 --- a/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx +++ b/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx @@ -34,13 +34,12 @@ const contextWrapper = () => { describe('useTraceTree', () => { it('returns tree for error case', async () => { const {result} = renderHookWithProviders( - () => - useTraceTree({ + useTraceTree, + {additionalWrapper: contextWrapper(), initialProps: { trace: getMockedTraceResults('error'), traceSlug: 'test-trace', replay: null, - }), - {additionalWrapper: contextWrapper()} + }} ); await waitFor(() => { @@ -50,13 +49,12 @@ describe('useTraceTree', () => { it('returns tree for loading case', async () => { const {result} = renderHookWithProviders( - () => - useTraceTree({ + useTraceTree, + {additionalWrapper: contextWrapper(), initialProps: { trace: getMockedTraceResults('pending'), traceSlug: 'test-trace', replay: null, - }), - {additionalWrapper: contextWrapper()} + }} ); await waitFor(() => { @@ -66,16 +64,15 @@ describe('useTraceTree', () => { it('returns tree for empty success case', async () => { const {result} = renderHookWithProviders( - () => - useTraceTree({ + useTraceTree, + {additionalWrapper: contextWrapper(), initialProps: { trace: getMockedTraceResults('success', { transactions: [], orphan_errors: [], }), traceSlug: 'test-trace', replay: null, - }), - {additionalWrapper: contextWrapper()} + }} ); await waitFor(() => { @@ -120,13 +117,12 @@ describe('useTraceTree', () => { }; const {result} = renderHookWithProviders( - () => - useTraceTree({ + useTraceTree, + {additionalWrapper: contextWrapper(), initialProps: { trace: getMockedTraceResults('success', mockedTrace), traceSlug: 'test-trace', replay: null, - }), - {additionalWrapper: contextWrapper()} + }} ); await waitFor(() => { diff --git a/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx b/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx index 5b13e9dbb48e8f..2eca75c58b78a5 100644 --- a/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx +++ b/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx @@ -31,8 +31,8 @@ describe('useGetActiveIntegratedOrgs', () => { }); const {result} = renderHookWithProviders( - () => useGetActiveIntegratedOrgs({organization}), - {organization} + useGetActiveIntegratedOrgs, + {organization, initialProps: {organization}} ); await waitFor(() => { @@ -71,8 +71,8 @@ describe('useGetActiveIntegratedOrgs', () => { }); const {result} = renderHookWithProviders( - () => useGetActiveIntegratedOrgs({organization}), - {organization} + useGetActiveIntegratedOrgs, + {organization, initialProps: {organization}} ); await waitFor(() => { @@ -92,8 +92,8 @@ describe('useGetActiveIntegratedOrgs', () => { }); const {result} = renderHookWithProviders( - () => useGetActiveIntegratedOrgs({organization}), - {organization} + useGetActiveIntegratedOrgs, + {organization, initialProps: {organization}} ); await waitFor(() => { diff --git a/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx b/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx index 9479d0a577a0b5..960809502b911d 100644 --- a/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx +++ b/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx @@ -98,9 +98,9 @@ describe('useInfiniteTestResults', () => { ); - const {result} = renderHookWithProviders(() => useInfiniteTestResults({}), { + const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, + organization, initialProps: {}, }); await waitFor(() => { @@ -153,14 +153,13 @@ describe('useInfiniteTestResults', () => { ); const {result} = renderHookWithProviders( - () => - useInfiniteTestResults({ - cursor: 'next-cursor', - navigation: 'next', - }), + useInfiniteTestResults, { additionalWrapper, - organization, + organization, initialProps: { + cursor: 'next-cursor', + navigation: 'next', + }, } ); @@ -194,9 +193,9 @@ describe('useInfiniteTestResults', () => { ); - const {result} = renderHookWithProviders(() => useInfiniteTestResults({}), { + const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, + organization, initialProps: {}, }); await waitFor(() => { @@ -226,9 +225,9 @@ describe('useInfiniteTestResults', () => { ); - const {result} = renderHookWithProviders(() => useInfiniteTestResults({}), { + const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, + organization, initialProps: {}, }); await waitFor(() => { @@ -277,9 +276,9 @@ describe('useInfiniteTestResults', () => { ); - const {result} = renderHookWithProviders(() => useInfiniteTestResults({}), { + const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, + organization, initialProps: {}, }); await waitFor(() => { diff --git a/static/app/views/prevent/tests/queries/useRepo.spec.tsx b/static/app/views/prevent/tests/queries/useRepo.spec.tsx index ee1f6680187705..c4f6573211d7af 100644 --- a/static/app/views/prevent/tests/queries/useRepo.spec.tsx +++ b/static/app/views/prevent/tests/queries/useRepo.spec.tsx @@ -37,7 +37,7 @@ describe('useRepo', () => { ); - const {result} = renderHookWithProviders(() => useRepo(), { + const {result} = renderHookWithProviders(useRepo, { additionalWrapper, organization, }); @@ -66,7 +66,7 @@ describe('useRepo', () => { ); - const {result} = renderHookWithProviders(() => useRepo(), { + const {result} = renderHookWithProviders(useRepo, { additionalWrapper, organization, }); diff --git a/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx b/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx index ba2454bc7cec69..81034ad0e760f1 100644 --- a/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx +++ b/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx @@ -69,14 +69,13 @@ describe('useInfiniteRepositoryTokens', () => { ); const {result} = renderHookWithProviders( - () => - useInfiniteRepositoryTokens({ - cursor: undefined, - navigation: undefined, - }), + useInfiniteRepositoryTokens, { organization, - additionalWrapper, + additionalWrapper, initialProps: { + cursor: undefined, + navigation: undefined, + }, } ); @@ -121,14 +120,13 @@ describe('useInfiniteRepositoryTokens', () => { ); const {result} = renderHookWithProviders( - () => - useInfiniteRepositoryTokens({ - cursor: 'next-cursor', - navigation: 'next', - }), + useInfiniteRepositoryTokens, { organization, - additionalWrapper, + additionalWrapper, initialProps: { + cursor: 'next-cursor', + navigation: 'next', + }, } ); @@ -156,14 +154,13 @@ describe('useInfiniteRepositoryTokens', () => { ); const {result} = renderHookWithProviders( - () => - useInfiniteRepositoryTokens({ - cursor: undefined, - navigation: undefined, - }), + useInfiniteRepositoryTokens, { organization, - additionalWrapper, + additionalWrapper, initialProps: { + cursor: undefined, + navigation: undefined, + }, } ); @@ -195,14 +192,13 @@ describe('useInfiniteRepositoryTokens', () => { ); const {result} = renderHookWithProviders( - () => - useInfiniteRepositoryTokens({ - cursor: undefined, - navigation: undefined, - }), + useInfiniteRepositoryTokens, { additionalWrapper, - organization, + organization, initialProps: { + cursor: undefined, + navigation: undefined, + }, } ); @@ -230,14 +226,13 @@ describe('useInfiniteRepositoryTokens', () => { ); const {result} = renderHookWithProviders( - () => - useInfiniteRepositoryTokens({ - cursor: undefined, - navigation: undefined, - }), + useInfiniteRepositoryTokens, { additionalWrapper, - organization, + organization, initialProps: { + cursor: undefined, + navigation: undefined, + }, } ); diff --git a/static/app/views/prevent/tokens/repoTokenTable/hooks/useRegenerateRepositoryToken.spec.tsx b/static/app/views/prevent/tokens/repoTokenTable/hooks/useRegenerateRepositoryToken.spec.tsx index 9a084ece9df39e..d8c7190fa64ebb 100644 --- a/static/app/views/prevent/tokens/repoTokenTable/hooks/useRegenerateRepositoryToken.spec.tsx +++ b/static/app/views/prevent/tokens/repoTokenTable/hooks/useRegenerateRepositoryToken.spec.tsx @@ -43,7 +43,7 @@ describe('useRegenerateRepositoryToken', () => { body: {token: mockToken}, }); - const {result} = renderHook(() => useRegenerateRepositoryToken(), {wrapper}); + const {result} = renderHook(useRegenerateRepositoryToken, {wrapper}); result.current.mutate(mockVariables); @@ -70,7 +70,7 @@ describe('useRegenerateRepositoryToken', () => { body: {detail: 'Internal server error'}, }); - const {result} = renderHook(() => useRegenerateRepositoryToken(), {wrapper}); + const {result} = renderHook(useRegenerateRepositoryToken, {wrapper}); result.current.mutate(mockVariables); @@ -93,7 +93,7 @@ describe('useRegenerateRepositoryToken', () => { const invalidateQueriesSpy = jest.spyOn(queryClient, 'invalidateQueries'); - const {result} = renderHook(() => useRegenerateRepositoryToken(), {wrapper}); + const {result} = renderHook(useRegenerateRepositoryToken, {wrapper}); result.current.mutate(mockVariables); diff --git a/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx b/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx index a0269f96ba9c97..0d5f6edde7925c 100644 --- a/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx +++ b/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx @@ -55,8 +55,8 @@ describe('useReplaySummary', () => { body: mockSummaryData, }); - const {result} = renderHookWithProviders(() => useReplaySummary(mockReplay), { - organization: mockOrganization, + const {result} = renderHookWithProviders(useReplaySummary, { + organization: mockOrganization, initialProps: mockReplay, }); await waitFor(() => { @@ -73,8 +73,8 @@ describe('useReplaySummary', () => { statusCode: 500, body: {detail: 'Internal server error'}, }); - const {result} = renderHookWithProviders(() => useReplaySummary(mockReplay), { - organization: mockOrganization, + const {result} = renderHookWithProviders(useReplaySummary, { + organization: mockOrganization, initialProps: mockReplay, }); await waitFor(() => { @@ -142,8 +142,8 @@ describe('useReplaySummary', () => { body: responsePromise, }); - const {result} = renderHookWithProviders(() => useReplaySummary(mockReplay), { - organization: mockOrganization, + const {result} = renderHookWithProviders(useReplaySummary, { + organization: mockOrganization, initialProps: mockReplay, }); // Wait for the return value to be in pending state @@ -165,8 +165,8 @@ describe('useReplaySummary', () => { body: {status: ReplaySummaryStatus.PROCESSING, data: undefined}, }); - const {result} = renderHookWithProviders(() => useReplaySummary(mockReplay), { - organization: mockOrganization, + const {result} = renderHookWithProviders(useReplaySummary, { + organization: mockOrganization, initialProps: mockReplay, }); await waitFor(() => { @@ -184,8 +184,8 @@ describe('useReplaySummary', () => { }, }); - const {result} = renderHookWithProviders(() => useReplaySummary(mockReplay), { - organization: mockOrganization, + const {result} = renderHookWithProviders(useReplaySummary, { + organization: mockOrganization, initialProps: mockReplay, }); await waitFor(() => { @@ -200,8 +200,8 @@ describe('useReplaySummary', () => { body: {status: ReplaySummaryStatus.ERROR, data: undefined}, }); - const {result} = renderHookWithProviders(() => useReplaySummary(mockReplay), { - organization: mockOrganization, + const {result} = renderHookWithProviders(useReplaySummary, { + organization: mockOrganization, initialProps: mockReplay, }); await waitFor(() => { @@ -228,9 +228,9 @@ describe('useReplaySummary', () => { }); const {result, rerender} = renderHookWithProviders( - () => useReplaySummary(mockReplay), + useReplaySummary, { - organization: mockOrganization, + organization: mockOrganization, initialProps: mockReplay, } ); diff --git a/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx b/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx index dceed74b97687f..e76611c26fd9a9 100644 --- a/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx +++ b/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx @@ -35,7 +35,7 @@ describe('useTraceMeta', () => { }, }); - const {result} = renderHookWithProviders(() => useReplayTraces({replayRecord})); + const {result} = renderHookWithProviders(useReplayTraces, {initialProps: {replayRecord}}); expect(result.current.indexComplete).toBe(false); @@ -61,7 +61,7 @@ describe('useTraceMeta', () => { statusCode: 400, }); - const {result} = renderHookWithProviders(() => useReplayTraces({replayRecord})); + const {result} = renderHookWithProviders(useReplayTraces, {initialProps: {replayRecord}}); expect(result.current.indexComplete).toBe(false); diff --git a/static/app/views/seerExplorer/hooks/useBlockNavigation.spec.tsx b/static/app/views/seerExplorer/hooks/useBlockNavigation.spec.tsx index 7fa4c26d5269a4..3d9cbc6b0adcb0 100644 --- a/static/app/views/seerExplorer/hooks/useBlockNavigation.spec.tsx +++ b/static/app/views/seerExplorer/hooks/useBlockNavigation.spec.tsx @@ -86,7 +86,7 @@ describe('useBlockNavigation', () => { describe('Arrow Key Navigation', () => { it('moves from input to last block on ArrowUp', () => { - renderHook(() => useBlockNavigation(defaultProps)); + renderHook(useBlockNavigation, {initialProps: defaultProps}); // Simulate ArrowUp keydown const event = new KeyboardEvent('keydown', {key: 'ArrowUp'}); @@ -102,7 +102,7 @@ describe('useBlockNavigation', () => { it('moves up through blocks on ArrowUp', () => { const props = {...defaultProps, focusedBlockIndex: 2}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'ArrowUp'}); document.dispatchEvent(event); @@ -116,7 +116,7 @@ describe('useBlockNavigation', () => { it('does not move up from first block', () => { const props = {...defaultProps, focusedBlockIndex: 0}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'ArrowUp'}); document.dispatchEvent(event); @@ -127,7 +127,7 @@ describe('useBlockNavigation', () => { it('moves down through blocks on ArrowDown', () => { const props = {...defaultProps, focusedBlockIndex: 0}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'ArrowDown'}); document.dispatchEvent(event); @@ -141,7 +141,7 @@ describe('useBlockNavigation', () => { it('moves from last block to input on ArrowDown', () => { const props = {...defaultProps, focusedBlockIndex: 2}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'ArrowDown'}); document.dispatchEvent(event); @@ -155,7 +155,7 @@ describe('useBlockNavigation', () => { }); it('does nothing on ArrowDown when already at input', () => { - renderHook(() => useBlockNavigation(defaultProps)); + renderHook(useBlockNavigation, {initialProps: defaultProps}); const event = new KeyboardEvent('keydown', {key: 'ArrowDown'}); document.dispatchEvent(event); @@ -167,7 +167,7 @@ describe('useBlockNavigation', () => { describe('Tab Navigation', () => { it('always returns to input on Tab', () => { const props = {...defaultProps, focusedBlockIndex: 1}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'Tab'}); document.dispatchEvent(event); @@ -181,7 +181,7 @@ describe('useBlockNavigation', () => { }); it('focuses textarea even when already at input', () => { - renderHook(() => useBlockNavigation(defaultProps)); + renderHook(useBlockNavigation, {initialProps: defaultProps}); const event = new KeyboardEvent('keydown', {key: 'Tab'}); document.dispatchEvent(event); @@ -194,7 +194,7 @@ describe('useBlockNavigation', () => { describe('Panel State Control', () => { it('ignores keyboard events when panel is closed', () => { const props = {...defaultProps, isOpen: false}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'ArrowUp'}); document.dispatchEvent(event); @@ -204,7 +204,7 @@ describe('useBlockNavigation', () => { it('responds to keyboard events when panel is open', () => { const props = {...defaultProps, isOpen: true}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'Tab'}); document.dispatchEvent(event); @@ -220,7 +220,7 @@ describe('useBlockNavigation', () => { blocks: [], blockRefs: {current: []}, }; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'ArrowUp'}); document.dispatchEvent(event); @@ -237,7 +237,7 @@ describe('useBlockNavigation', () => { blocks: singleBlock, blockRefs: {current: [createMockElement()]}, }; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); // ArrowUp from input should go to block 0 const arrowUpEvent = new KeyboardEvent('keydown', {key: 'ArrowUp'}); @@ -246,7 +246,7 @@ describe('useBlockNavigation', () => { // ArrowDown from block 0 should go to input const propsAtBlock0 = {...props, focusedBlockIndex: 0}; - renderHook(() => useBlockNavigation(propsAtBlock0)); + renderHook(useBlockNavigation, {initialProps: propsAtBlock0}); const arrowDownEvent = new KeyboardEvent('keydown', {key: 'ArrowDown'}); document.dispatchEvent(arrowDownEvent); @@ -257,7 +257,7 @@ describe('useBlockNavigation', () => { describe('Event Cleanup', () => { it('removes event listener on unmount', () => { const removeEventListenerSpy = jest.spyOn(document, 'removeEventListener'); - const {unmount} = renderHook(() => useBlockNavigation(defaultProps)); + const {unmount} = renderHook(useBlockNavigation, {initialProps: defaultProps}); unmount(); @@ -298,7 +298,7 @@ describe('useBlockNavigation', () => { ...defaultProps, blockRefs: {current: [null, testElement2, testElement3]}, }; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'ArrowUp'}); document.dispatchEvent(event); @@ -313,7 +313,7 @@ describe('useBlockNavigation', () => { it('handles null textarea ref gracefully', () => { const props = {...defaultProps, textareaRef: {current: null}}; - renderHook(() => useBlockNavigation(props)); + renderHook(useBlockNavigation, {initialProps: props}); const event = new KeyboardEvent('keydown', {key: 'Tab'}); document.dispatchEvent(event); diff --git a/static/app/views/seerExplorer/hooks/useSeerExplorer.spec.tsx b/static/app/views/seerExplorer/hooks/useSeerExplorer.spec.tsx index d49fbf08eb5432..bf52a97ee5b03f 100644 --- a/static/app/views/seerExplorer/hooks/useSeerExplorer.spec.tsx +++ b/static/app/views/seerExplorer/hooks/useSeerExplorer.spec.tsx @@ -17,7 +17,7 @@ describe('useSeerExplorer', () => { describe('Initial State', () => { it('returns initial state with no session data', () => { - const {result} = renderHookWithProviders(() => useSeerExplorer(), { + const {result} = renderHookWithProviders(useSeerExplorer, { organization, }); @@ -77,7 +77,7 @@ describe('useSeerExplorer', () => { }, }); - const {result} = renderHookWithProviders(() => useSeerExplorer(), { + const {result} = renderHookWithProviders(useSeerExplorer, { organization, }); @@ -111,7 +111,7 @@ describe('useSeerExplorer', () => { body: {detail: 'Server error'}, }); - const {result} = renderHookWithProviders(() => useSeerExplorer(), { + const {result} = renderHookWithProviders(useSeerExplorer, { organization, }); @@ -130,7 +130,7 @@ describe('useSeerExplorer', () => { body: {session: null}, }); - const {result} = renderHookWithProviders(() => useSeerExplorer(), { + const {result} = renderHookWithProviders(useSeerExplorer, { organization, }); @@ -151,7 +151,7 @@ describe('useSeerExplorer', () => { body: {session: null}, }); - const {result} = renderHookWithProviders(() => useSeerExplorer(), { + const {result} = renderHookWithProviders(useSeerExplorer, { organization, }); @@ -163,7 +163,7 @@ describe('useSeerExplorer', () => { }); it('filters messages based on deleted index', () => { - const {result} = renderHookWithProviders(() => useSeerExplorer(), { + const {result} = renderHookWithProviders(useSeerExplorer, { organization, }); @@ -177,7 +177,7 @@ describe('useSeerExplorer', () => { describe('Polling Logic', () => { it('returns false for polling when no session exists', () => { - const {result} = renderHookWithProviders(() => useSeerExplorer(), { + const {result} = renderHookWithProviders(useSeerExplorer, { organization, }); diff --git a/static/gsAdmin/views/customerDetails.spec.tsx b/static/gsAdmin/views/customerDetails.spec.tsx index a8bf012a247609..7aecc55069c48d 100644 --- a/static/gsAdmin/views/customerDetails.spec.tsx +++ b/static/gsAdmin/views/customerDetails.spec.tsx @@ -690,22 +690,16 @@ describe('Customer Details', () => { MockApiClient.clearMockResponses(); }); + function populateChartData() { + const series = useSeries(); + return populateChartData(data.intervals, data.groups, series); + } it('populates chart data', () => { setUpMocks(organization); const data = StatsBillingPeriodFixture(); - const {result: chartData} = renderHook( - () => { - const series = useSeries(); - return populateChartData(data.intervals, data.groups, series); - }, - { - wrapper: ({children}) => { - return {children}; - }, - } - ); + const {result: chartData} = render(); expect(chartData.current).toEqual([ { diff --git a/static/gsApp/hooks/dashboardsLimit.spec.tsx b/static/gsApp/hooks/dashboardsLimit.spec.tsx index 6d34b16a9d6cc2..e6bd04b339d738 100644 --- a/static/gsApp/hooks/dashboardsLimit.spec.tsx +++ b/static/gsApp/hooks/dashboardsLimit.spec.tsx @@ -39,7 +39,7 @@ describe('useDashboardsLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); @@ -66,7 +66,7 @@ describe('useDashboardsLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); @@ -110,7 +110,7 @@ describe('useDashboardsLimit', () => { match: [MockApiClient.matchQuery({per_page: 10, filter: 'excludePrebuilt'})], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); @@ -152,7 +152,7 @@ describe('useDashboardsLimit', () => { match: [MockApiClient.matchQuery({per_page: 3, filter: 'excludePrebuilt'})], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); @@ -198,7 +198,7 @@ describe('useDashboardsLimit', () => { match: [MockApiClient.matchQuery({per_page: 2, filter: 'excludePrebuilt'})], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); @@ -240,7 +240,7 @@ describe('useDashboardsLimit', () => { match: [MockApiClient.matchQuery({per_page: 10, filter: 'excludePrebuilt'})], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); @@ -274,7 +274,7 @@ describe('useDashboardsLimit', () => { match: [MockApiClient.matchQuery({per_page: 10, filter: 'excludePrebuilt'})], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); @@ -306,7 +306,7 @@ describe('useDashboardsLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useDashboardsLimit(), { + const {result} = renderHookWithProviders(useDashboardsLimit, { organization: mockOrganization, }); diff --git a/static/gsApp/hooks/genAiAccess.spec.tsx b/static/gsApp/hooks/genAiAccess.spec.tsx index 83d5364ba6e96d..4cda9b92056b13 100644 --- a/static/gsApp/hooks/genAiAccess.spec.tsx +++ b/static/gsApp/hooks/genAiAccess.spec.tsx @@ -52,8 +52,8 @@ describe('useGenAiConsentButtonAccess', () => { }); mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); - const {result} = renderHook(() => useGenAiConsentButtonAccess({subscription}), { - wrapper: contextWrapper(organization), + const {result} = renderHook(useGenAiConsentButtonAccess, { + wrapper: contextWrapper(organization), initialProps: {subscription}, }); expect(result.current).toEqual( @@ -83,8 +83,8 @@ describe('useGenAiConsentButtonAccess', () => { }); mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); - const {result} = renderHook(() => useGenAiConsentButtonAccess({subscription}), { - wrapper: contextWrapper(organization), + const {result} = renderHook(useGenAiConsentButtonAccess, { + wrapper: contextWrapper(organization), initialProps: {subscription}, }); expect(result.current).toEqual( @@ -114,8 +114,8 @@ describe('useGenAiConsentButtonAccess', () => { }); mockUseUser.mockReturnValue(UserFixture({isSuperuser: true})); - const {result} = renderHook(() => useGenAiConsentButtonAccess({subscription}), { - wrapper: contextWrapper(organization), + const {result} = renderHook(useGenAiConsentButtonAccess, { + wrapper: contextWrapper(organization), initialProps: {subscription}, }); expect(result.current).toEqual( @@ -145,8 +145,8 @@ describe('useGenAiConsentButtonAccess', () => { }); mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); - const {result} = renderHook(() => useGenAiConsentButtonAccess({subscription}), { - wrapper: contextWrapper(organization), + const {result} = renderHook(useGenAiConsentButtonAccess, { + wrapper: contextWrapper(organization), initialProps: {subscription}, }); expect(result.current).toEqual( @@ -179,8 +179,8 @@ describe('useGenAiConsentButtonAccess', () => { }); mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); - const {result} = renderHook(() => useGenAiConsentButtonAccess({subscription}), { - wrapper: contextWrapper(organization), + const {result} = renderHook(useGenAiConsentButtonAccess, { + wrapper: contextWrapper(organization), initialProps: {subscription}, }); expect(result.current).toEqual( @@ -210,8 +210,8 @@ describe('useGenAiConsentButtonAccess', () => { }); mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); - const {result} = renderHook(() => useGenAiConsentButtonAccess({subscription}), { - wrapper: contextWrapper(organization), + const {result} = renderHook(useGenAiConsentButtonAccess, { + wrapper: contextWrapper(organization), initialProps: {subscription}, }); expect(result.current).toEqual( diff --git a/static/gsApp/hooks/useMaxPickableDays.spec.tsx b/static/gsApp/hooks/useMaxPickableDays.spec.tsx index 8e3672cd2d94ed..8c23fdf0a7acd9 100644 --- a/static/gsApp/hooks/useMaxPickableDays.spec.tsx +++ b/static/gsApp/hooks/useMaxPickableDays.spec.tsx @@ -12,10 +12,9 @@ import {useMaxPickableDays} from './useMaxPickableDays'; describe('useMaxPickableDays', () => { describe('without downsampled-date-page-filter', () => { it('returns 90/90 for transactions', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.TRANSACTIONS], - }) + }} ); expect(result.current).toEqual({ @@ -25,10 +24,9 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for replays', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.REPLAYS], - }) + }} ); expect(result.current).toEqual({ @@ -38,10 +36,9 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for spans without flag', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.SPANS], - }) + }} ); expect(result.current).toEqual({ @@ -53,14 +50,13 @@ describe('useMaxPickableDays', () => { it('returns 90/90 for spans with flag', () => { const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ - dataCategories: [DataCategory.SPANS], - }), + useMaxPickableDays, { organization: OrganizationFixture({ features: ['visibility-explore-range-high'], - }), + }), initialProps: { + dataCategories: [DataCategory.SPANS], + }, } ); @@ -72,10 +68,9 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for tracemetrics', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.TRACE_METRICS], - }) + }} ); expect(result.current).toEqual({ @@ -86,10 +81,9 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for logs', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [DataCategory.LOG_BYTE, DataCategory.LOG_ITEM], - }) + }} ); expect(result.current).toEqual({ @@ -100,8 +94,7 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for many without flag', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [ DataCategory.SPANS, DataCategory.SPANS_INDEXED, @@ -109,7 +102,7 @@ describe('useMaxPickableDays', () => { DataCategory.LOG_BYTE, DataCategory.LOG_ITEM, ], - }) + }} ); expect(result.current).toEqual({ @@ -120,15 +113,14 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for profiles', () => { - const {result} = renderHookWithProviders(() => - useMaxPickableDays({ + const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { dataCategories: [ DataCategory.PROFILE_CHUNKS, DataCategory.PROFILE_CHUNKS_UI, DataCategory.PROFILE_DURATION, DataCategory.PROFILE_DURATION_UI, ], - }) + }} ); expect(result.current).toEqual({ @@ -163,11 +155,10 @@ describe('useMaxPickableDays', () => { it('returns 30/90 for transactions', () => { const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [DataCategory.TRANSACTIONS], - }), - {organization} + }} ); expect(result.current).toEqual({ @@ -178,11 +169,10 @@ describe('useMaxPickableDays', () => { it('returns 30/90 for replays', () => { const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [DataCategory.REPLAYS], - }), - {organization} + }} ); expect(result.current).toEqual({ @@ -194,11 +184,10 @@ describe('useMaxPickableDays', () => { it('returns 121/121 for spans on 2025/12/31', () => { jest.useFakeTimers().setSystemTime(new Date(2025, 11, 31)); const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [DataCategory.SPANS], - }), - {organization} + }} ); expect(result.current).toEqual({ @@ -211,11 +200,10 @@ describe('useMaxPickableDays', () => { it('returns 396/396 for spans on 2027/01/01', () => { jest.useFakeTimers().setSystemTime(new Date(2027, 0, 1)); const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [DataCategory.SPANS], - }), - {organization} + }} ); expect(result.current).toEqual({ @@ -227,11 +215,10 @@ describe('useMaxPickableDays', () => { it('returns 30/30 days for tracemetrics', () => { const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [DataCategory.TRACE_METRICS], - }), - {organization} + }} ); expect(result.current).toEqual({ @@ -243,11 +230,10 @@ describe('useMaxPickableDays', () => { it('returns 30/30 days for logs', () => { const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [DataCategory.LOG_BYTE, DataCategory.LOG_ITEM], - }), - {organization} + }} ); expect(result.current).toEqual({ @@ -260,8 +246,8 @@ describe('useMaxPickableDays', () => { it('returns 396/396 for many without flag', () => { jest.useFakeTimers().setSystemTime(new Date(2027, 0, 1)); const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [ DataCategory.SPANS, DataCategory.SPANS_INDEXED, @@ -269,8 +255,7 @@ describe('useMaxPickableDays', () => { DataCategory.LOG_BYTE, DataCategory.LOG_ITEM, ], - }), - {organization} + }} ); expect(result.current).toEqual({ @@ -282,16 +267,15 @@ describe('useMaxPickableDays', () => { it('returns 30/90 for profiles', () => { const {result} = renderHookWithProviders( - () => - useMaxPickableDays({ + useMaxPickableDays, + {organization, initialProps: { dataCategories: [ DataCategory.PROFILE_CHUNKS, DataCategory.PROFILE_CHUNKS_UI, DataCategory.PROFILE_DURATION, DataCategory.PROFILE_DURATION_UI, ], - }), - {organization} + }} ); expect(result.current).toEqual({ diff --git a/static/gsApp/hooks/useMetricDetectorLimit.spec.tsx b/static/gsApp/hooks/useMetricDetectorLimit.spec.tsx index 75124d16bfeafc..8e79f294ae9f31 100644 --- a/static/gsApp/hooks/useMetricDetectorLimit.spec.tsx +++ b/static/gsApp/hooks/useMetricDetectorLimit.spec.tsx @@ -34,7 +34,7 @@ describe('useMetricDetectorLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useMetricDetectorLimit(), { + const {result} = renderHookWithProviders(useMetricDetectorLimit, { organization: mockOrganizationWithoutFeature, }); @@ -57,7 +57,7 @@ describe('useMetricDetectorLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useMetricDetectorLimit(), { + const {result} = renderHookWithProviders(useMetricDetectorLimit, { organization: mockOrganization, }); @@ -95,7 +95,7 @@ describe('useMetricDetectorLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useMetricDetectorLimit(), { + const {result} = renderHookWithProviders(useMetricDetectorLimit, { organization: mockOrganization, }); @@ -141,7 +141,7 @@ describe('useMetricDetectorLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useMetricDetectorLimit(), { + const {result} = renderHookWithProviders(useMetricDetectorLimit, { organization: mockOrganization, }); @@ -177,7 +177,7 @@ describe('useMetricDetectorLimit', () => { body: [], }); - const {result} = renderHookWithProviders(() => useMetricDetectorLimit(), { + const {result} = renderHookWithProviders(useMetricDetectorLimit, { organization: mockOrganization, }); @@ -214,7 +214,7 @@ describe('useMetricDetectorLimit', () => { statusCode: 500, }); - const {result} = renderHookWithProviders(() => useMetricDetectorLimit(), { + const {result} = renderHookWithProviders(useMetricDetectorLimit, { organization: mockOrganization, }); diff --git a/static/gsApp/hooks/useProductBillingAccess.spec.tsx b/static/gsApp/hooks/useProductBillingAccess.spec.tsx index 8383e6395ac98a..bb2c5fa4c48846 100644 --- a/static/gsApp/hooks/useProductBillingAccess.spec.tsx +++ b/static/gsApp/hooks/useProductBillingAccess.spec.tsx @@ -19,9 +19,9 @@ describe('useProductBillingAccess', () => { }); it('returns true if the org has billing access to the given product', () => { const {result} = renderHookWithProviders( - () => useProductBillingAccess(DataCategory.ERRORS), + useProductBillingAccess, { - organization, + organization, initialProps: DataCategory.ERRORS, } ); expect(result.current).toBe(true); @@ -29,9 +29,9 @@ describe('useProductBillingAccess', () => { it('returns false if the org does not have billing access to the given product', () => { const {result} = renderHookWithProviders( - () => useProductBillingAccess(DataCategory.TRANSACTIONS), + useProductBillingAccess, { - organization, + organization, initialProps: DataCategory.TRANSACTIONS, } ); expect(result.current).toBe(false); @@ -39,9 +39,9 @@ describe('useProductBillingAccess', () => { it('uses parent add-on context when appropriate', () => { const {result: result1} = renderHookWithProviders( - () => useProductBillingAccess(DataCategory.SEER_USER), + useProductBillingAccess, { - organization, + organization, initialProps: DataCategory.SEER_USER, } ); expect(result1.current).toBe(false); @@ -56,9 +56,9 @@ describe('useProductBillingAccess', () => { }); const {result: result2} = renderHookWithProviders( - () => useProductBillingAccess(DataCategory.SEER_USER), + useProductBillingAccess, { - organization, + organization, initialProps: DataCategory.SEER_USER, } ); expect(result2.current).toBe(false); // still false because add-on parent is not enabled @@ -72,9 +72,9 @@ describe('useProductBillingAccess', () => { }); const {result: result3} = renderHookWithProviders( - () => useProductBillingAccess(DataCategory.SEER_USER), + useProductBillingAccess, { - organization, + organization, initialProps: DataCategory.SEER_USER, } ); expect(result3.current).toBe(true); // now true because add-on parent is enabled From 91f8172954dc1dae45941e53606a0fa80159f472 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 23 Jan 2026 10:59:56 -0800 Subject: [PATCH 5/7] fix whitespace errors, some types. more to go --- .../app/actionCreators/savedSearches.spec.tsx | 14 +- .../app/bootstrap/boostrapRequests.spec.tsx | 35 ++- static/app/components/acl/useRole.spec.tsx | 12 +- .../charts/useChartXRangeSelection.spec.tsx | 98 +++--- .../components/core/layout/styles.spec.tsx | 41 +-- .../app/components/prevent/summary.spec.tsx | 12 +- .../useSyncScrollMargin.spec.ts | 5 +- .../replays/replayLiveIndicator.spec.tsx | 50 ++-- .../searchQueryBuilder/hooks.spec.tsx | 23 +- .../workflowEngine/form/useFormField.spec.tsx | 15 +- static/app/utils/api/apiOptions.spec.tsx | 8 +- static/app/utils/demoMode/demoTours.spec.tsx | 33 +- .../list/useListItemCheckboxState.spec.ts | 35 ++- .../hooks/useProfileFunctionTrends.spec.tsx | 28 +- .../hooks/useProfileFunctions.spec.tsx | 14 +- .../app/utils/url/useQueryParamState.spec.tsx | 64 ++-- static/app/utils/useIsMountedRef.spec.tsx | 2 +- .../app/utils/useLocalStorageState.spec.tsx | 4 +- static/app/utils/useMaxPickableDays.spec.tsx | 56 ++-- .../app/utils/useUpdateOrganization.spec.tsx | 6 +- .../hooks/useLogsWidgetQuery.spec.tsx | 86 +++--- .../hooks/useSpansWidgetQuery.spec.tsx | 282 +++++++++--------- .../hooks/useTraceMetricsWidgetQuery.spec.tsx | 105 ++++--- .../hooks/useMetricDetectorAnomalies.spec.tsx | 7 +- .../useMetricDetectorAnomalyPeriods.spec.tsx | 7 +- ...seMetricDetectorAnomalyThresholds.spec.tsx | 82 ++--- .../hooks/useExploreAggregatesTable.spec.tsx | 48 ++- .../hooks/useExploreSpansTable.spec.tsx | 46 ++- .../hooks/useExploreTimeseries.spec.tsx | 44 ++- .../useGetTraceItemAttributeValues.spec.tsx | 14 +- .../hooks/useProgressiveQuery.spec.tsx | 16 +- .../explore/hooks/useSortByFields.spec.tsx | 54 ++-- .../hooks/useTraceItemAttributeKeys.spec.tsx | 28 +- .../explore/hooks/useVisualizeFields.spec.tsx | 9 +- .../logs/useLogsAggregatesTable.spec.tsx | 14 +- .../views/explore/logs/useLogsQuery.spec.tsx | 23 +- .../explore/logs/useLogsTimeseries.spec.tsx | 64 ++-- .../explore/logs/useSaveAsItems.spec.tsx | 92 +++--- .../explore/logs/useVirtualStreaming.spec.tsx | 32 +- .../hooks/useMetricAggregatesTable.spec.tsx | 22 +- .../hooks/useMetricSamplesTable.spec.tsx | 48 ++- .../hooks/useMetricTimeseries.spec.tsx | 16 +- .../metrics/useSaveAsMetricItems.spec.tsx | 66 ++-- .../hooks/useMultiQueryTable.spec.tsx | 7 +- .../hooks/useMultiQueryTimeseries.spec.tsx | 7 +- .../explore/queryParams/context.spec.tsx | 2 +- .../views/onboarding/useConfigureSdk.spec.tsx | 16 +- .../traceApi/useTrace.spec.tsx | 14 +- .../traceApi/useTraceMeta.spec.tsx | 12 +- .../traceApi/useTraceTree.spec.tsx | 70 ++--- .../useGetActiveIntegratedOrgs.spec.tsx | 24 +- .../tests/queries/useGetTestResults.spec.tsx | 30 +- .../useInfiniteRepositoryTokens.spec.tsx | 90 +++--- .../detail/ai/useReplaySummary.spec.tsx | 28 +- .../detail/trace/useReplayTraces.spec.tsx | 8 +- static/gsApp/hooks/genAiAccess.spec.tsx | 18 +- .../gsApp/hooks/useMaxPickableDays.spec.tsx | 185 ++++++------ .../hooks/useProductBillingAccess.spec.tsx | 50 ++-- 58 files changed, 1186 insertions(+), 1135 deletions(-) diff --git a/static/app/actionCreators/savedSearches.spec.tsx b/static/app/actionCreators/savedSearches.spec.tsx index eebb6a24366807..f2d830f2ab7292 100644 --- a/static/app/actionCreators/savedSearches.spec.tsx +++ b/static/app/actionCreators/savedSearches.spec.tsx @@ -35,13 +35,13 @@ describe('useFetchRecentSearches', () => { ], }); - const {result} = renderHookWithProviders( - useFetchRecentSearches, - {organization, initialProps: { - savedSearchType: SavedSearchType.TRACEMETRIC, - namespace, - }} - ); + const {result} = renderHookWithProviders(useFetchRecentSearches, { + organization, + initialProps: { + savedSearchType: SavedSearchType.TRACEMETRIC, + namespace, + }, + }); await waitFor(() => expect(result.current.isSuccess).toBe(true)); diff --git a/static/app/bootstrap/boostrapRequests.spec.tsx b/static/app/bootstrap/boostrapRequests.spec.tsx index ad3c6aadb43107..81e6946a43d16d 100644 --- a/static/app/bootstrap/boostrapRequests.spec.tsx +++ b/static/app/bootstrap/boostrapRequests.spec.tsx @@ -49,7 +49,10 @@ describe('useBootstrapOrganizationQuery', () => { query: {detailed: 0, include_feature_flags: 1}, }); - const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); + const {result} = renderHook(useBootstrapOrganizationQuery, { + wrapper, + initialProps: orgSlug, + }); await waitFor(() => expect(result.current.data).toBeDefined()); expect(JSON.stringify(OrganizationStore.get().organization)).toEqual( @@ -64,7 +67,10 @@ describe('useBootstrapOrganizationQuery', () => { body: {}, }); - const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); + const {result} = renderHook(useBootstrapOrganizationQuery, { + wrapper, + initialProps: orgSlug, + }); await waitFor(() => expect(result.current.error).toBeDefined()); expect(OrganizationStore.get().organization).toBeNull(); @@ -75,7 +81,10 @@ describe('useBootstrapOrganizationQuery', () => { }); it('does not fetch when orgSlug is null', () => { - const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: null}); + const {result} = renderHook(useBootstrapOrganizationQuery, { + wrapper, + initialProps: null, + }); expect(result.current.data).toBeUndefined(); }); @@ -84,7 +93,10 @@ describe('useBootstrapOrganizationQuery', () => { orgSlug: org.slug, organization: Promise.resolve>([org, undefined, undefined]), }; - const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); + const {result} = renderHook(useBootstrapOrganizationQuery, { + wrapper, + initialProps: orgSlug, + }); await waitFor(() => expect(result.current.data).toBeDefined()); expect(window.__sentry_preload?.organization).toBeUndefined(); }); @@ -105,7 +117,10 @@ describe('useBootstrapOrganizationQuery', () => { query: {detailed: 0, include_feature_flags: 1}, }); - const {result} = renderHook(useBootstrapOrganizationQuery, {wrapper, initialProps: orgSlug}); + const {result} = renderHook(useBootstrapOrganizationQuery, { + wrapper, + initialProps: orgSlug, + }); await waitFor(() => expect(result.current.data).toBeDefined()); expect(JSON.stringify(OrganizationStore.get().organization?.features)).toEqual( JSON.stringify(['enable-issues']) @@ -186,7 +201,10 @@ describe('useBootstrapProjectsQuery', () => { }, }); - const {result} = renderHook(useBootstrapProjectsQuery, {wrapper, initialProps: orgSlug}); + const {result} = renderHook(useBootstrapProjectsQuery, { + wrapper, + initialProps: orgSlug, + }); await waitFor(() => expect(result.current.data).toBeDefined()); expect(ProjectsStore.getState().projects).toEqual(mockProjects); @@ -198,7 +216,10 @@ describe('useBootstrapProjectsQuery', () => { statusCode: 500, }); - const {result} = renderHook(useBootstrapProjectsQuery, {wrapper, initialProps: orgSlug}); + const {result} = renderHook(useBootstrapProjectsQuery, { + wrapper, + initialProps: orgSlug, + }); await waitFor(() => expect(result.current.error).toBeDefined()); expect(ProjectsStore.getState().projects).toEqual([]); diff --git a/static/app/components/acl/useRole.spec.tsx b/static/app/components/acl/useRole.spec.tsx index 7fe5d47dc22e97..0fb0387580c145 100644 --- a/static/app/components/acl/useRole.spec.tsx +++ b/static/app/components/acl/useRole.spec.tsx @@ -25,7 +25,8 @@ describe('useRole', () => { it('has a sufficient role', () => { const {result} = renderHookWithProviders(useRole, { - organization, initialProps: {role: 'attachmentsRole'}, + organization, + initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(true); expect(result.current.roleRequired).toBe('admin'); @@ -38,7 +39,8 @@ describe('useRole', () => { }); OrganizationStore.onUpdate(org, {replace: true}); const {result} = renderHookWithProviders(useRole, { - organization: org, initialProps: {role: 'attachmentsRole'}, + organization: org, + initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(false); }); @@ -51,7 +53,8 @@ describe('useRole', () => { }); OrganizationStore.onUpdate(org, {replace: true}); const {result} = renderHookWithProviders(useRole, { - organization: org, initialProps: {role: 'attachmentsRole'}, + organization: org, + initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(true); }); @@ -60,7 +63,8 @@ describe('useRole', () => { const org = {...organization, orgRoleList: []}; OrganizationStore.onUpdate(org, {replace: true}); const {result} = renderHookWithProviders(useRole, { - organization: org, initialProps: {role: 'attachmentsRole'}, + organization: org, + initialProps: {role: 'attachmentsRole'}, }); expect(result.current.hasRole).toBe(false); }); diff --git a/static/app/components/charts/useChartXRangeSelection.spec.tsx b/static/app/components/charts/useChartXRangeSelection.spec.tsx index 51adc33c8f9b1a..d14bbdebd411cd 100644 --- a/static/app/components/charts/useChartXRangeSelection.spec.tsx +++ b/static/app/components/charts/useChartXRangeSelection.spec.tsx @@ -40,21 +40,23 @@ describe('useChartXRangeSelection', () => { describe('initial state', () => { it('should return brush configuration when not disabled', () => { - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, - }} - ); + }, + }); expect(result.current.brush).toBeDefined(); expect(result.current.toolBox).toBeDefined(); }); it('should return undefined brush when disabled', () => { - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, disabled: true, - }} - ); + }, + }); expect(result.current.brush).toBeUndefined(); expect(result.current.toolBox).toBeUndefined(); @@ -65,11 +67,12 @@ describe('useChartXRangeSelection', () => { it('should hide tooltip when brush starts', () => { const onSelectionStart = jest.fn(); - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, onSelectionStart, - }} - ); + }, + }); act(() => { result.current.onBrushStart({} as any, mockChartInstance); @@ -85,11 +88,12 @@ describe('useChartXRangeSelection', () => { const disconnectSpy = jest.fn(); jest.spyOn(require('echarts'), 'disconnect').mockImplementation(disconnectSpy); - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, chartsGroupName: 'test-group', - }} - ); + }, + }); act(() => { result.current.onBrushStart({} as any, mockChartInstance); @@ -140,11 +144,12 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, onSelectionEnd, - }} - ); + }, + }); const mockEvent = { areas: [ @@ -208,11 +213,12 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, onSelectionEnd, - }} - ); + }, + }); const mockEvent = { areas: [ @@ -270,11 +276,12 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, chartsGroupName: 'test-group', - }} - ); + }, + }); const mockEvent = { areas: [{coordRange: [10, 90], panelId: 'test-panel-id'}], @@ -321,11 +328,12 @@ describe('useChartXRangeSelection', () => {
Action Menu
)); - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, actionMenuRenderer, - }} - ); + }, + }); act(() => { result.current.onBrushEnd( @@ -382,13 +390,14 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, actionMenuRenderer: _params => (
Action Menu
), - }} - ); + }, + }); act(() => { result.current.onBrushEnd( @@ -414,10 +423,11 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - renderHook(useChartXRangeSelection, {initialProps: { + renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, - }} - ); + }, + }); await waitFor(() => { expect(mockEchartsInstance.dispatchAction).toHaveBeenCalledWith({ @@ -498,11 +508,12 @@ describe('useChartXRangeSelection', () => { panelId: 'initial-panel-id', }; - renderHook(useChartXRangeSelection, {initialProps: { + renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, initialSelection, - }} - ); + }, + }); await waitFor(() => { expect(mockEchartsInstance.dispatchAction).toHaveBeenCalledWith({ @@ -702,11 +713,12 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, onInsideSelectionClick, - }} - ); + }, + }); // Create a selection first act(() => { @@ -782,11 +794,12 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, onOutsideSelectionClick, - }} - ); + }, + }); // Create a selection first act(() => { @@ -860,11 +873,12 @@ describe('useChartXRangeSelection', () => { getEchartsInstance: () => mockEchartsInstance, } as unknown as EChartsReact; - const {result} = renderHook(useChartXRangeSelection, {initialProps: { + const {result} = renderHook(useChartXRangeSelection, { + initialProps: { chartRef: mockChartRef, onOutsideSelectionClick, - }} - ); + }, + }); // Create a selection first act(() => { diff --git a/static/app/components/core/layout/styles.spec.tsx b/static/app/components/core/layout/styles.spec.tsx index e81a4167002dde..6cc7231f21456f 100644 --- a/static/app/components/core/layout/styles.spec.tsx +++ b/static/app/components/core/layout/styles.spec.tsx @@ -59,7 +59,8 @@ const setupMediaQueries = ( describe('useResponsivePropValue', () => { it('returns identity for non-responsive values', () => { const {result} = renderHook(useResponsivePropValue, { - wrapper: createWrapper(), initialProps: 'hello', + wrapper: createWrapper(), + initialProps: 'hello', }); expect(result.current).toBe('hello'); @@ -80,7 +81,8 @@ describe('useResponsivePropValue', () => { }; const {result} = renderHook(useResponsivePropValue, { - wrapper: createWrapper(), initialProps: responsiveValue, + wrapper: createWrapper(), + initialProps: responsiveValue, }); expect(result.current).toBe('medium'); @@ -100,7 +102,8 @@ describe('useResponsivePropValue', () => { }; const {result} = renderHook(useResponsivePropValue, { - wrapper: createWrapper(), initialProps: responsiveValue, + wrapper: createWrapper(), + initialProps: responsiveValue, }); expect(result.current).toBe('medium'); @@ -118,7 +121,8 @@ describe('useResponsivePropValue', () => { }; const {result} = renderHook(useResponsivePropValue, { - wrapper: createWrapper(), initialProps: responsiveValue, + wrapper: createWrapper(), + initialProps: responsiveValue, }); expect(result.current).toBe('small'); @@ -139,7 +143,8 @@ describe('useResponsivePropValue', () => { }; const {result} = renderHook(useResponsivePropValue, { - wrapper: createWrapper(), initialProps: responsiveValue, + wrapper: createWrapper(), + initialProps: responsiveValue, }); expect(result.current).toBe('small'); @@ -160,7 +165,8 @@ describe('useResponsivePropValue', () => { }; const {result} = renderHook(useResponsivePropValue, { - wrapper: createWrapper(), initialProps: responsiveValue, + wrapper: createWrapper(), + initialProps: responsiveValue, }); expect(result.current).toBe('medium'); @@ -170,7 +176,8 @@ describe('useResponsivePropValue', () => { it('throws an error when no breakpoints are defined in responsive prop', () => { expect(() => renderHook(useResponsivePropValue, { - wrapper: createWrapper(), initialProps: {}, + wrapper: createWrapper(), + initialProps: {}, }) ).toThrow('Responsive prop must contain at least one breakpoint'); }); @@ -284,12 +291,10 @@ describe('useActiveBreakpoint', () => { return mockQuery; }); - const {result} = renderHook( - useResponsivePropValue, - { - wrapper: createWrapper(), initialProps: {xs: 'small', md: 'medium', lg: 'large'}, - } - ); + const {result} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), + initialProps: {xs: 'small', md: 'medium', lg: 'large'}, + }); // Initially query matches 'medium' expect(result.current).toBe('medium'); @@ -335,12 +340,10 @@ describe('useActiveBreakpoint', () => { dispatchEvent: jest.fn(), })); - const {unmount} = renderHook( - useResponsivePropValue, - { - wrapper: createWrapper(), initialProps: {xs: 'small', md: 'medium'}, - } - ); + const {unmount} = renderHook(useResponsivePropValue, { + wrapper: createWrapper(), + initialProps: {xs: 'small', md: 'medium'}, + }); // Sets up listeners for all breakpoints expect(addEventListener).toHaveBeenCalledTimes(Object.keys(theme.breakpoints).length); diff --git a/static/app/components/prevent/summary.spec.tsx b/static/app/components/prevent/summary.spec.tsx index 75fb23146b53af..0915c583aa4921 100644 --- a/static/app/components/prevent/summary.spec.tsx +++ b/static/app/components/prevent/summary.spec.tsx @@ -18,7 +18,8 @@ describe('useCreateSummaryFilterLink', () => { describe('when the filter is not applied', () => { it('returns isFiltered as false', () => { const {result} = renderHook(useCreateSummaryFilterLink, { - wrapper: createWrapper('/'), initialProps: 'slowestTests', + wrapper: createWrapper('/'), + initialProps: 'slowestTests', }); expect(result.current.isFiltered).toBeFalsy(); @@ -26,7 +27,8 @@ describe('useCreateSummaryFilterLink', () => { it('returns the link with search param', () => { const {result} = renderHook(useCreateSummaryFilterLink, { - wrapper: createWrapper('/'), initialProps: 'slowestTests', + wrapper: createWrapper('/'), + initialProps: 'slowestTests', }); expect(result.current.filterLink).toEqual( @@ -38,7 +40,8 @@ describe('useCreateSummaryFilterLink', () => { describe('when the filter is applied', () => { it('returns isFiltered as true', () => { const {result} = renderHook(useCreateSummaryFilterLink, { - wrapper: createWrapper('/?filterBy=slowestTests'), initialProps: 'slowestTests', + wrapper: createWrapper('/?filterBy=slowestTests'), + initialProps: 'slowestTests', }); expect(result.current.isFiltered).toBeTruthy(); @@ -46,7 +49,8 @@ describe('useCreateSummaryFilterLink', () => { it('returns the link without search param', () => { const {result} = renderHook(useCreateSummaryFilterLink, { - wrapper: createWrapper('/?filterBy=slowestTests'), initialProps: 'slowestTests', + wrapper: createWrapper('/?filterBy=slowestTests'), + initialProps: 'slowestTests', }); expect(result.current.filterLink).toEqual(expect.objectContaining({query: {}})); diff --git a/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts b/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts index c5cedc7185fc02..6b5fcd2456c0bc 100644 --- a/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts +++ b/static/app/components/prevent/virtualRenderers/useSyncScrollMargin.spec.ts @@ -32,8 +32,9 @@ describe('useSyncScrollMargin', () => { describe('overlayRef is set', () => { it('returns the scroll margin', () => { - const {result} = renderHook(useSyncScrollMargin, {initialProps: {current: {} as HTMLDivElement}} - ); + const {result} = renderHook(useSyncScrollMargin, { + initialProps: {current: {} as HTMLDivElement}, + }); expect(result.current).toBe(100); }); diff --git a/static/app/components/replays/replayLiveIndicator.spec.tsx b/static/app/components/replays/replayLiveIndicator.spec.tsx index 54342deae9c4aa..f9b9db07d410de 100644 --- a/static/app/components/replays/replayLiveIndicator.spec.tsx +++ b/static/app/components/replays/replayLiveIndicator.spec.tsx @@ -28,11 +28,12 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 60_000); // 1 minute ago const finishedAt = new Date(now); // just now - const {result} = renderHook(useLiveBadge, {initialProps: { + const {result} = renderHook(useLiveBadge, { + initialProps: { startedAt, finishedAt, - }} - ); + }, + }); expect(result.current.isLive).toBe(true); }); @@ -42,11 +43,12 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 10 * 60_000); // 10 minutes ago const finishedAt = new Date(now - 6 * 60_000); // 6 minutes ago (more than 5 min threshold) - const {result} = renderHook(useLiveBadge, {initialProps: { + const {result} = renderHook(useLiveBadge, { + initialProps: { startedAt, finishedAt, - }} - ); + }, + }); expect(result.current.isLive).toBe(false); }); @@ -56,11 +58,12 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 2 * 60 * 60_000); // 2 hours ago const finishedAt = new Date(now); // just now - const {result} = renderHook(useLiveBadge, {initialProps: { + const {result} = renderHook(useLiveBadge, { + initialProps: { startedAt, finishedAt, - }} - ); + }, + }); expect(result.current.isLive).toBe(false); }); @@ -70,11 +73,12 @@ describe('useLiveBadge', () => { const startedAt = new Date(now - 60_000); // 1 minute ago const finishedAt = new Date(now); // just now - const {result} = renderHook(useLiveBadge, {initialProps: { + const {result} = renderHook(useLiveBadge, { + initialProps: { startedAt, finishedAt, - }} - ); + }, + }); expect(result.current.isLive).toBe(true); @@ -90,11 +94,12 @@ describe('useLiveBadge', () => { const now = Date.now(); const startedAt = new Date(now - 60_000); - const {result} = renderHook(useLiveBadge, {initialProps: { + const {result} = renderHook(useLiveBadge, { + initialProps: { startedAt, finishedAt: null, - }} - ); + }, + }); expect(result.current.isLive).toBe(false); }); @@ -120,7 +125,8 @@ describe('useLiveRefresh', () => { it('should not show refresh button when replay is undefined', () => { const {result} = renderHook(useLiveRefresh, { - wrapper: createWrapper(), initialProps: {replay: undefined}, + wrapper: createWrapper(), + initialProps: {replay: undefined}, }); expect(result.current.shouldShowRefreshButton).toBe(false); @@ -138,7 +144,8 @@ describe('useLiveRefresh', () => { }); const {result} = renderHook(useLiveRefresh, { - wrapper: createWrapper(), initialProps: {replay}, + wrapper: createWrapper(), + initialProps: {replay}, }); // Initial state - no refresh button since polled and current are equal @@ -164,7 +171,8 @@ describe('useLiveRefresh', () => { }); const {result} = renderHook(useLiveRefresh, { - wrapper: createWrapper(), initialProps: {replay}, + wrapper: createWrapper(), + initialProps: {replay}, }); // Wait for the API call to complete and state to update @@ -186,7 +194,8 @@ describe('useLiveRefresh', () => { }); renderHook(useLiveRefresh, { - wrapper: createWrapper(), initialProps: {replay}, + wrapper: createWrapper(), + initialProps: {replay}, }); // Advance time past polling interval @@ -211,7 +220,8 @@ describe('useLiveRefresh', () => { }); const {result} = renderHook(useLiveRefresh, { - wrapper: createWrapper(), initialProps: {replay}, + wrapper: createWrapper(), + initialProps: {replay}, }); result.current.doRefresh(); diff --git a/static/app/components/searchQueryBuilder/hooks.spec.tsx b/static/app/components/searchQueryBuilder/hooks.spec.tsx index d7ae71f6881e7f..2da9320ab6be03 100644 --- a/static/app/components/searchQueryBuilder/hooks.spec.tsx +++ b/static/app/components/searchQueryBuilder/hooks.spec.tsx @@ -4,24 +4,19 @@ import {useCaseInsensitivity} from 'sentry/components/searchQueryBuilder/hooks'; describe('useCaseSensitivity', () => { it('should return the correct case sensitivity', () => { - const {result: noCaseSensitivity} = renderHookWithProviders(useCaseInsensitivity - ); + const {result: noCaseSensitivity} = renderHookWithProviders(useCaseInsensitivity); expect(noCaseSensitivity.current[0]).toBeNull(); - const {result: caseSensitivityFalse} = renderHookWithProviders( - useCaseInsensitivity, - { - initialRouterConfig: { - location: {pathname: '/', query: {}}, - }, - } - ); + const {result: caseSensitivityFalse} = renderHookWithProviders(useCaseInsensitivity, { + initialRouterConfig: { + location: {pathname: '/', query: {}}, + }, + }); expect(caseSensitivityFalse.current[0]).toBeNull(); - const {result: caseSensitivityTrue} = renderHookWithProviders( - useCaseInsensitivity, - {initialRouterConfig: {location: {pathname: '/', query: {caseInsensitive: '1'}}}} - ); + const {result: caseSensitivityTrue} = renderHookWithProviders(useCaseInsensitivity, { + initialRouterConfig: {location: {pathname: '/', query: {caseInsensitive: '1'}}}, + }); expect(caseSensitivityTrue.current[0]).toBe(true); }); diff --git a/static/app/components/workflowEngine/form/useFormField.spec.tsx b/static/app/components/workflowEngine/form/useFormField.spec.tsx index 4226206b2e1723..bf50034b576e05 100644 --- a/static/app/components/workflowEngine/form/useFormField.spec.tsx +++ b/static/app/components/workflowEngine/form/useFormField.spec.tsx @@ -20,7 +20,8 @@ describe('useFormField', () => { model.setInitialData({targetField: 'initial', otherField: 'other'}); const {result} = renderHook(useFormField, { - wrapper: withFormContext, initialProps: 'targetField', + wrapper: withFormContext, + initialProps: 'targetField', }); expect(result.current).toBe('initial'); @@ -38,13 +39,15 @@ describe('useFormField', () => { it('handles undefined values and type parameters', () => { const {result: undefinedResult} = renderHook(useFormField, { - wrapper: withFormContext, initialProps: 'nonexistent', + wrapper: withFormContext, + initialProps: 'nonexistent', }); expect(undefinedResult.current).toBe(''); model.setInitialData({numberField: 42}); const {result: typedResult} = renderHook(useFormField, { - wrapper: withFormContext, initialProps: 'numberField', + wrapper: withFormContext, + initialProps: 'numberField', }); expect(typedResult.current).toBe(42); expect(typeof typedResult.current).toBe('number'); @@ -53,7 +56,8 @@ describe('useFormField', () => { it('handles fields that are added after subscription', () => { // Start with a hook subscribed to a field that doesn't exist yet const {result} = renderHook(useFormField, { - wrapper: withFormContext, initialProps: 'laterField', + wrapper: withFormContext, + initialProps: 'laterField', }); // Initially should return empty string for non-existent field @@ -79,7 +83,8 @@ describe('useFormField', () => { model.setInitialData({targetField: 'initial'}); const {result} = renderHook(useFormField, { - wrapper: withFormContext, initialProps: 'targetField', + wrapper: withFormContext, + initialProps: 'targetField', }); expect(result.current).toBe('initial'); diff --git a/static/app/utils/api/apiOptions.spec.tsx b/static/app/utils/api/apiOptions.spec.tsx index 08a5be469e0602..f08cf955f8cc14 100644 --- a/static/app/utils/api/apiOptions.spec.tsx +++ b/static/app/utils/api/apiOptions.spec.tsx @@ -109,10 +109,10 @@ describe('apiOptions', () => { }, }); - const {result} = renderHook( - useQuery, - {wrapper, initialProps: {...options, select: selectWithHeaders(['Link', 'X-Hits'] as const)}} - ); + const {result} = renderHook(useQuery, { + wrapper, + initialProps: {...options, select: selectWithHeaders(['Link', 'X-Hits'] as const)}, + }); await waitFor(() => result.current.isSuccess); diff --git a/static/app/utils/demoMode/demoTours.spec.tsx b/static/app/utils/demoMode/demoTours.spec.tsx index 7fc10d4bb4f1be..8a9642d410de1d 100644 --- a/static/app/utils/demoMode/demoTours.spec.tsx +++ b/static/app/utils/demoMode/demoTours.spec.tsx @@ -105,7 +105,9 @@ describe('DemoTours', () => { it('returns null when used outside provider', () => { jest.spyOn(console, 'error').mockImplementation(() => {}); - const {result} = renderHookWithProviders(useDemoTour, {initialProps: DemoTour.RELEASES}); + const {result} = renderHookWithProviders(useDemoTour, { + initialProps: DemoTour.RELEASES, + }); expect(result.current).toBeNull(); @@ -114,7 +116,8 @@ describe('DemoTours', () => { it('provides tour context when used inside provider', () => { const {result} = renderHookWithProviders(useDemoTour, { - additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, + additionalWrapper: createWrapper(), + initialProps: DemoTour.RELEASES, }); const tour = result.current; @@ -129,7 +132,8 @@ describe('DemoTours', () => { it('handles tour actions', () => { const {result} = renderHookWithProviders(useDemoTour, { - additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, + additionalWrapper: createWrapper(), + initialProps: DemoTour.RELEASES, }); const tour = result.current; @@ -159,21 +163,17 @@ describe('DemoTours', () => { }); it('maintains separate state for different tours', () => { - const {result: sideBarResult} = renderHookWithProviders( - useDemoTour, - { - additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, - } - ); + const {result: sideBarResult} = renderHookWithProviders(useDemoTour, { + additionalWrapper: createWrapper(), + initialProps: DemoTour.RELEASES, + }); const sidebarTour = sideBarResult.current; - const {result: issuesResult} = renderHookWithProviders( - useDemoTour, - { - additionalWrapper: createWrapper(), initialProps: DemoTour.ISSUES, - } - ); + const {result: issuesResult} = renderHookWithProviders(useDemoTour, { + additionalWrapper: createWrapper(), + initialProps: DemoTour.ISSUES, + }); const issuesTour = issuesResult.current; @@ -214,7 +214,8 @@ describe('DemoTours', () => { it('correctly advances through tour steps', () => { const {result} = renderHookWithProviders(useDemoTour, { - additionalWrapper: createWrapper(), initialProps: DemoTour.RELEASES, + additionalWrapper: createWrapper(), + initialProps: DemoTour.RELEASES, }); const sidebarTour = result.current; diff --git a/static/app/utils/list/useListItemCheckboxState.spec.ts b/static/app/utils/list/useListItemCheckboxState.spec.ts index 865c7b084bf258..a58d2eac0b4f55 100644 --- a/static/app/utils/list/useListItemCheckboxState.spec.ts +++ b/static/app/utils/list/useListItemCheckboxState.spec.ts @@ -9,8 +9,9 @@ const queryKey: ApiQueryKey = [getApiUrl('/api-tokens/')]; describe('useListItemCheckboxContext', () => { describe('All hits are already known', () => { it('should return the correct initial state', () => { - const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} - ); + const {result} = renderHook(useListItemCheckboxContext, { + initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}, + }); expect(result.current).toEqual({ countSelected: 0, deselectAll: expect.any(Function), @@ -27,8 +28,9 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting an individual item when all hits are known', () => { - const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} - ); + const {result} = renderHook(useListItemCheckboxContext, { + initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}, + }); // Initially nothing is selected expect(result.current.isSelected('1')).toBe(false); @@ -82,8 +84,9 @@ describe('useListItemCheckboxContext', () => { }); it('sets isAllSelected to true when all items are selected', () => { - const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} - ); + const {result} = renderHook(useListItemCheckboxContext, { + initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}, + }); // Initially nothing is selected expect(result.current.isSelected('1')).toBe(false); @@ -105,8 +108,9 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting all items with selectAll', () => { - const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}} - ); + const {result} = renderHook(useListItemCheckboxContext, { + initialProps: {hits: 3, knownIds: ['1', '2', '3'], queryKey}, + }); // Initially nothing is selected expect(result.current.isSelected('1')).toBe(false); @@ -148,8 +152,9 @@ describe('useListItemCheckboxContext', () => { describe('More hits to load', () => { it('should return the correct initial state', () => { - const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}} - ); + const {result} = renderHook(useListItemCheckboxContext, { + initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}, + }); expect(result.current).toEqual({ countSelected: 0, deselectAll: expect.any(Function), @@ -166,8 +171,9 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting individual items when there are more hits to load', () => { - const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}} - ); + const {result} = renderHook(useListItemCheckboxContext, { + initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}, + }); // Initially nothing is selected expect(result.current.isSelected('1')).toBe(false); @@ -235,8 +241,9 @@ describe('useListItemCheckboxContext', () => { }); it('should allow selecting all items with selectAll', () => { - const {result} = renderHook(useListItemCheckboxContext, {initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}} - ); + const {result} = renderHook(useListItemCheckboxContext, { + initialProps: {hits: 10, knownIds: ['1', '2', '3'], queryKey}, + }); // Initially nothing is selected expect(result.current.isSelected('1')).toBe(false); diff --git a/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx b/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx index 9bde3941a62b68..64923aac41bddd 100644 --- a/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx +++ b/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx @@ -29,13 +29,13 @@ describe('useProfileFunctionTrendss', () => { body: {data: []}, }); - const hook = renderHook( - useProfileFunctionTrends, - {wrapper: TestContext, initialProps: { - trendFunction: 'p95()', - trendType: 'regression', - }} - ); + const hook = renderHook(useProfileFunctionTrends, { + wrapper: TestContext, + initialProps: { + trendFunction: 'p95()', + trendType: 'regression', + }, + }); expect(hook.result.current).toMatchObject( expect.objectContaining({ isInitialLoading: true, @@ -49,13 +49,13 @@ describe('useProfileFunctionTrendss', () => { body: {data: []}, }); - const hook = renderHook( - useProfileFunctionTrends, - {wrapper: TestContext, initialProps: { - trendFunction: 'p95()', - trendType: 'regression', - }} - ); + const hook = renderHook(useProfileFunctionTrends, { + wrapper: TestContext, + initialProps: { + trendFunction: 'p95()', + trendType: 'regression', + }, + }); expect(hook.result.current.isPending).toBe(true); expect(hook.result.current.isFetched).toBe(false); await waitFor(() => diff --git a/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx b/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx index 8bf9a117329000..008a8dfed03f89 100644 --- a/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx +++ b/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx @@ -13,15 +13,16 @@ describe('useProfileFunctions', () => { body: {data: []}, }); - const hook = renderHookWithProviders(useProfileFunctions, {initialProps: { + const hook = renderHookWithProviders(useProfileFunctions, { + initialProps: { fields: ['count()'], referrer: '', sort: { key: 'count()', order: 'desc', }, - }} - ); + }, + }); expect(hook.result.current).toMatchObject( expect.objectContaining({ isInitialLoading: true, @@ -35,15 +36,16 @@ describe('useProfileFunctions', () => { body: {data: []}, }); - const hook = renderHookWithProviders(useProfileFunctions, {initialProps: { + const hook = renderHookWithProviders(useProfileFunctions, { + initialProps: { fields: ['count()'], referrer: '', sort: { key: 'count()', order: 'desc', }, - }} - ); + }, + }); expect(hook.result.current.isPending).toBe(true); expect(hook.result.current.isFetched).toBe(false); await waitFor(() => diff --git a/static/app/utils/url/useQueryParamState.spec.tsx b/static/app/utils/url/useQueryParamState.spec.tsx index 63f45604911c1e..b4f9c88aa029a3 100644 --- a/static/app/utils/url/useQueryParamState.spec.tsx +++ b/static/app/utils/url/useQueryParamState.spec.tsx @@ -31,7 +31,8 @@ describe('useQueryParamState', () => { ); const {result} = renderHook(useQueryParamState, { - wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField'}, + wrapper: UrlParamBatchProvider, + initialProps: {fieldName: 'testField'}, }); expect(result.current[0]).toBe('initial state'); @@ -42,7 +43,8 @@ describe('useQueryParamState', () => { mockedUseNavigate.mockReturnValue(mockedNavigate); const {result} = renderHook(useQueryParamState, { - wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField'}, + wrapper: UrlParamBatchProvider, + initialProps: {fieldName: 'testField'}, }); act(() => { @@ -84,12 +86,10 @@ describe('useQueryParamState', () => { const testDeserializer = (value: string) => `${value.toUpperCase()} - decoded`; - const {result} = renderHook( - useQueryParamState, - { - wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', deserializer: testDeserializer}, - } - ); + const {result} = renderHook(useQueryParamState, { + wrapper: UrlParamBatchProvider, + initialProps: {fieldName: 'testField', deserializer: testDeserializer}, + }); expect(result.current[0]).toBe('INITIAL STATE - decoded'); }); @@ -107,12 +107,10 @@ describe('useQueryParamState', () => { const testSerializer = (value: TestType) => `${value.value} - ${value.count} - ${value.isActive}`; - const {result} = renderHook( - useQueryParamState, - { - wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', serializer: testSerializer}, - } - ); + const {result} = renderHook(useQueryParamState, { + wrapper: UrlParamBatchProvider, + initialProps: {fieldName: 'testField', serializer: testSerializer}, + }); act(() => { result.current[1]({value: 'newValue', count: 2, isActive: true}); @@ -133,16 +131,14 @@ describe('useQueryParamState', () => { const mockedNavigate = jest.fn(); mockedUseNavigate.mockReturnValue(mockedNavigate); - const {result} = renderHook( - useQueryParamState, - { - wrapper: UrlParamBatchProvider, initialProps: { - fieldName: 'sort', - decoder: decodeSorts, - serializer: value => value.map(formatSort), - }, - } - ); + const {result} = renderHook(useQueryParamState, { + wrapper: UrlParamBatchProvider, + initialProps: { + fieldName: 'sort', + decoder: decodeSorts, + serializer: value => value.map(formatSort), + }, + }); expect(result.current[0]).toEqual([{field: 'testField', kind: 'desc'}]); @@ -164,12 +160,10 @@ describe('useQueryParamState', () => { LocationFixture({query: {testField: 'initial state'}}) ); - const {result, rerender} = renderHook( - useQueryParamState, - { - wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', syncStateWithUrl: false}, - } - ); + const {result, rerender} = renderHook(useQueryParamState, { + wrapper: UrlParamBatchProvider, + initialProps: {fieldName: 'testField', syncStateWithUrl: false}, + }); expect(result.current[0]).toBe('initial state'); @@ -189,12 +183,10 @@ describe('useQueryParamState', () => { LocationFixture({query: {testField: 'initial state'}}) ); - const {result, rerender} = renderHook( - useQueryParamState, - { - wrapper: UrlParamBatchProvider, initialProps: {fieldName: 'testField', syncStateWithUrl: true}, - } - ); + const {result, rerender} = renderHook(useQueryParamState, { + wrapper: UrlParamBatchProvider, + initialProps: {fieldName: 'testField', syncStateWithUrl: true}, + }); expect(result.current[0]).toBe('initial state'); diff --git a/static/app/utils/useIsMountedRef.spec.tsx b/static/app/utils/useIsMountedRef.spec.tsx index e200aeef02b387..d6d341fc009fb5 100644 --- a/static/app/utils/useIsMountedRef.spec.tsx +++ b/static/app/utils/useIsMountedRef.spec.tsx @@ -1,4 +1,4 @@ -import {renderHook, render} from 'sentry-test/reactTestingLibrary'; +import {render, renderHook} from 'sentry-test/reactTestingLibrary'; import {useIsMountedRef} from './useIsMountedRef'; diff --git a/static/app/utils/useLocalStorageState.spec.tsx b/static/app/utils/useLocalStorageState.spec.tsx index 1fc2decdc04b94..da3fb3df9fe534 100644 --- a/static/app/utils/useLocalStorageState.spec.tsx +++ b/static/app/utils/useLocalStorageState.spec.tsx @@ -1,4 +1,4 @@ -import {act, renderHook, waitFor, render} from 'sentry-test/reactTestingLibrary'; +import {act, render, renderHook, waitFor} from 'sentry-test/reactTestingLibrary'; import localStorageWrapper from 'sentry/utils/localStorage'; import {useLocalStorageState} from 'sentry/utils/useLocalStorageState'; @@ -15,7 +15,9 @@ describe('useLocalStorageState', () => { it('throws if key is not a string', () => { expect(() => { function TestComponent() { + // @ts-expect-error force incorrect usage useLocalStorageState({}, 'default value'); + return null; } render(); }).toThrow('useLocalStorage: key must be a string'); diff --git a/static/app/utils/useMaxPickableDays.spec.tsx b/static/app/utils/useMaxPickableDays.spec.tsx index 5da991d8d6c809..ab50c750cf49ed 100644 --- a/static/app/utils/useMaxPickableDays.spec.tsx +++ b/static/app/utils/useMaxPickableDays.spec.tsx @@ -8,10 +8,11 @@ import {useMaxPickableDays} from './useMaxPickableDays'; describe('useMaxPickableDays', () => { it('returns 90/90 for transactions', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.TRANSACTIONS], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 90, @@ -20,10 +21,11 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for replays', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.REPLAYS], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 90, @@ -32,10 +34,11 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for spans without flag', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.SPANS], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 30, @@ -45,14 +48,12 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for spans with flag', () => { - const {result} = renderHookWithProviders( - useMaxPickableDays, - { - organization: OrganizationFixture({features: ['visibility-explore-range-high']}), initialProps: { - dataCategories: [DataCategory.SPANS], - }, - } - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization: OrganizationFixture({features: ['visibility-explore-range-high']}), + initialProps: { + dataCategories: [DataCategory.SPANS], + }, + }); expect(result.current).toEqual({ maxPickableDays: 90, @@ -62,10 +63,11 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for tracemetrics', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.TRACE_METRICS], - }} - ); + }, + }); expect(result.current).toEqual({ defaultPeriod: '24h', @@ -75,10 +77,11 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for logs', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.LOG_BYTE, DataCategory.LOG_ITEM], - }} - ); + }, + }); expect(result.current).toEqual({ defaultPeriod: '24h', @@ -88,7 +91,8 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for many without flag', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [ DataCategory.SPANS, DataCategory.SPANS_INDEXED, @@ -96,8 +100,8 @@ describe('useMaxPickableDays', () => { DataCategory.LOG_BYTE, DataCategory.LOG_ITEM, ], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 30, diff --git a/static/app/utils/useUpdateOrganization.spec.tsx b/static/app/utils/useUpdateOrganization.spec.tsx index 3bfd58374ffcc4..e251c6ea6305f7 100644 --- a/static/app/utils/useUpdateOrganization.spec.tsx +++ b/static/app/utils/useUpdateOrganization.spec.tsx @@ -40,7 +40,8 @@ describe('useUpdateOrganization', () => { const {result} = renderHook(useUpdateOrganization, { wrapper: ({children}) => ( {children} - ), initialProps: organization, + ), + initialProps: organization, }); // Verify initial state @@ -84,7 +85,8 @@ describe('useUpdateOrganization', () => { const {result} = renderHook(useUpdateOrganization, { wrapper: ({children}) => ( {children} - ), initialProps: organization, + ), + initialProps: organization, }); // Verify initial state diff --git a/static/app/views/dashboards/widgetCard/hooks/useLogsWidgetQuery.spec.tsx b/static/app/views/dashboards/widgetCard/hooks/useLogsWidgetQuery.spec.tsx index fc928b5546eb06..cffa5b05b4582b 100644 --- a/static/app/views/dashboards/widgetCard/hooks/useLogsWidgetQuery.spec.tsx +++ b/static/app/views/dashboards/widgetCard/hooks/useLogsWidgetQuery.spec.tsx @@ -60,16 +60,15 @@ describe('useLogsSeriesQuery', () => { }, }); - renderHook( - () => - useLogsSeriesQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useLogsSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -106,19 +105,18 @@ describe('useLogsSeriesQuery', () => { }, }); - renderHook( - () => - useLogsSeriesQuery({ - widget, - organization, - pageFilters, - dashboardFilters: { - release: ['1.0.0'], - }, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useLogsSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + dashboardFilters: { + release: ['1.0.0'], + }, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -165,16 +163,15 @@ describe('useLogsTableQuery', () => { }, }); - renderHook( - () => - useLogsTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useLogsTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -210,18 +207,17 @@ describe('useLogsTableQuery', () => { }, }); - renderHook( - () => - useLogsTableQuery({ - widget, - organization, - pageFilters, - limit: 50, - cursor: 'test-cursor', - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useLogsTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + limit: 50, + cursor: 'test-cursor', + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( diff --git a/static/app/views/dashboards/widgetCard/hooks/useSpansWidgetQuery.spec.tsx b/static/app/views/dashboards/widgetCard/hooks/useSpansWidgetQuery.spec.tsx index 7dbe178cd6fafe..895c8e87590d00 100644 --- a/static/app/views/dashboards/widgetCard/hooks/useSpansWidgetQuery.spec.tsx +++ b/static/app/views/dashboards/widgetCard/hooks/useSpansWidgetQuery.spec.tsx @@ -77,16 +77,15 @@ describe('useSpansSeriesQuery', () => { }, }); - renderHook( - () => - useSpansSeriesQuery({ - widget, - organization, - pageFilters: pageFiltersWithDates, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters: pageFiltersWithDates, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -123,19 +122,18 @@ describe('useSpansSeriesQuery', () => { }, }); - renderHook( - () => - useSpansSeriesQuery({ - widget, - organization, - pageFilters, - dashboardFilters: { - release: ['1.0.0'], - }, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + dashboardFilters: { + release: ['1.0.0'], + }, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -202,16 +200,15 @@ describe('useSpansSeriesQuery', () => { ], }); - renderHook( - () => - useSpansSeriesQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest1).toHaveBeenCalled(); @@ -241,16 +238,15 @@ describe('useSpansSeriesQuery', () => { }, }); - const {result} = renderHook( - () => - useSpansSeriesQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + const {result} = renderHook(useSpansSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); expect(result.current.loading).toBe(true); }); @@ -278,16 +274,15 @@ describe('useSpansSeriesQuery', () => { statusCode: 500, }); - const {result} = renderHook( - () => - useSpansSeriesQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + const {result} = renderHook(useSpansSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(result.current.errorMessage).toBeDefined(); @@ -342,16 +337,15 @@ describe('useSpansTableQuery', () => { }, }); - renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters: pageFiltersWithDates, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters: pageFiltersWithDates, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -388,16 +382,15 @@ describe('useSpansTableQuery', () => { }, }); - const {result} = renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + const {result} = renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(result.current.loading).toBe(false); @@ -426,19 +419,18 @@ describe('useSpansTableQuery', () => { }, }); - renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - dashboardFilters: { - release: ['1.0.0'], - }, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + dashboardFilters: { + release: ['1.0.0'], + }, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -474,18 +466,17 @@ describe('useSpansTableQuery', () => { }, }); - renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - limit: 50, - cursor: 'test-cursor', - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + limit: 50, + cursor: 'test-cursor', + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -522,16 +513,15 @@ describe('useSpansTableQuery', () => { }, }); - const {result} = renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + const {result} = renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); expect(result.current.loading).toBe(true); }); @@ -559,16 +549,15 @@ describe('useSpansTableQuery', () => { statusCode: 500, }); - const {result} = renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + const {result} = renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(result.current.errorMessage).toBeDefined(); @@ -601,16 +590,15 @@ describe('useSpansTableQuery', () => { }, }); - renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -644,16 +632,15 @@ describe('useSpansTableQuery', () => { data: [{transaction: '/api/test', 'count()': 100}], }, }); - renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( '/organizations/org-slug/events/', @@ -688,16 +675,15 @@ describe('useSpansTableQuery', () => { }, }); - renderHook( - () => - useSpansTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useSpansTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( diff --git a/static/app/views/dashboards/widgetCard/hooks/useTraceMetricsWidgetQuery.spec.tsx b/static/app/views/dashboards/widgetCard/hooks/useTraceMetricsWidgetQuery.spec.tsx index 3396d065bb2d10..ff93d543a0c8f2 100644 --- a/static/app/views/dashboards/widgetCard/hooks/useTraceMetricsWidgetQuery.spec.tsx +++ b/static/app/views/dashboards/widgetCard/hooks/useTraceMetricsWidgetQuery.spec.tsx @@ -74,16 +74,15 @@ describe('useTraceMetricsSeriesQuery', () => { }, }); - renderHook( - () => - useTraceMetricsSeriesQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useTraceMetricsSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -130,19 +129,18 @@ describe('useTraceMetricsSeriesQuery', () => { }, }); - renderHook( - () => - useTraceMetricsSeriesQuery({ - widget, - organization, - pageFilters, - dashboardFilters: { - release: ['1.0.0'], - }, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useTraceMetricsSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + dashboardFilters: { + release: ['1.0.0'], + }, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -178,16 +176,15 @@ describe('useTraceMetricsSeriesQuery', () => { }, }); - renderHook( - () => - useTraceMetricsSeriesQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useTraceMetricsSeriesQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -239,16 +236,15 @@ describe('useTraceMetricsTableQuery', () => { }, }); - renderHook( - () => - useTraceMetricsTableQuery({ - widget, - organization, - pageFilters, - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useTraceMetricsTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( @@ -289,18 +285,17 @@ describe('useTraceMetricsTableQuery', () => { }, }); - renderHook( - () => - useTraceMetricsTableQuery({ - widget, - organization, - pageFilters, - limit: 25, - cursor: 'test-cursor', - enabled: true, - }), - {wrapper: createWrapper()} - ); + renderHook(useTraceMetricsTableQuery, { + wrapper: createWrapper(), + initialProps: { + widget, + organization, + pageFilters, + limit: 25, + cursor: 'test-cursor', + enabled: true, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledWith( diff --git a/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx b/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx index 8f1a38fbddb848..d282c59254b0d8 100644 --- a/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx +++ b/static/app/views/detectors/hooks/useMetricDetectorAnomalies.spec.tsx @@ -56,7 +56,8 @@ describe('useMetricDetectorAnomalies', () => { }, ]; - const {result} = renderHookWithProviders(useMetricDetectorAnomalies, {initialProps: { + const {result} = renderHookWithProviders(useMetricDetectorAnomalies, { + initialProps: { series, historicalSeries, thresholdType: AlertRuleThresholdType.ABOVE, @@ -64,8 +65,8 @@ describe('useMetricDetectorAnomalies', () => { interval: 900, // 15 minutes projectId: '1', enabled: true, - }} - ); + }, + }); await waitFor(() => { expect(anomalyRequest).toHaveBeenCalledWith( diff --git a/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx b/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx index f621d14738a855..22ca285262cc6d 100644 --- a/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx +++ b/static/app/views/detectors/hooks/useMetricDetectorAnomalyPeriods.spec.tsx @@ -74,7 +74,8 @@ describe('useMetricDetectorAnomalyPeriods', () => { }, ]; - const {result} = renderHookWithProviders(useMetricDetectorAnomalyPeriods, {initialProps: { + const {result} = renderHookWithProviders(useMetricDetectorAnomalyPeriods, { + initialProps: { series, detectorDataset: DetectorDataset.ERRORS, dataset: Dataset.ERRORS, @@ -89,8 +90,8 @@ describe('useMetricDetectorAnomalyPeriods', () => { sensitivity: AlertRuleSensitivity.MEDIUM, isLoadingSeries: false, enabled: true, - }} - ); + }, + }); await waitFor(() => { expect(anomalyRequest).toHaveBeenCalled(); diff --git a/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx b/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx index d079971fea5916..558a34e2fcb2c0 100644 --- a/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx +++ b/static/app/views/detectors/hooks/useMetricDetectorAnomalyThresholds.spec.tsx @@ -26,16 +26,16 @@ describe('useMetricDetectorAnomalyThresholds', () => { }, ]; - renderHookWithProviders( - useMetricDetectorAnomalyThresholds, - {organization, initialProps: { - detectorId: '123', - detectionType: 'static', - startTimestamp: 1609459200, - endTimestamp: 1609545600, - series, - }} - ); + renderHookWithProviders(useMetricDetectorAnomalyThresholds, { + organization, + initialProps: { + detectorId: '123', + detectionType: 'static', + startTimestamp: 1609459200, + endTimestamp: 1609545600, + series, + }, + }); expect(anomalyDataRequest).not.toHaveBeenCalled(); }); @@ -67,16 +67,16 @@ describe('useMetricDetectorAnomalyThresholds', () => { }, ]; - renderHookWithProviders( - useMetricDetectorAnomalyThresholds, - {organization, initialProps: { - detectorId: '123', - detectionType: 'dynamic', - startTimestamp: 1609459200, - endTimestamp: 1609545600, - series, - }} - ); + renderHookWithProviders(useMetricDetectorAnomalyThresholds, { + organization, + initialProps: { + detectorId: '123', + detectionType: 'dynamic', + startTimestamp: 1609459200, + endTimestamp: 1609545600, + series, + }, + }); await waitFor(() => { expect(anomalyDataRequest).toHaveBeenCalled(); @@ -100,16 +100,16 @@ describe('useMetricDetectorAnomalyThresholds', () => { }, ]; - renderHookWithProviders( - useMetricDetectorAnomalyThresholds, - {organization, initialProps: { - detectorId: '123', - detectionType: undefined, - startTimestamp: 1609459200, - endTimestamp: 1609545600, - series, - }} - ); + renderHookWithProviders(useMetricDetectorAnomalyThresholds, { + organization, + initialProps: { + detectorId: '123', + detectionType: undefined, + startTimestamp: 1609459200, + endTimestamp: 1609545600, + series, + }, + }); expect(anomalyDataRequest).not.toHaveBeenCalled(); }); @@ -142,17 +142,17 @@ describe('useMetricDetectorAnomalyThresholds', () => { }, ]; - renderHookWithProviders( - useMetricDetectorAnomalyThresholds, - {organization, initialProps: { - detectorId: '123', - detectionType: 'dynamic', - startTimestamp: 1609459200, - endTimestamp: 1609545600, - series, - isLegacyAlert: true, - }} - ); + renderHookWithProviders(useMetricDetectorAnomalyThresholds, { + organization, + initialProps: { + detectorId: '123', + detectionType: 'dynamic', + startTimestamp: 1609459200, + endTimestamp: 1609545600, + series, + isLegacyAlert: true, + }, + }); await waitFor(() => { expect(anomalyDataRequest).toHaveBeenCalled(); diff --git a/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx b/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx index e9073bbb5fda96..b45e217fa2ef2b 100644 --- a/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx +++ b/static/app/views/explore/hooks/useExploreAggregatesTable.spec.tsx @@ -45,16 +45,14 @@ describe('useExploreAggregatesTable', () => { ], method: 'GET', }); - renderHookWithProviders( - useExploreAggregatesTable, - { - additionalWrapper: Wrapper, initialProps: { - query: 'test value', - enabled: true, - limit: 100, - }, - } - ); + renderHookWithProviders(useExploreAggregatesTable, { + additionalWrapper: Wrapper, + initialProps: { + query: 'test value', + enabled: true, + limit: 100, + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( @@ -95,24 +93,22 @@ describe('useExploreAggregatesTable', () => { method: 'GET', }); - renderHookWithProviders( - useExploreAggregatesTable, - { - additionalWrapper: Wrapper, - initialRouterConfig: { - location: { - pathname: '/organizations/org-slug/explore/traces/', - query: { - extrapolate: '0', - }, + renderHookWithProviders(useExploreAggregatesTable, { + additionalWrapper: Wrapper, + initialRouterConfig: { + location: { + pathname: '/organizations/org-slug/explore/traces/', + query: { + extrapolate: '0', }, - }, initialProps: { - query: 'test value', - enabled: true, - limit: 100, }, - } - ); + }, + initialProps: { + query: 'test value', + enabled: true, + limit: 100, + }, + }); await waitFor(() => expect(mockNonExtrapolatedRequest).toHaveBeenCalledTimes(1)); expect(mockNonExtrapolatedRequest).toHaveBeenCalledWith( diff --git a/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx b/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx index 263c8c52ab200b..d94d8f401cd4f0 100644 --- a/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx +++ b/static/app/views/explore/hooks/useExploreSpansTable.spec.tsx @@ -46,14 +46,14 @@ describe('useExploreSpansTable', () => { ], method: 'GET', }); - renderHookWithProviders( - useExploreSpansTable, - {additionalWrapper: Wrapper, initialProps: { - query: 'test value', - enabled: true, - limit: 10, - }} - ); + renderHookWithProviders(useExploreSpansTable, { + additionalWrapper: Wrapper, + initialProps: { + query: 'test value', + enabled: true, + limit: 10, + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( @@ -102,24 +102,22 @@ describe('useExploreSpansTable', () => { method: 'GET', }); - renderHookWithProviders( - useExploreSpansTable, - { - additionalWrapper: Wrapper, - initialRouterConfig: { - location: { - pathname: '/organizations/org-slug/explore/traces/', - query: { - extrapolate: '0', - }, + renderHookWithProviders(useExploreSpansTable, { + additionalWrapper: Wrapper, + initialRouterConfig: { + location: { + pathname: '/organizations/org-slug/explore/traces/', + query: { + extrapolate: '0', }, - }, initialProps: { - query: 'test value', - enabled: true, - limit: 10, }, - } - ); + }, + initialProps: { + query: 'test value', + enabled: true, + limit: 10, + }, + }); await waitFor(() => expect(mockNonExtrapolatedRequest).toHaveBeenCalledTimes(1)); expect(mockNonExtrapolatedRequest).toHaveBeenCalledWith( diff --git a/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx b/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx index fef4e39b5457a4..65eb138750a38d 100644 --- a/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx +++ b/static/app/views/explore/hooks/useExploreTimeseries.spec.tsx @@ -60,15 +60,13 @@ describe('useExploreTimeseries', () => { ], method: 'GET', }); - renderHookWithProviders( - useExploreTimeseries, - { - additionalWrapper: Wrapper, initialProps: { - query: 'test value', - enabled: true, - }, - } - ); + renderHookWithProviders(useExploreTimeseries, { + additionalWrapper: Wrapper, + initialProps: { + query: 'test value', + enabled: true, + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( @@ -109,23 +107,21 @@ describe('useExploreTimeseries', () => { method: 'GET', }); - renderHookWithProviders( - useExploreTimeseries, - { - additionalWrapper: Wrapper, - initialRouterConfig: { - location: { - pathname: '/organizations/org-slug/explore/traces/', - query: { - extrapolate: '0', - }, + renderHookWithProviders(useExploreTimeseries, { + additionalWrapper: Wrapper, + initialRouterConfig: { + location: { + pathname: '/organizations/org-slug/explore/traces/', + query: { + extrapolate: '0', }, - }, initialProps: { - query: 'test value', - enabled: true, }, - } - ); + }, + initialProps: { + query: 'test value', + enabled: true, + }, + }); await waitFor(() => expect(mockNonExtrapolatedRequest).toHaveBeenCalledTimes(1)); expect(mockNonExtrapolatedRequest).toHaveBeenCalledWith( diff --git a/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx b/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx index 539b9a069e58a8..0f0fd6e04f3b1f 100644 --- a/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx +++ b/static/app/views/explore/hooks/useGetTraceItemAttributeValues.spec.tsx @@ -45,11 +45,12 @@ describe('useGetTraceItemAttributeValues', () => { ], }); - const {result} = renderHookWithProviders(useGetTraceItemAttributeValues, {initialProps: { + const {result} = renderHookWithProviders(useGetTraceItemAttributeValues, { + initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }} - ); + }, + }); const tag = { key: attributeKey, @@ -87,11 +88,12 @@ describe('useGetTraceItemAttributeValues', () => { ], }); - const {result} = renderHookWithProviders(useGetTraceItemAttributeValues, {initialProps: { + const {result} = renderHookWithProviders(useGetTraceItemAttributeValues, { + initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'number', - }} - ); + }, + }); const tag = { key: attributeKey, diff --git a/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx b/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx index a16f083bd90c10..9ab561522f326a 100644 --- a/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx +++ b/static/app/views/explore/hooks/useProgressiveQuery.spec.tsx @@ -82,17 +82,18 @@ describe('useProgressiveQuery', () => { }, ], }); - renderHookWithProviders(useProgressiveQuery, {initialProps: { + renderHookWithProviders(useProgressiveQuery, { + initialProps: { queryHookImplementation: useMockHookImpl, queryHookArgs: {enabled: true, query: 'test value'}, queryOptions: { - canTriggerHighAccuracy: results => { + canTriggerHighAccuracy: (results: any) => { // Simulate checking if there is data and more data is available return defined(results.data) && results.data.meta.dataScanned === 'partial'; }, }, - }} - ); + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( @@ -132,7 +133,8 @@ describe('useProgressiveQuery', () => { }, ], }); - renderHookWithProviders(useProgressiveQuery, {initialProps: { + renderHookWithProviders(useProgressiveQuery, { + initialProps: { queryHookImplementation: useMockHookImpl, queryHookArgs: {enabled: true, query: 'test value'}, queryOptions: { @@ -141,8 +143,8 @@ describe('useProgressiveQuery', () => { return false; }, }, - }} - ); + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( diff --git a/static/app/views/explore/hooks/useSortByFields.spec.tsx b/static/app/views/explore/hooks/useSortByFields.spec.tsx index 8d1b046f4f4d3e..8c06e776cd30f2 100644 --- a/static/app/views/explore/hooks/useSortByFields.spec.tsx +++ b/static/app/views/explore/hooks/useSortByFields.spec.tsx @@ -45,24 +45,22 @@ describe('useSortByFields', () => { }); it('returns a valid list of field options in samples mode', () => { - const {result} = renderHook( - useSortByFields, - { - wrapper: createWrapper(organization), initialProps: { - fields: [ - 'id', - 'span.op', - 'span.description', - 'span.duration', - 'transaction', - 'timestamp', - ], - groupBys: [], - yAxes: ['avg(span.duration)'], - mode: Mode.SAMPLES, - }, - } - ); + const {result} = renderHook(useSortByFields, { + wrapper: createWrapper(organization), + initialProps: { + fields: [ + 'id', + 'span.op', + 'span.description', + 'span.duration', + 'transaction', + 'timestamp', + ], + groupBys: [], + yAxes: ['avg(span.duration)'], + mode: Mode.SAMPLES, + }, + }); expect(result.current.map(field => field.value)).toEqual([ 'id', @@ -75,17 +73,15 @@ describe('useSortByFields', () => { }); it('returns a valid list of field options in aggregate mode', () => { - const {result} = renderHook( - useSortByFields, - { - wrapper: createWrapper(organization), initialProps: { - fields: ['span.op', 'span.description'], - groupBys: ['span.op'], - yAxes: ['avg(span.duration)'], - mode: Mode.AGGREGATE, - }, - } - ); + const {result} = renderHook(useSortByFields, { + wrapper: createWrapper(organization), + initialProps: { + fields: ['span.op', 'span.description'], + groupBys: ['span.op'], + yAxes: ['avg(span.duration)'], + mode: Mode.AGGREGATE, + }, + }); expect(result.current.map(field => field.value)).toEqual([ 'avg(span.duration)', diff --git a/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx b/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx index 2846783c2450b5..bd589ecb62e440 100644 --- a/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx +++ b/static/app/views/explore/hooks/useTraceItemAttributeKeys.spec.tsx @@ -64,11 +64,12 @@ describe('useTraceItemAttributeKeys', () => { mockAttributeKeys ); - const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, { + initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }} - ); + }, + }); await waitFor(() => expect(result.current.isLoading).toBe(false)); expect(mockResponse).toHaveBeenCalled(); @@ -118,11 +119,12 @@ describe('useTraceItemAttributeKeys', () => { 'number' ); - const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, { + initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'number', - }} - ); + }, + }); await waitFor(() => expect(result.current.isLoading).toBe(false)); expect(mockResponse).toHaveBeenCalled(); @@ -171,11 +173,12 @@ describe('useTraceItemAttributeKeys', () => { mockTraceItemAttributeKeysApi(organization.slug, attributesWithInvalidChars); - const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, { + initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }} - ); + }, + }); await waitFor(() => expect(result.current.isLoading).toBe(false)); @@ -224,11 +227,12 @@ describe('useTraceItemAttributeKeys', () => { testAttributeKeys ); - const {result} = renderHookWithProviders(useTraceItemAttributeKeys, {initialProps: { + const {result} = renderHookWithProviders(useTraceItemAttributeKeys, { + initialProps: { traceItemType: TraceItemDataset.LOGS, type: 'string', - }} - ); + }, + }); await waitFor(() => expect(result.current.isLoading).toBe(false)); expect(mockResponse).toHaveBeenCalled(); diff --git a/static/app/views/explore/hooks/useVisualizeFields.spec.tsx b/static/app/views/explore/hooks/useVisualizeFields.spec.tsx index 5e93c48fe54c13..0a4e2f38405a34 100644 --- a/static/app/views/explore/hooks/useVisualizeFields.spec.tsx +++ b/static/app/views/explore/hooks/useVisualizeFields.spec.tsx @@ -58,7 +58,8 @@ describe('useVisualizeFields', () => { it('returns numeric fields', () => { const {result} = renderHook(useWrapper, { - wrapper: createWrapper(organization), initialProps: 'avg(score.ttfb)', + wrapper: createWrapper(organization), + initialProps: 'avg(score.ttfb)', }); expect(result.current.map(field => field.value)).toEqual([ @@ -70,7 +71,8 @@ describe('useVisualizeFields', () => { it('returns numeric fields for count', () => { const {result} = renderHook(useWrapper, { - wrapper: createWrapper(organization), initialProps: 'count(span.duration)', + wrapper: createWrapper(organization), + initialProps: 'count(span.duration)', }); expect(result.current.map(field => field.value)).toEqual(['span.duration']); @@ -78,7 +80,8 @@ describe('useVisualizeFields', () => { it('returns string fields for count_unique', () => { const {result} = renderHook(useWrapper, { - wrapper: createWrapper(organization), initialProps: 'count_unique(foobar)', + wrapper: createWrapper(organization), + initialProps: 'count_unique(foobar)', }); expect(result.current.map(field => field.value)).toEqual( diff --git a/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx b/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx index 122bfd90989fc8..1e86edb08c5846 100644 --- a/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx +++ b/static/app/views/explore/logs/useLogsAggregatesTable.spec.tsx @@ -58,13 +58,13 @@ describe('useLogsAggregatesTable', () => { ], }); - renderHookWithProviders( - useLogsAggregatesTable, - {additionalWrapper: Wrapper, initialProps: { - enabled: true, - limit: 100, - }} - ); + renderHookWithProviders(useLogsAggregatesTable, { + additionalWrapper: Wrapper, + initialProps: { + enabled: true, + limit: 100, + }, + }); expect(mockNormalRequest).toHaveBeenCalledTimes(1); expect(mockNormalRequest).toHaveBeenCalledWith( diff --git a/static/app/views/explore/logs/useLogsQuery.spec.tsx b/static/app/views/explore/logs/useLogsQuery.spec.tsx index b5fc08cde8915d..94076801c4b7d7 100644 --- a/static/app/views/explore/logs/useLogsQuery.spec.tsx +++ b/static/app/views/explore/logs/useLogsQuery.spec.tsx @@ -289,7 +289,8 @@ describe('useInfiniteLogsQuery', () => { }); renderHookWithProviders(useInfiniteLogsQuery, { - additionalWrapper: createWrapper(), initialProps: {}, + additionalWrapper: createWrapper(), + initialProps: {}, }); expect(mockNormalRequest).toHaveBeenCalledTimes(1); @@ -380,12 +381,10 @@ describe('useInfiniteLogsQuery', () => { makeMockEventsResponse({cursor: 'page6', nextCursor: 'page7', hasNext: false}), ].map(response => MockApiClient.addMockResponse(response)); - const {result} = renderHookWithProviders( - useInfiniteLogsQuery, - { - additionalWrapper: createWrapper(), initialProps: {highFidelity: true, maxAutoFetches: 3}, - } - ); + const {result} = renderHookWithProviders(useInfiniteLogsQuery, { + additionalWrapper: createWrapper(), + initialProps: {highFidelity: true, maxAutoFetches: 3}, + }); // the first 3 requests should have been called await waitFor(() => expect(mockFlextTimeRequests[0]).toHaveBeenCalledTimes(1)); @@ -433,12 +432,10 @@ describe('useInfiniteLogsQuery', () => { }), ].map(response => MockApiClient.addMockResponse(response)); - const {result} = renderHookWithProviders( - useInfiniteLogsQuery, - { - additionalWrapper: createWrapper(), initialProps: {highFidelity: true, maxAutoFetches: 3}, - } - ); + const {result} = renderHookWithProviders(useInfiniteLogsQuery, { + additionalWrapper: createWrapper(), + initialProps: {highFidelity: true, maxAutoFetches: 3}, + }); // the first 2 requests should have been called and stop because it totals 1000 results await waitFor(() => expect(mockFlextTimeRequests[0]).toHaveBeenCalledTimes(1)); diff --git a/static/app/views/explore/logs/useLogsTimeseries.spec.tsx b/static/app/views/explore/logs/useLogsTimeseries.spec.tsx index 5c733f1179627c..b0ecb7367e854f 100644 --- a/static/app/views/explore/logs/useLogsTimeseries.spec.tsx +++ b/static/app/views/explore/logs/useLogsTimeseries.spec.tsx @@ -73,39 +73,39 @@ describe('useLogsTimeseries', () => { ], }); - renderHookWithProviders( - useLogsTimeseries, - {additionalWrapper: Wrapper, initialProps: { - enabled: true, - timeseriesIngestDelay: 0n, - tableData: { - error: null, - isError: false, - isFetching: false, - isPending: false, - data: [], - meta: { - fields: {}, - units: {}, - }, - isRefetching: false, - isEmpty: true, - fetchNextPage: () => Promise.resolve({} as any), - fetchPreviousPage: () => Promise.resolve({} as any), - refetch: () => Promise.resolve({} as any), - hasNextPage: false, - queryKey: [] as any, - hasPreviousPage: false, - isFetchingNextPage: false, - isFetchingPreviousPage: false, - lastPageLength: 0, - bytesScanned: 0, - dataScanned: undefined, - canResumeAutoFetch: false, - resumeAutoFetch: () => {}, + renderHookWithProviders(useLogsTimeseries, { + additionalWrapper: Wrapper, + initialProps: { + enabled: true, + timeseriesIngestDelay: 0n, + tableData: { + error: null, + isError: false, + isFetching: false, + isPending: false, + data: [], + meta: { + fields: {}, + units: {}, }, - }} - ); + isRefetching: false, + isEmpty: true, + fetchNextPage: () => Promise.resolve({} as any), + fetchPreviousPage: () => Promise.resolve({} as any), + refetch: () => Promise.resolve({} as any), + hasNextPage: false, + queryKey: [] as any, + hasPreviousPage: false, + isFetchingNextPage: false, + isFetchingPreviousPage: false, + lastPageLength: 0, + bytesScanned: 0, + dataScanned: undefined, + canResumeAutoFetch: false, + resumeAutoFetch: () => {}, + }, + }, + }); expect(mockNormalRequest).toHaveBeenCalledTimes(1); expect(mockNormalRequest).toHaveBeenCalledWith( diff --git a/static/app/views/explore/logs/useSaveAsItems.spec.tsx b/static/app/views/explore/logs/useSaveAsItems.spec.tsx index 6de86a7b9f2859..c1c9c4d053e745 100644 --- a/static/app/views/explore/logs/useSaveAsItems.spec.tsx +++ b/static/app/views/explore/logs/useSaveAsItems.spec.tsx @@ -104,17 +104,17 @@ describe('useSaveAsItems', () => { }); it('should open save query modal when save as new query is clicked', () => { - const {result} = renderHookWithProviders( - useSaveAsItems, - {additionalWrapper: createWrapper(), initialProps: { - visualizes: [new VisualizeFunction('count()')], - groupBys: ['message.template'], - interval: '5m', - mode: Mode.AGGREGATE, - search: new MutableSearch('message:"test error"'), - sortBys: [{field: 'timestamp', kind: 'desc'}], - }} - ); + const {result} = renderHookWithProviders(useSaveAsItems, { + additionalWrapper: createWrapper(), + initialProps: { + visualizes: [new VisualizeFunction('count()')], + groupBys: ['message.template'], + interval: '5m', + mode: Mode.AGGREGATE, + search: new MutableSearch('message:"test error"'), + sortBys: [{field: 'timestamp', kind: 'desc'}], + }, + }); const saveAsItems = result.current; const saveAsQuery = saveAsItems.find(item => item.key === 'save-query') as { @@ -161,17 +161,17 @@ describe('useSaveAsItems', () => { }) ); - const {result} = renderHookWithProviders( - useSaveAsItems, - {additionalWrapper: createWrapper(), initialProps: { - visualizes: [new VisualizeFunction('count()')], - groupBys: ['message.template'], - interval: '5m', - mode: Mode.AGGREGATE, - search: new MutableSearch('message:"test"'), - sortBys: [{field: 'timestamp', kind: 'desc'}], - }} - ); + const {result} = renderHookWithProviders(useSaveAsItems, { + additionalWrapper: createWrapper(), + initialProps: { + visualizes: [new VisualizeFunction('count()')], + groupBys: ['message.template'], + interval: '5m', + mode: Mode.AGGREGATE, + search: new MutableSearch('message:"test"'), + sortBys: [{field: 'timestamp', kind: 'desc'}], + }, + }); await waitFor(() => { expect(result.current.some(item => item.key === 'update-query')).toBe(true); @@ -192,17 +192,17 @@ describe('useSaveAsItems', () => { }) ); - const {result} = renderHookWithProviders( - useSaveAsItems, - {additionalWrapper: createWrapper(), initialProps: { - visualizes: [new VisualizeFunction('count()')], - groupBys: ['message.template'], - interval: '5m', - mode: Mode.AGGREGATE, - search: new MutableSearch('message:"test"'), - sortBys: [{field: 'timestamp', kind: 'desc'}], - }} - ); + const {result} = renderHookWithProviders(useSaveAsItems, { + additionalWrapper: createWrapper(), + initialProps: { + visualizes: [new VisualizeFunction('count()')], + groupBys: ['message.template'], + interval: '5m', + mode: Mode.AGGREGATE, + search: new MutableSearch('message:"test"'), + sortBys: [{field: 'timestamp', kind: 'desc'}], + }, + }); const saveAsItems = result.current; @@ -211,19 +211,19 @@ describe('useSaveAsItems', () => { }); it('should call saveQuery with correct parameters when modal saves', async () => { - const {result} = renderHookWithProviders( - useSaveAsItems, - {additionalWrapper: createWrapper(), initialProps: { - visualizes: [new VisualizeFunction('count()')], - groupBys: ['message.template'], - // Note: useSaveQuery uses the value returned by useChartInterval() - // not the interval passed in as options. - interval: '5m', - mode: Mode.AGGREGATE, - search: new MutableSearch('message:"test error"'), - sortBys: [{field: 'timestamp', kind: 'desc'}], - }} - ); + const {result} = renderHookWithProviders(useSaveAsItems, { + additionalWrapper: createWrapper(), + initialProps: { + visualizes: [new VisualizeFunction('count()')], + groupBys: ['message.template'], + // Note: useSaveQuery uses the value returned by useChartInterval() + // not the interval passed in as options. + interval: '5m', + mode: Mode.AGGREGATE, + search: new MutableSearch('message:"test error"'), + sortBys: [{field: 'timestamp', kind: 'desc'}], + }, + }); const saveAsItems = result.current; const saveAsQuery = saveAsItems.find(item => item.key === 'save-query') as { diff --git a/static/app/views/explore/logs/useVirtualStreaming.spec.tsx b/static/app/views/explore/logs/useVirtualStreaming.spec.tsx index 672162459556da..f34c99f6c40c77 100644 --- a/static/app/views/explore/logs/useVirtualStreaming.spec.tsx +++ b/static/app/views/explore/logs/useVirtualStreaming.spec.tsx @@ -102,10 +102,11 @@ describe('useVirtualStreaming', () => { }), ]); - const {result} = renderHookWithProviders( - useVirtualStreaming, - {additionalWrapper: createWrapper({autoRefresh: 'enabled'}), organization, initialProps: {data: mockData}} - ); + const {result} = renderHookWithProviders(useVirtualStreaming, { + additionalWrapper: createWrapper({autoRefresh: 'enabled'}), + organization, + initialProps: {data: mockData}, + }); await waitFor(() => { expect(result.current.virtualStreamedTimestamp).toBeDefined(); @@ -127,10 +128,11 @@ describe('useVirtualStreaming', () => { }), ]); - const {result} = renderHookWithProviders( - useVirtualStreaming, - {additionalWrapper: createWrapper({autoRefresh: 'idle'}), organization, initialProps: {data: mockData}} - ); + const {result} = renderHookWithProviders(useVirtualStreaming, { + additionalWrapper: createWrapper({autoRefresh: 'idle'}), + organization, + initialProps: {data: mockData}, + }); expect(result.current.virtualStreamedTimestamp).toBeUndefined(); }); @@ -147,7 +149,8 @@ describe('useVirtualStreaming', () => { renderHookWithProviders(useVirtualStreaming, { additionalWrapper: createWrapper({autoRefresh: 'enabled'}), - organization, initialProps: {data: mockData}, + organization, + initialProps: {data: mockData}, }); await waitFor(() => { @@ -165,10 +168,10 @@ describe('useVirtualStreaming', () => { }), ]); - const {unmount} = renderHookWithProviders( - useVirtualStreaming, - {additionalWrapper: createWrapper({autoRefresh: 'enabled'}), initialProps: {data: mockData}} - ); + const {unmount} = renderHookWithProviders(useVirtualStreaming, { + additionalWrapper: createWrapper({autoRefresh: 'enabled'}), + initialProps: {data: mockData}, + }); await waitFor(() => { expect(requestAnimationFrameSpy).toHaveBeenCalled(); @@ -179,7 +182,8 @@ describe('useVirtualStreaming', () => { // Re-render with disabled autorefresh renderHookWithProviders(useVirtualStreaming, { additionalWrapper: createWrapper({autoRefresh: 'idle'}), - organization, initialProps: {data: mockData}, + organization, + initialProps: {data: mockData}, }); await waitFor(() => { diff --git a/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx b/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx index 2e03da07442809..3e4009ea3b0739 100644 --- a/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx +++ b/static/app/views/explore/metrics/hooks/useMetricAggregatesTable.spec.tsx @@ -41,19 +41,17 @@ describe('useMetricAggregatesTable', () => { ], method: 'GET', }); - renderHookWithProviders( - useMetricAggregatesTable, - { - additionalWrapper: MockMetricQueryParamsContext, initialProps: { - traceMetric: { - name: 'test metric', - type: 'counter', - }, - limit: 100, - enabled: true, + renderHookWithProviders(useMetricAggregatesTable, { + additionalWrapper: MockMetricQueryParamsContext, + initialProps: { + traceMetric: { + name: 'test metric', + type: 'counter', }, - } - ); + limit: 100, + enabled: true, + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( diff --git a/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx b/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx index 6a6a09c608119b..6cef387880baa2 100644 --- a/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx +++ b/static/app/views/explore/metrics/hooks/useMetricSamplesTable.spec.tsx @@ -54,20 +54,18 @@ describe('useMetricSamplesTable', () => { ], method: 'GET', }); - renderHookWithProviders( - useMetricSamplesTable, - { - additionalWrapper: MockMetricQueryParamsContext, initialProps: { - traceMetric: { - name: 'test metric', - type: 'counter', - }, - fields: [], - limit: 100, - ingestionDelaySeconds: 0, + renderHookWithProviders(useMetricSamplesTable, { + additionalWrapper: MockMetricQueryParamsContext, + initialProps: { + traceMetric: { + name: 'test metric', + type: 'counter', }, - } - ); + fields: [], + limit: 100, + ingestionDelaySeconds: 0, + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( @@ -104,20 +102,18 @@ describe('useMetricSamplesTable', () => { method: 'GET', }); - renderHookWithProviders( - useMetricSamplesTable, - { - additionalWrapper: MockMetricQueryParamsContext, initialProps: { - traceMetric: { - name: 'test.metric', - type: 'counter', - }, - fields: ['trace', 'timestamp'], - limit: 50, - ingestionDelaySeconds: 0, + renderHookWithProviders(useMetricSamplesTable, { + additionalWrapper: MockMetricQueryParamsContext, + initialProps: { + traceMetric: { + name: 'test.metric', + type: 'counter', }, - } - ); + fields: ['trace', 'timestamp'], + limit: 50, + ingestionDelaySeconds: 0, + }, + }); await waitFor(() => { expect(mockRequest).toHaveBeenCalledTimes(1); diff --git a/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx b/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx index 77dc9d4cf3079a..84d616e378f2af 100644 --- a/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx +++ b/static/app/views/explore/metrics/hooks/useMetricTimeseries.spec.tsx @@ -55,15 +55,13 @@ describe('useMetricTimeseries', () => { ], method: 'GET', }); - renderHookWithProviders( - useMetricTimeseries, - { - additionalWrapper: MockMetricQueryParamsContext, initialProps: { - traceMetric: {name: 'test metric', type: 'counter'}, - enabled: true, - }, - } - ); + renderHookWithProviders(useMetricTimeseries, { + additionalWrapper: MockMetricQueryParamsContext, + initialProps: { + traceMetric: {name: 'test metric', type: 'counter'}, + enabled: true, + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( diff --git a/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx b/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx index 72d3d11d6a6de8..80b60820a0d8a8 100644 --- a/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx +++ b/static/app/views/explore/metrics/useSaveAsMetricItems.spec.tsx @@ -64,12 +64,12 @@ describe('useSaveAsMetricItems', () => { }); it('should open save query modal when save as new query is clicked', () => { - const {result} = renderHook( - useSaveAsMetricItems, - {wrapper: createWrapper(), initialProps: { - interval: '5m', - }} - ); + const {result} = renderHook(useSaveAsMetricItems, { + wrapper: createWrapper(), + initialProps: { + interval: '5m', + }, + }); const saveAsItems = result.current; const saveAsQuery = saveAsItems.find(item => item.key === 'save-query') as { @@ -114,12 +114,12 @@ describe('useSaveAsMetricItems', () => { }) ); - const {result} = renderHook( - useSaveAsMetricItems, - {wrapper: createWrapper(), initialProps: { - interval: '5m', - }} - ); + const {result} = renderHook(useSaveAsMetricItems, { + wrapper: createWrapper(), + initialProps: { + interval: '5m', + }, + }); await waitFor(() => { expect(result.current.some(item => item.key === 'update-query')).toBe(true); @@ -138,12 +138,12 @@ describe('useSaveAsMetricItems', () => { }) ); - const {result} = renderHook( - useSaveAsMetricItems, - {wrapper: createWrapper(), initialProps: { - interval: '5m', - }} - ); + const {result} = renderHook(useSaveAsMetricItems, { + wrapper: createWrapper(), + initialProps: { + interval: '5m', + }, + }); const saveAsItems = result.current; @@ -156,22 +156,20 @@ describe('useSaveAsMetricItems', () => { features: [], }); - const {result} = renderHook( - useSaveAsMetricItems, - { - wrapper: function ({children}: {children?: React.ReactNode}) { - return ( - - - {children} - - - ); - }, initialProps: { - interval: '5m', - }, - } - ); + const {result} = renderHook(useSaveAsMetricItems, { + wrapper: function ({children}: {children?: React.ReactNode}) { + return ( + + + {children} + + + ); + }, + initialProps: { + interval: '5m', + }, + }); const saveAsItems = result.current; expect(saveAsItems).toEqual([]); diff --git a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx index 9651affef121f7..ce08e4059101fd 100644 --- a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx +++ b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTable.spec.tsx @@ -88,14 +88,15 @@ describe('useMultiQueryTable', () => { ], method: 'GET', }); - renderHookWithProviders(hook, {initialProps: { + renderHookWithProviders(hook, { + initialProps: { enabled: true, groupBys: [], query: 'test value', sortBys: [], yAxes: [], - }} - ); + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( diff --git a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx index 1b21be6beef561..f7f0813d3b4e44 100644 --- a/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx +++ b/static/app/views/explore/multiQueryMode/hooks/useMultiQueryTimeseries.spec.tsx @@ -70,11 +70,12 @@ describe('useMultiQueryTimeseries', () => { ], method: 'GET', }); - renderHookWithProviders(useMultiQueryTimeseries, {initialProps: { + renderHookWithProviders(useMultiQueryTimeseries, { + initialProps: { enabled: true, index: 0, - }} - ); + }, + }); expect(mockNormalRequestUrl).toHaveBeenCalledTimes(1); expect(mockNormalRequestUrl).toHaveBeenCalledWith( diff --git a/static/app/views/explore/queryParams/context.spec.tsx b/static/app/views/explore/queryParams/context.spec.tsx index 231edcafa92e53..5a1385d02d201c 100644 --- a/static/app/views/explore/queryParams/context.spec.tsx +++ b/static/app/views/explore/queryParams/context.spec.tsx @@ -1,6 +1,6 @@ import {useMemo, type ReactNode} from 'react'; -import {renderHookWithProviders, render} from 'sentry-test/reactTestingLibrary'; +import {render, renderHookWithProviders} from 'sentry-test/reactTestingLibrary'; import {useResettableState} from 'sentry/utils/useResettableState'; import { diff --git a/static/app/views/onboarding/useConfigureSdk.spec.tsx b/static/app/views/onboarding/useConfigureSdk.spec.tsx index a4e708edd09956..ae84b850a12f30 100644 --- a/static/app/views/onboarding/useConfigureSdk.spec.tsx +++ b/static/app/views/onboarding/useConfigureSdk.spec.tsx @@ -79,13 +79,17 @@ describe('useConfigureSdk', () => { }); it('returns loading state correctly', () => { - const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); + const {result} = renderHookWithProviders(useConfigureSdk, { + initialProps: {onComplete}, + }); expect(result.current.isLoadingData).toBe(true); }); it('opens the framework suggestion modal if platform is supported', async () => { - const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); + const {result} = renderHookWithProviders(useConfigureSdk, { + initialProps: {onComplete}, + }); await act(async () => { await result.current.configureSdk(frameworkModalSupportedPlatform); @@ -95,7 +99,9 @@ describe('useConfigureSdk', () => { }); it('does not open the framework suggestion modal if platform is not supported', async () => { - const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); + const {result} = renderHookWithProviders(useConfigureSdk, { + initialProps: {onComplete}, + }); await act(async () => { await result.current.configureSdk(notFrameworkModalSupportedPlatform); @@ -106,7 +112,9 @@ describe('useConfigureSdk', () => { }); it('creates project only once even if called multiple times', async () => { - const {result} = renderHookWithProviders(useConfigureSdk, {initialProps: {onComplete}}); + const {result} = renderHookWithProviders(useConfigureSdk, { + initialProps: {onComplete}, + }); mockCreateProject.mockImplementation( () => new Promise(resolve => setTimeout(resolve, 10)) diff --git a/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx b/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx index 2b3845598257d3..79fe294bcd0e1d 100644 --- a/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx +++ b/static/app/views/performance/newTraceDetails/traceApi/useTrace.spec.tsx @@ -48,10 +48,11 @@ describe('useTrace', () => { body: [], }); - renderHookWithProviders(useTrace, {initialProps: { + renderHookWithProviders(useTrace, { + initialProps: { traceSlug: 'test-trace-id', - }} - ); + }, + }); // Wait for the hook to make the API call await waitFor(() => { @@ -133,10 +134,11 @@ describe('useTrace', () => { body: [], }); - renderHookWithProviders(useTrace, {initialProps: { + renderHookWithProviders(useTrace, { + initialProps: { traceSlug: 'trace-test-id', - }} - ); + }, + }); await waitFor(() => { expect(eapTraceMock).toHaveBeenCalled(); diff --git a/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx b/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx index 15bc3139ee5796..6dba871e310d49 100644 --- a/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx +++ b/static/app/views/performance/newTraceDetails/traceApi/useTraceMeta.spec.tsx @@ -83,7 +83,8 @@ describe('useTraceMeta', () => { }); const {result} = renderHookWithProviders(useTraceMeta, { - organization, initialProps: mockedReplayTraces, + organization, + initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ @@ -171,7 +172,8 @@ describe('useTraceMeta', () => { }); const {result} = renderHookWithProviders(useTraceMeta, { - organization: org, initialProps: mockedReplayTraces, + organization: org, + initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ @@ -223,7 +225,8 @@ describe('useTraceMeta', () => { }); const {result} = renderHookWithProviders(useTraceMeta, { - organization, initialProps: mockedReplayTraces, + organization, + initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ @@ -291,7 +294,8 @@ describe('useTraceMeta', () => { }); const {result} = renderHookWithProviders(useTraceMeta, { - organization, initialProps: mockedReplayTraces, + organization, + initialProps: mockedReplayTraces, }); expect(result.current).toEqual({ diff --git a/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx b/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx index 8d042ebbe6efdc..281599a698346d 100644 --- a/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx +++ b/static/app/views/performance/newTraceDetails/traceApi/useTraceTree.spec.tsx @@ -33,14 +33,14 @@ const contextWrapper = () => { describe('useTraceTree', () => { it('returns tree for error case', async () => { - const {result} = renderHookWithProviders( - useTraceTree, - {additionalWrapper: contextWrapper(), initialProps: { - trace: getMockedTraceResults('error'), - traceSlug: 'test-trace', - replay: null, - }} - ); + const {result} = renderHookWithProviders(useTraceTree, { + additionalWrapper: contextWrapper(), + initialProps: { + trace: getMockedTraceResults('error'), + traceSlug: 'test-trace', + replay: null, + }, + }); await waitFor(() => { expect(result.current.type).toBe('error'); @@ -48,14 +48,14 @@ describe('useTraceTree', () => { }); it('returns tree for loading case', async () => { - const {result} = renderHookWithProviders( - useTraceTree, - {additionalWrapper: contextWrapper(), initialProps: { - trace: getMockedTraceResults('pending'), - traceSlug: 'test-trace', - replay: null, - }} - ); + const {result} = renderHookWithProviders(useTraceTree, { + additionalWrapper: contextWrapper(), + initialProps: { + trace: getMockedTraceResults('pending'), + traceSlug: 'test-trace', + replay: null, + }, + }); await waitFor(() => { expect(result.current.type).toBe('loading'); @@ -63,17 +63,17 @@ describe('useTraceTree', () => { }); it('returns tree for empty success case', async () => { - const {result} = renderHookWithProviders( - useTraceTree, - {additionalWrapper: contextWrapper(), initialProps: { - trace: getMockedTraceResults('success', { - transactions: [], - orphan_errors: [], - }), - traceSlug: 'test-trace', - replay: null, - }} - ); + const {result} = renderHookWithProviders(useTraceTree, { + additionalWrapper: contextWrapper(), + initialProps: { + trace: getMockedTraceResults('success', { + transactions: [], + orphan_errors: [], + }), + traceSlug: 'test-trace', + replay: null, + }, + }); await waitFor(() => { expect(result.current.type).toBe('empty'); @@ -116,14 +116,14 @@ describe('useTraceTree', () => { ], }; - const {result} = renderHookWithProviders( - useTraceTree, - {additionalWrapper: contextWrapper(), initialProps: { - trace: getMockedTraceResults('success', mockedTrace), - traceSlug: 'test-trace', - replay: null, - }} - ); + const {result} = renderHookWithProviders(useTraceTree, { + additionalWrapper: contextWrapper(), + initialProps: { + trace: getMockedTraceResults('success', mockedTrace), + traceSlug: 'test-trace', + replay: null, + }, + }); await waitFor(() => { expect(result.current.type).toBe('trace'); diff --git a/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx b/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx index 2eca75c58b78a5..ad0ad2be7b60af 100644 --- a/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx +++ b/static/app/views/prevent/tests/queries/useGetActiveIntegratedOrgs.spec.tsx @@ -30,10 +30,10 @@ describe('useGetActiveIntegratedOrgs', () => { body: mockIntegrations, }); - const {result} = renderHookWithProviders( - useGetActiveIntegratedOrgs, - {organization, initialProps: {organization}} - ); + const {result} = renderHookWithProviders(useGetActiveIntegratedOrgs, { + organization, + initialProps: {organization}, + }); await waitFor(() => { expect(result.current.isSuccess).toBe(true); @@ -70,10 +70,10 @@ describe('useGetActiveIntegratedOrgs', () => { body: mockIntegrations, }); - const {result} = renderHookWithProviders( - useGetActiveIntegratedOrgs, - {organization, initialProps: {organization}} - ); + const {result} = renderHookWithProviders(useGetActiveIntegratedOrgs, { + organization, + initialProps: {organization}, + }); await waitFor(() => { expect(result.current.isSuccess).toBe(true); @@ -91,10 +91,10 @@ describe('useGetActiveIntegratedOrgs', () => { body: {detail: 'Repository not found'}, }); - const {result} = renderHookWithProviders( - useGetActiveIntegratedOrgs, - {organization, initialProps: {organization}} - ); + const {result} = renderHookWithProviders(useGetActiveIntegratedOrgs, { + organization, + initialProps: {organization}, + }); await waitFor(() => { expect(result.current.isError).toBe(true); diff --git a/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx b/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx index 960809502b911d..0032f427758844 100644 --- a/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx +++ b/static/app/views/prevent/tests/queries/useGetTestResults.spec.tsx @@ -100,7 +100,8 @@ describe('useInfiniteTestResults', () => { const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, initialProps: {}, + organization, + initialProps: {}, }); await waitFor(() => { @@ -152,16 +153,14 @@ describe('useInfiniteTestResults', () => { ); - const {result} = renderHookWithProviders( - useInfiniteTestResults, - { - additionalWrapper, - organization, initialProps: { - cursor: 'next-cursor', - navigation: 'next', - }, - } - ); + const {result} = renderHookWithProviders(useInfiniteTestResults, { + additionalWrapper, + organization, + initialProps: { + cursor: 'next-cursor', + navigation: 'next', + }, + }); await waitFor(() => { expect(result.current.isSuccess).toBe(true); @@ -195,7 +194,8 @@ describe('useInfiniteTestResults', () => { const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, initialProps: {}, + organization, + initialProps: {}, }); await waitFor(() => { @@ -227,7 +227,8 @@ describe('useInfiniteTestResults', () => { const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, initialProps: {}, + organization, + initialProps: {}, }); await waitFor(() => { @@ -278,7 +279,8 @@ describe('useInfiniteTestResults', () => { const {result} = renderHookWithProviders(useInfiniteTestResults, { additionalWrapper, - organization, initialProps: {}, + organization, + initialProps: {}, }); await waitFor(() => { diff --git a/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx b/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx index 81034ad0e760f1..99b5617cb9d481 100644 --- a/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx +++ b/static/app/views/prevent/tokens/repoTokenTable/hooks/useInfiniteRepositoryTokens.spec.tsx @@ -68,16 +68,14 @@ describe('useInfiniteRepositoryTokens', () => { ); - const {result} = renderHookWithProviders( - useInfiniteRepositoryTokens, - { - organization, - additionalWrapper, initialProps: { - cursor: undefined, - navigation: undefined, - }, - } - ); + const {result} = renderHookWithProviders(useInfiniteRepositoryTokens, { + organization, + additionalWrapper, + initialProps: { + cursor: undefined, + navigation: undefined, + }, + }); await waitFor(() => { expect(result.current.isSuccess).toBe(true); @@ -119,16 +117,14 @@ describe('useInfiniteRepositoryTokens', () => { ); - const {result} = renderHookWithProviders( - useInfiniteRepositoryTokens, - { - organization, - additionalWrapper, initialProps: { - cursor: 'next-cursor', - navigation: 'next', - }, - } - ); + const {result} = renderHookWithProviders(useInfiniteRepositoryTokens, { + organization, + additionalWrapper, + initialProps: { + cursor: 'next-cursor', + navigation: 'next', + }, + }); await waitFor(() => { expect(result.current.isSuccess).toBe(true); @@ -153,16 +149,14 @@ describe('useInfiniteRepositoryTokens', () => { ); - const {result} = renderHookWithProviders( - useInfiniteRepositoryTokens, - { - organization, - additionalWrapper, initialProps: { - cursor: undefined, - navigation: undefined, - }, - } - ); + const {result} = renderHookWithProviders(useInfiniteRepositoryTokens, { + organization, + additionalWrapper, + initialProps: { + cursor: undefined, + navigation: undefined, + }, + }); await waitFor(() => { expect(result.current.isSuccess).toBe(true); @@ -191,16 +185,14 @@ describe('useInfiniteRepositoryTokens', () => { ); - const {result} = renderHookWithProviders( - useInfiniteRepositoryTokens, - { - additionalWrapper, - organization, initialProps: { - cursor: undefined, - navigation: undefined, - }, - } - ); + const {result} = renderHookWithProviders(useInfiniteRepositoryTokens, { + additionalWrapper, + organization, + initialProps: { + cursor: undefined, + navigation: undefined, + }, + }); await waitFor(() => { expect(result.current.isError).toBe(true); @@ -225,16 +217,14 @@ describe('useInfiniteRepositoryTokens', () => { ); - const {result} = renderHookWithProviders( - useInfiniteRepositoryTokens, - { - additionalWrapper, - organization, initialProps: { - cursor: undefined, - navigation: undefined, - }, - } - ); + const {result} = renderHookWithProviders(useInfiniteRepositoryTokens, { + additionalWrapper, + organization, + initialProps: { + cursor: undefined, + navigation: undefined, + }, + }); expect(result.current.data).toHaveLength(0); expect(result.current.totalCount).toBe(0); diff --git a/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx b/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx index 0d5f6edde7925c..8f53f70b143200 100644 --- a/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx +++ b/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx @@ -56,7 +56,8 @@ describe('useReplaySummary', () => { }); const {result} = renderHookWithProviders(useReplaySummary, { - organization: mockOrganization, initialProps: mockReplay, + organization: mockOrganization, + initialProps: mockReplay, }); await waitFor(() => { @@ -74,7 +75,8 @@ describe('useReplaySummary', () => { body: {detail: 'Internal server error'}, }); const {result} = renderHookWithProviders(useReplaySummary, { - organization: mockOrganization, initialProps: mockReplay, + organization: mockOrganization, + initialProps: mockReplay, }); await waitFor(() => { @@ -143,7 +145,8 @@ describe('useReplaySummary', () => { }); const {result} = renderHookWithProviders(useReplaySummary, { - organization: mockOrganization, initialProps: mockReplay, + organization: mockOrganization, + initialProps: mockReplay, }); // Wait for the return value to be in pending state @@ -166,7 +169,8 @@ describe('useReplaySummary', () => { }); const {result} = renderHookWithProviders(useReplaySummary, { - organization: mockOrganization, initialProps: mockReplay, + organization: mockOrganization, + initialProps: mockReplay, }); await waitFor(() => { @@ -185,7 +189,8 @@ describe('useReplaySummary', () => { }); const {result} = renderHookWithProviders(useReplaySummary, { - organization: mockOrganization, initialProps: mockReplay, + organization: mockOrganization, + initialProps: mockReplay, }); await waitFor(() => { @@ -201,7 +206,8 @@ describe('useReplaySummary', () => { }); const {result} = renderHookWithProviders(useReplaySummary, { - organization: mockOrganization, initialProps: mockReplay, + organization: mockOrganization, + initialProps: mockReplay, }); await waitFor(() => { @@ -227,12 +233,10 @@ describe('useReplaySummary', () => { method: 'POST', }); - const {result, rerender} = renderHookWithProviders( - useReplaySummary, - { - organization: mockOrganization, initialProps: mockReplay, - } - ); + const {result, rerender} = renderHookWithProviders(useReplaySummary, { + organization: mockOrganization, + initialProps: mockReplay, + }); await waitFor(() => { expect(result.current.isPending).toBe(false); diff --git a/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx b/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx index e76611c26fd9a9..d6f3dd5075b0ff 100644 --- a/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx +++ b/static/app/views/replays/detail/trace/useReplayTraces.spec.tsx @@ -35,7 +35,9 @@ describe('useTraceMeta', () => { }, }); - const {result} = renderHookWithProviders(useReplayTraces, {initialProps: {replayRecord}}); + const {result} = renderHookWithProviders(useReplayTraces, { + initialProps: {replayRecord}, + }); expect(result.current.indexComplete).toBe(false); @@ -61,7 +63,9 @@ describe('useTraceMeta', () => { statusCode: 400, }); - const {result} = renderHookWithProviders(useReplayTraces, {initialProps: {replayRecord}}); + const {result} = renderHookWithProviders(useReplayTraces, { + initialProps: {replayRecord}, + }); expect(result.current.indexComplete).toBe(false); diff --git a/static/gsApp/hooks/genAiAccess.spec.tsx b/static/gsApp/hooks/genAiAccess.spec.tsx index 4cda9b92056b13..ad21bdfc21c5c8 100644 --- a/static/gsApp/hooks/genAiAccess.spec.tsx +++ b/static/gsApp/hooks/genAiAccess.spec.tsx @@ -53,7 +53,8 @@ describe('useGenAiConsentButtonAccess', () => { mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); const {result} = renderHook(useGenAiConsentButtonAccess, { - wrapper: contextWrapper(organization), initialProps: {subscription}, + wrapper: contextWrapper(organization), + initialProps: {subscription}, }); expect(result.current).toEqual( @@ -84,7 +85,8 @@ describe('useGenAiConsentButtonAccess', () => { mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); const {result} = renderHook(useGenAiConsentButtonAccess, { - wrapper: contextWrapper(organization), initialProps: {subscription}, + wrapper: contextWrapper(organization), + initialProps: {subscription}, }); expect(result.current).toEqual( @@ -115,7 +117,8 @@ describe('useGenAiConsentButtonAccess', () => { mockUseUser.mockReturnValue(UserFixture({isSuperuser: true})); const {result} = renderHook(useGenAiConsentButtonAccess, { - wrapper: contextWrapper(organization), initialProps: {subscription}, + wrapper: contextWrapper(organization), + initialProps: {subscription}, }); expect(result.current).toEqual( @@ -146,7 +149,8 @@ describe('useGenAiConsentButtonAccess', () => { mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); const {result} = renderHook(useGenAiConsentButtonAccess, { - wrapper: contextWrapper(organization), initialProps: {subscription}, + wrapper: contextWrapper(organization), + initialProps: {subscription}, }); expect(result.current).toEqual( @@ -180,7 +184,8 @@ describe('useGenAiConsentButtonAccess', () => { mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); const {result} = renderHook(useGenAiConsentButtonAccess, { - wrapper: contextWrapper(organization), initialProps: {subscription}, + wrapper: contextWrapper(organization), + initialProps: {subscription}, }); expect(result.current).toEqual( @@ -211,7 +216,8 @@ describe('useGenAiConsentButtonAccess', () => { mockUseUser.mockReturnValue(UserFixture({isSuperuser: false})); const {result} = renderHook(useGenAiConsentButtonAccess, { - wrapper: contextWrapper(organization), initialProps: {subscription}, + wrapper: contextWrapper(organization), + initialProps: {subscription}, }); expect(result.current).toEqual( diff --git a/static/gsApp/hooks/useMaxPickableDays.spec.tsx b/static/gsApp/hooks/useMaxPickableDays.spec.tsx index 8c23fdf0a7acd9..46cd1d5d0a9a36 100644 --- a/static/gsApp/hooks/useMaxPickableDays.spec.tsx +++ b/static/gsApp/hooks/useMaxPickableDays.spec.tsx @@ -12,10 +12,11 @@ import {useMaxPickableDays} from './useMaxPickableDays'; describe('useMaxPickableDays', () => { describe('without downsampled-date-page-filter', () => { it('returns 90/90 for transactions', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.TRANSACTIONS], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 90, @@ -24,10 +25,11 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for replays', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.REPLAYS], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 90, @@ -36,10 +38,11 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for spans without flag', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.SPANS], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 30, @@ -49,16 +52,14 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for spans with flag', () => { - const {result} = renderHookWithProviders( - useMaxPickableDays, - { - organization: OrganizationFixture({ - features: ['visibility-explore-range-high'], - }), initialProps: { - dataCategories: [DataCategory.SPANS], - }, - } - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization: OrganizationFixture({ + features: ['visibility-explore-range-high'], + }), + initialProps: { + dataCategories: [DataCategory.SPANS], + }, + }); expect(result.current).toEqual({ maxPickableDays: 90, @@ -68,10 +69,11 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for tracemetrics', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.TRACE_METRICS], - }} - ); + }, + }); expect(result.current).toEqual({ defaultPeriod: '24h', @@ -81,10 +83,11 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for logs', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [DataCategory.LOG_BYTE, DataCategory.LOG_ITEM], - }} - ); + }, + }); expect(result.current).toEqual({ defaultPeriod: '24h', @@ -94,7 +97,8 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for many without flag', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [ DataCategory.SPANS, DataCategory.SPANS_INDEXED, @@ -102,8 +106,8 @@ describe('useMaxPickableDays', () => { DataCategory.LOG_BYTE, DataCategory.LOG_ITEM, ], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 30, @@ -113,15 +117,16 @@ describe('useMaxPickableDays', () => { }); it('returns 90/90 for profiles', () => { - const {result} = renderHookWithProviders(useMaxPickableDays, {initialProps: { + const {result} = renderHookWithProviders(useMaxPickableDays, { + initialProps: { dataCategories: [ DataCategory.PROFILE_CHUNKS, DataCategory.PROFILE_CHUNKS_UI, DataCategory.PROFILE_DURATION, DataCategory.PROFILE_DURATION_UI, ], - }} - ); + }, + }); expect(result.current).toEqual({ maxPickableDays: 90, @@ -154,12 +159,12 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for transactions', () => { - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [DataCategory.TRANSACTIONS], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [DataCategory.TRANSACTIONS], + }, + }); expect(result.current).toEqual({ maxPickableDays: 30, @@ -168,12 +173,12 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for replays', () => { - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [DataCategory.REPLAYS], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [DataCategory.REPLAYS], + }, + }); expect(result.current).toEqual({ maxPickableDays: 30, @@ -183,12 +188,12 @@ describe('useMaxPickableDays', () => { it('returns 121/121 for spans on 2025/12/31', () => { jest.useFakeTimers().setSystemTime(new Date(2025, 11, 31)); - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [DataCategory.SPANS], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [DataCategory.SPANS], + }, + }); expect(result.current).toEqual({ maxPickableDays: 121, @@ -199,12 +204,12 @@ describe('useMaxPickableDays', () => { it('returns 396/396 for spans on 2027/01/01', () => { jest.useFakeTimers().setSystemTime(new Date(2027, 0, 1)); - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [DataCategory.SPANS], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [DataCategory.SPANS], + }, + }); expect(result.current).toEqual({ maxPickableDays: 396, @@ -214,12 +219,12 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for tracemetrics', () => { - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [DataCategory.TRACE_METRICS], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [DataCategory.TRACE_METRICS], + }, + }); expect(result.current).toEqual({ defaultPeriod: '24h', @@ -229,12 +234,12 @@ describe('useMaxPickableDays', () => { }); it('returns 30/30 days for logs', () => { - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [DataCategory.LOG_BYTE, DataCategory.LOG_ITEM], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [DataCategory.LOG_BYTE, DataCategory.LOG_ITEM], + }, + }); expect(result.current).toEqual({ defaultPeriod: '24h', @@ -245,18 +250,18 @@ describe('useMaxPickableDays', () => { it('returns 396/396 for many without flag', () => { jest.useFakeTimers().setSystemTime(new Date(2027, 0, 1)); - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [ - DataCategory.SPANS, - DataCategory.SPANS_INDEXED, - DataCategory.TRACE_METRICS, - DataCategory.LOG_BYTE, - DataCategory.LOG_ITEM, - ], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [ + DataCategory.SPANS, + DataCategory.SPANS_INDEXED, + DataCategory.TRACE_METRICS, + DataCategory.LOG_BYTE, + DataCategory.LOG_ITEM, + ], + }, + }); expect(result.current).toEqual({ maxPickableDays: 396, @@ -266,17 +271,17 @@ describe('useMaxPickableDays', () => { }); it('returns 30/90 for profiles', () => { - const {result} = renderHookWithProviders( - useMaxPickableDays, - {organization, initialProps: { - dataCategories: [ - DataCategory.PROFILE_CHUNKS, - DataCategory.PROFILE_CHUNKS_UI, - DataCategory.PROFILE_DURATION, - DataCategory.PROFILE_DURATION_UI, - ], - }} - ); + const {result} = renderHookWithProviders(useMaxPickableDays, { + organization, + initialProps: { + dataCategories: [ + DataCategory.PROFILE_CHUNKS, + DataCategory.PROFILE_CHUNKS_UI, + DataCategory.PROFILE_DURATION, + DataCategory.PROFILE_DURATION_UI, + ], + }, + }); expect(result.current).toEqual({ maxPickableDays: 30, diff --git a/static/gsApp/hooks/useProductBillingAccess.spec.tsx b/static/gsApp/hooks/useProductBillingAccess.spec.tsx index bb2c5fa4c48846..b515507d94f663 100644 --- a/static/gsApp/hooks/useProductBillingAccess.spec.tsx +++ b/static/gsApp/hooks/useProductBillingAccess.spec.tsx @@ -18,32 +18,26 @@ describe('useProductBillingAccess', () => { SubscriptionStore.set(organization.slug, subscription); }); it('returns true if the org has billing access to the given product', () => { - const {result} = renderHookWithProviders( - useProductBillingAccess, - { - organization, initialProps: DataCategory.ERRORS, - } - ); + const {result} = renderHookWithProviders(useProductBillingAccess, { + organization, + initialProps: DataCategory.ERRORS, + }); expect(result.current).toBe(true); }); it('returns false if the org does not have billing access to the given product', () => { - const {result} = renderHookWithProviders( - useProductBillingAccess, - { - organization, initialProps: DataCategory.TRANSACTIONS, - } - ); + const {result} = renderHookWithProviders(useProductBillingAccess, { + organization, + initialProps: DataCategory.TRANSACTIONS, + }); expect(result.current).toBe(false); }); it('uses parent add-on context when appropriate', () => { - const {result: result1} = renderHookWithProviders( - useProductBillingAccess, - { - organization, initialProps: DataCategory.SEER_USER, - } - ); + const {result: result1} = renderHookWithProviders(useProductBillingAccess, { + organization, + initialProps: DataCategory.SEER_USER, + }); expect(result1.current).toBe(false); act(() => { @@ -55,12 +49,10 @@ describe('useProductBillingAccess', () => { SubscriptionStore.set(organization.slug, subscription); }); - const {result: result2} = renderHookWithProviders( - useProductBillingAccess, - { - organization, initialProps: DataCategory.SEER_USER, - } - ); + const {result: result2} = renderHookWithProviders(useProductBillingAccess, { + organization, + initialProps: DataCategory.SEER_USER, + }); expect(result2.current).toBe(false); // still false because add-on parent is not enabled act(() => { @@ -71,12 +63,10 @@ describe('useProductBillingAccess', () => { SubscriptionStore.set(organization.slug, subscription); }); - const {result: result3} = renderHookWithProviders( - useProductBillingAccess, - { - organization, initialProps: DataCategory.SEER_USER, - } - ); + const {result: result3} = renderHookWithProviders(useProductBillingAccess, { + organization, + initialProps: DataCategory.SEER_USER, + }); expect(result3.current).toBe(true); // now true because add-on parent is enabled }); }); From bcd7e056f13518706010585f2e0cab5d95558a78 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 6 Feb 2026 11:15:03 -0800 Subject: [PATCH 6/7] fix some messy tests --- static/app/utils/useIsMountedRef.spec.tsx | 12 ++++++------ .../views/explore/queryParams/context.spec.tsx | 17 ++++++++++------- .../replays/detail/ai/useReplaySummary.spec.tsx | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/static/app/utils/useIsMountedRef.spec.tsx b/static/app/utils/useIsMountedRef.spec.tsx index d6d341fc009fb5..85468c06f85016 100644 --- a/static/app/utils/useIsMountedRef.spec.tsx +++ b/static/app/utils/useIsMountedRef.spec.tsx @@ -1,4 +1,4 @@ -import {render, renderHook} from 'sentry-test/reactTestingLibrary'; +import {renderHook} from 'sentry-test/reactTestingLibrary'; import {useIsMountedRef} from './useIsMountedRef'; @@ -9,12 +9,12 @@ describe('useIsMounted', () => { expect(result.current).toBeInstanceOf(Object); }); - function TestComponent() { - const isMountedRef = useIsMountedRef(); - return isMountedRef.current; - } it('should return false within first render', () => { - const {result} = render(); + // eslint-disable-next-line @sentry/no-renderHook-arrow-function + const {result} = renderHook(() => { + const isMountedRef = useIsMountedRef(); + return isMountedRef.current; + }); expect(result.current).toBe(false); }); diff --git a/static/app/views/explore/queryParams/context.spec.tsx b/static/app/views/explore/queryParams/context.spec.tsx index 5a1385d02d201c..f96040e8aeab1b 100644 --- a/static/app/views/explore/queryParams/context.spec.tsx +++ b/static/app/views/explore/queryParams/context.spec.tsx @@ -1,6 +1,6 @@ import {useMemo, type ReactNode} from 'react'; -import {render, renderHookWithProviders} from 'sentry-test/reactTestingLibrary'; +import {renderHookWithProviders} from 'sentry-test/reactTestingLibrary'; import {useResettableState} from 'sentry/utils/useResettableState'; import { @@ -67,12 +67,15 @@ describe('QueryParamsContext', () => { describe('useSetQueryParamsCrossEvents', () => { it('should set the crossEvents', () => { - function QueryParamsCrossEvents() { - const setCrossEvents = useSetQueryParamsCrossEvents(); - setCrossEvents([{query: 'bar', type: 'logs'}]); - return useQueryParamsCrossEvents(); - } - render(); + renderHookWithProviders( + // eslint-disable-next-line @sentry/no-renderHook-arrow-function + () => { + const setCrossEvents = useSetQueryParamsCrossEvents(); + setCrossEvents([{query: 'bar', type: 'logs'}]); + return useQueryParamsCrossEvents(); + }, + {additionalWrapper: Wrapper} + ); expect(mockSetQueryParams).toHaveBeenCalled(); expect(mockSetQueryParams).toHaveBeenCalledWith({ diff --git a/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx b/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx index 007ff1706f1038..e45da89be4cf45 100644 --- a/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx +++ b/static/app/views/replays/detail/ai/useReplaySummary.spec.tsx @@ -249,7 +249,7 @@ describe('useReplaySummary', () => { // Update the segment count and expect a POST. mockReplayRecord.count_segments = 2; mockReplay.getReplay = jest.fn().mockReturnValue(mockReplayRecord); - rerender(); + rerender(mockReplay); await waitFor(() => { expect(mockPostRequest).toHaveBeenCalledWith( From 007e498712b21301f0bf564117f19240c84c8242 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 6 Feb 2026 11:25:21 -0800 Subject: [PATCH 7/7] fix ts --- static/app/utils/api/apiOptions.spec.tsx | 4 +++- .../utils/profiling/hooks/useProfileFunctionTrends.spec.tsx | 4 ++-- static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx | 4 ++-- static/app/utils/url/useQueryParamState.spec.tsx | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/static/app/utils/api/apiOptions.spec.tsx b/static/app/utils/api/apiOptions.spec.tsx index f08cf955f8cc14..dc92a03f39147e 100644 --- a/static/app/utils/api/apiOptions.spec.tsx +++ b/static/app/utils/api/apiOptions.spec.tsx @@ -88,6 +88,7 @@ describe('apiOptions', () => { body: ['Project 1', 'Project 2'], }); + // @ts-expect-error initialProps is not typed correctly const {result} = renderHook(useQuery, {wrapper, initialProps: options}); await waitFor(() => result.current.isSuccess); @@ -111,6 +112,7 @@ describe('apiOptions', () => { const {result} = renderHook(useQuery, { wrapper, + // @ts-expect-error select is not typed correctly initialProps: {...options, select: selectWithHeaders(['Link', 'X-Hits'] as const)}, }); @@ -121,7 +123,7 @@ describe('apiOptions', () => { headers: {Link: 'my-link', 'X-Hits': 'some-hits'}, }); - // headers should be narrowly typed + // @ts-expect-error headers should be narrowly typed expectTypeOf(result.current.data!.headers).toEqualTypeOf<{ Link: string | undefined; 'X-Hits': string | undefined; diff --git a/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx b/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx index 64923aac41bddd..61043b106ba9b8 100644 --- a/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx +++ b/static/app/utils/profiling/hooks/useProfileFunctionTrends.spec.tsx @@ -29,7 +29,7 @@ describe('useProfileFunctionTrendss', () => { body: {data: []}, }); - const hook = renderHook(useProfileFunctionTrends, { + const hook = renderHook(useProfileFunctionTrends, { wrapper: TestContext, initialProps: { trendFunction: 'p95()', @@ -49,7 +49,7 @@ describe('useProfileFunctionTrendss', () => { body: {data: []}, }); - const hook = renderHook(useProfileFunctionTrends, { + const hook = renderHook(useProfileFunctionTrends, { wrapper: TestContext, initialProps: { trendFunction: 'p95()', diff --git a/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx b/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx index 008a8dfed03f89..d308787e9748c9 100644 --- a/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx +++ b/static/app/utils/profiling/hooks/useProfileFunctions.spec.tsx @@ -13,7 +13,7 @@ describe('useProfileFunctions', () => { body: {data: []}, }); - const hook = renderHookWithProviders(useProfileFunctions, { + const hook = renderHookWithProviders(useProfileFunctions, { initialProps: { fields: ['count()'], referrer: '', @@ -36,7 +36,7 @@ describe('useProfileFunctions', () => { body: {data: []}, }); - const hook = renderHookWithProviders(useProfileFunctions, { + const hook = renderHookWithProviders(useProfileFunctions, { initialProps: { fields: ['count()'], referrer: '', diff --git a/static/app/utils/url/useQueryParamState.spec.tsx b/static/app/utils/url/useQueryParamState.spec.tsx index b4f9c88aa029a3..47ab022d561d98 100644 --- a/static/app/utils/url/useQueryParamState.spec.tsx +++ b/static/app/utils/url/useQueryParamState.spec.tsx @@ -131,7 +131,7 @@ describe('useQueryParamState', () => { const mockedNavigate = jest.fn(); mockedUseNavigate.mockReturnValue(mockedNavigate); - const {result} = renderHook(useQueryParamState, { + const {result} = renderHook(useQueryParamState, { wrapper: UrlParamBatchProvider, initialProps: { fieldName: 'sort',