Code Insights: another attempt to fix flaky screenshot tests (#24383)

* Do not render tooltip in Percy run

* Add log is percy var

* Fix node version

* Fix log statement

* Fix log statement

* Fix log statement

* log process env only

* Fix is_percy env read

* Use read env helper to read percy on env variable

* Add percy inactive element (remove old fix)
This commit is contained in:
Vova Kulikov 2021-08-28 02:18:42 +03:00 committed by GitHub
parent e032b759d8
commit 247dfe5f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 24 additions and 13 deletions

View File

@ -7,3 +7,6 @@ snapshot:
.monaco-editor .cursor {
visibility: hidden !important;
}
.percy-inactive-element {
pointer-events: none !important;
}

View File

@ -23,24 +23,33 @@ interface GlyphContentProps<Datum extends object> extends Omit<GlyphProps<Datum>
* Just because GlyphProps has a bug with types.
* GlyphProps key is an index of current datum and
* GlyphProps index doesn't exist in runtime.
* */
*/
index: string
/** Hovered point info (datum) to calculate proper styles for particular Glyph */
hoveredDatum: ActiveDatum<Datum> | null
/** Focused point info (datum) to calculate proper styles for particular Glyph */
focusedDatum: ActiveDatum<Datum> | null
/** Focus handler for glyph (chart point) */
setFocusedDatum: (datum: ActiveDatum<Datum> | null) => void
/** Map with getters to have a proper value of by x and y axis value for current point */
accessors: Accessors<Datum, keyof Datum>
/** Line (series) index of current point */
lineIndex: number
/** Total number of lines (series) to calculate proper aria-label for glyph content */
totalNumberOfLines: number
/** Data of particular line of current glyph (chart point) */
line: LineChartContentProps<Datum>['series'][number]
/** Focus handler for glyph (chart point) */
setFocusedDatum: (datum: ActiveDatum<Datum> | null) => void
/** On click handler for root component of glyph content */
onClick: MouseEventHandler
/** On pointer up handler for root component of glyph content */
onPointerUp: PointerEventHandler
}
@ -56,11 +65,11 @@ export function GlyphContent<Datum extends object>(props: GlyphContentProps<Datu
accessors,
lineIndex,
totalNumberOfLines,
x: xCoordinate,
y: yCoordinate,
onPointerUp,
onClick,
setFocusedDatum,
x: xCoordinate,
y: yCoordinate,
} = props
const currentDatumIndex = +index

View File

@ -23,13 +23,6 @@ import { NonActiveBackground } from './NonActiveBackground'
import { dateTickFormatter, numberFormatter, Tick, getTickXProps, getTickYProps } from './TickComponent'
import { TooltipContent } from './TooltipContent'
/**
* Check percy test run to be able disable flaky line chart tooltip appearance
* by disabling any point events over line chart container.
* See https://github.com/sourcegraph/sourcegraph/issues/23669
*/
const IS_PERCY_RUN = process.env.PERCY_ON === 'true'
// Chart configuration
const WIDTH_PER_TICK = 70
const HEIGHT_PER_TICK = 40
@ -176,6 +169,7 @@ export function LineChartContent<Datum extends object>(props: LineChartContentPr
const { onPointerMove = noop, onPointerOut = noop, ...otherHandlers } = usePointerEventEmitters({
source: XYCHART_EVENT_SOURCE,
onFocus: true,
onBlur: true,
})
// We only need to catch pointerout event on root element - chart
@ -218,6 +212,7 @@ export function LineChartContent<Datum extends object>(props: LineChartContentPr
[focused, onPointerOut, setHoveredDatum]
)
// Disable all event listeners explicitly to avoid flaky tooltip appearance
const eventEmitters = {
onPointerMove: handleRootPointerMove,
onPointerOut: handleRootPointerOut,
@ -297,7 +292,11 @@ export function LineChartContent<Datum extends object>(props: LineChartContentPr
// eslint-disable-next-line jsx-a11y/aria-role
role="graphics-datagroup"
aria-label="Chart series"
pointerEvents={IS_PERCY_RUN ? 'none' : 'bounding-box'}
pointerEvents="bounding-box"
// Check percy test run to be able disable flaky line chart tooltip appearance
// by disabling any point events over line chart container.
// See https://github.com/sourcegraph/sourcegraph/issues/23669
className="percy-inactive-element"
{...eventEmitters}
>
{/* Spread size of parent group element by transparent rect with width and height */}