Skip to content

Commit

Permalink
EDSC-4041: Fixes minor test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
macrouch committed Sep 24, 2024
1 parent 9830779 commit fdd5794
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 63 deletions.
6 changes: 3 additions & 3 deletions cypress/e2e/callbacks.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ describe('Callbacks', () => {

cy.window().then((win) => {
expect(win.console.log.getCall(0).args[0]).to.equal('handleTemporalSet called')
expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1609459200000,"temporalEnd":1610766098533,"temporalStart":1608010249884,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}')
expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1609459200000,"temporalEnd":1610769677838,"temporalStart":1608006278919,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}')
})
})

Expand All @@ -87,7 +87,7 @@ describe('Callbacks', () => {

cy.window().then((win) => {
expect(win.console.log.getCall(0).args[0]).to.equal('handleDragPan called')
expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1608123891892,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}')
expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1608120233514,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}')
})
})

Expand All @@ -111,7 +111,7 @@ describe('Callbacks', () => {

cy.window().then((win) => {
expect(win.console.log.getCall(0).args[0]).to.equal('handleScrollPan called')
expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1610794508108,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}')
expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1610798166486,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}')
})
})

Expand Down
12 changes: 6 additions & 6 deletions cypress/e2e/resizing.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Window resizing', () => {

getByTestId('center').should('have.text', 'Center: Fri, 01 Jan 2021 00:00:00 GMT')
getByTestId('tooltip').should('have.text', '15 Dec 2020 05:30:49 to 16 Jan 2021 03:01:38')
getByTestId('tooltip').should('have.css', 'left', '552.5px')
getByTestId('tooltip').should('have.css', 'left', '552.507px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')

// Change the window from 1400x1100 to 1000x1100
Expand All @@ -22,7 +22,7 @@ describe('Window resizing', () => {

getByTestId('center').should('have.text', 'Center: Fri, 01 Jan 2021 00:00:00 GMT')
getByTestId('tooltip').should('have.text', '15 Dec 2020 05:30:49 to 16 Jan 2021 03:01:38')
getByTestId('tooltip').should('have.css', 'left', '462.905px')
getByTestId('tooltip').should('have.css', 'left', '462.911px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')

// Drag the timeline a little
Expand All @@ -31,9 +31,9 @@ describe('Window resizing', () => {
.trigger('pointermove', 450, 25, { pointerId: 1 })
.trigger('pointerup', { pointerId: 1 })

getByTestId('center').should('have.text', 'Center: Tue, 19 Jan 2021 10:42:34 GMT')
getByTestId('center').should('have.text', 'Center: Tue, 19 Jan 2021 11:55:21 GMT')
getByTestId('tooltip').should('have.text', '15 Dec 2020 05:30:49 to 16 Jan 2021 03:01:38')
getByTestId('tooltip').should('have.css', 'left', '415.905px')
getByTestId('tooltip').should('have.css', 'left', '415.911px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')

// Reset the window size
Expand All @@ -42,9 +42,9 @@ describe('Window resizing', () => {
// Mouse over the temporal range
getByTestId('timelineList').rightclick()

getByTestId('center').should('have.text', 'Center: Tue, 19 Jan 2021 10:42:34 GMT')
getByTestId('center').should('have.text', 'Center: Tue, 19 Jan 2021 11:55:21 GMT')
getByTestId('tooltip').should('have.text', '15 Dec 2020 05:30:49 to 16 Jan 2021 03:01:38')
getByTestId('tooltip').should('have.css', 'left', '496.403px')
getByTestId('tooltip').should('have.css', 'left', '496.41px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})
})
39 changes: 16 additions & 23 deletions cypress/e2e/temporal_dragging.cy.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
import { getByTestId } from '../support/getByTestId'

const timeAtPx = {
550: '2020-11-13T08:00:01.235Z',
650: '2020-12-15T05:30:49.884Z',
750: '2021-01-16T03:01:38.533Z',
850: '2021-02-18T00:12:59.614Z'
}

describe('Temporal dragging', () => {
describe('creating temporal range', () => {
beforeEach(() => {
Expand Down Expand Up @@ -77,8 +70,8 @@ describe('Temporal dragging', () => {
clientY: 10
})

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[650]}`)
getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[750]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-12-15T04:24:38.919Z')
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2021-01-16T04:01:17.838Z')
})

it('when mousing out of a temporal marker does not hover the marker ', () => {
Expand Down Expand Up @@ -121,8 +114,8 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[550]}`)
getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[650]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-11-13T04:48:00.000Z')
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2020-12-15T04:24:38.919Z')
})
})
})
Expand Down Expand Up @@ -155,8 +148,8 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[650]}`)
getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[750]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-12-15T05:30:49.884Z')
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2021-01-16T03:01:38.533Z')
})
})

Expand All @@ -182,8 +175,8 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[550]}`)
getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[750]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-11-13T04:48:00.000Z')
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2021-01-16T03:01:38.533Z')
})

it('dragging the start marker past the end marker changes the temporal range', () => {
Expand All @@ -201,8 +194,8 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[750]}`)
getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[850]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2021-01-16T03:01:38.533Z')
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2021-02-18T03:22:22.703Z')
})

it('dragging the end marker changes the temporal range', () => {
Expand All @@ -220,8 +213,8 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[650]}`)
getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[850]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-12-15T05:30:49.884Z')
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2021-02-18T03:22:22.703Z')
})

it('dragging the end marker past the start marker changes the temporal range', () => {
Expand All @@ -239,8 +232,8 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[550]}`)
getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[650]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-11-13T04:48:00.000Z')
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2020-12-15T05:30:49.884Z')
})
})

Expand All @@ -264,7 +257,7 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalStart').should('have.text', `Temporal Start: ${timeAtPx[550]}`)
getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-11-13T04:48:00.000Z')
})

it('dragging the end marker changes the temporal range', () => {
Expand All @@ -286,7 +279,7 @@ describe('Temporal dragging', () => {
})
.trigger('pointerup', { pointerId: 1 })

getByTestId('temporalEnd').should('have.text', `Temporal End: ${timeAtPx[850]}`)
getByTestId('temporalEnd').should('have.text', 'Temporal End: 2021-02-18T03:22:22.703Z')
})
})
})
14 changes: 7 additions & 7 deletions cypress/e2e/temporal_tooltips.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('Temporal tooltips', () => {
getByTestId('timelineList').rightclick()

getByTestId('tooltip').should('have.text', '15 Dec 2020 05:30:49 to 16 Jan 2021 03:01:38')
getByTestId('tooltip').should('have.css', 'left', '552.5px')
getByTestId('tooltip').should('have.css', 'left', '552.507px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})

Expand All @@ -25,7 +25,7 @@ describe('Temporal tooltips', () => {
getByTestId('startMarker').rightclick()

getByTestId('tooltip').should('have.text', '15 Dec 2020 05:30:49')
getByTestId('tooltip').should('have.css', 'left', '504px')
getByTestId('tooltip').should('have.css', 'left', '504.139px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})

Expand All @@ -34,7 +34,7 @@ describe('Temporal tooltips', () => {
getByTestId('endMarker').rightclick()

getByTestId('tooltip').should('have.text', '16 Jan 2021 03:01:38')
getByTestId('tooltip').should('have.css', 'left', '601px')
getByTestId('tooltip').should('have.css', 'left', '600.874px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})
})
Expand All @@ -50,7 +50,7 @@ describe('Temporal tooltips', () => {
getByTestId('timelineList').rightclick()

getByTestId('tooltip').should('have.text', '15 Dec 2020 13:24:20 ongoing')
getByTestId('tooltip').should('have.css', 'left', '807.5px')
getByTestId('tooltip').should('have.css', 'left', '807.568px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})

Expand All @@ -59,7 +59,7 @@ describe('Temporal tooltips', () => {
getByTestId('startMarker').rightclick()

getByTestId('tooltip').should('have.text', '15 Dec 2020 13:24:20')
getByTestId('tooltip').should('have.css', 'left', '505px')
getByTestId('tooltip').should('have.css', 'left', '505.137px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})
})
Expand All @@ -75,7 +75,7 @@ describe('Temporal tooltips', () => {
getByTestId('timelineList').rightclick()

getByTestId('tooltip').should('have.text', 'Up to 16 Jan 2021 10:55:09')
getByTestId('tooltip').should('have.css', 'left', '301px')
getByTestId('tooltip').should('have.css', 'left', '300.936px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})

Expand All @@ -84,7 +84,7 @@ describe('Temporal tooltips', () => {
getByTestId('endMarker').rightclick()

getByTestId('tooltip').should('have.text', '16 Jan 2021 10:55:09')
getByTestId('tooltip').should('have.css', 'left', '602px')
getByTestId('tooltip').should('have.css', 'left', '601.872px')
getByTestId('tooltip').should('have.css', 'bottom', '2px')
})
})
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/timeline_dragging.cy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getByTestId } from '../support/getByTestId'

const startCenter = 'Center: Fri, 01 Jan 2021 00:00:00 GMT'
const backwardCenter = 'Center: Wed, 16 Dec 2020 13:04:51 GMT'
const forwardCenter = 'Center: Sat, 16 Jan 2021 10:55:08 GMT'
const backwardCenter = 'Center: Wed, 16 Dec 2020 12:03:53 GMT'
const forwardCenter = 'Center: Sat, 16 Jan 2021 11:56:06 GMT'
const timelineRangeStart = 'Timeline Start: 2018-07-01T00:00:00.000Z'
const timelineRangeEnd = 'Timeline End: 2023-07-01T00:00:00.000Z'

Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/timeline_zooming.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { getByTestId } from '../support/getByTestId'

const startCenter = 'Center: Fri, 01 Jan 2021 00:00:00 GMT'
const zoom1Center = 'Center: Tue, 23 Mar 2021 15:41:51 GMT'
const zoom2Center = 'Center: Wed, 17 Mar 2021 03:34:04 GMT'
const zoom1Center = 'Center: Tue, 23 Mar 2021 21:04:51 GMT'
const zoom2Center = 'Center: Wed, 17 Mar 2021 08:57:04 GMT'
const zoom3Center = 'Center: Fri, 01 Jan 2021 00:00:00 GMT'
const zoom4Center = 'Center: Tue, 25 Dec 2018 10:07:13 GMT'
const zoom5Center = 'Center: Mon, 04 Jan 2010 01:02:53 GMT'
const zoom4Center = 'Center: Tue, 25 Dec 2018 15:30:24 GMT'
const zoom5Center = 'Center: Mon, 04 Jan 2010 06:27:34 GMT'

const scrollWheel = (direction) => {
getByTestId('timelineList')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,10 @@ describe('TimelineDataSection component', () => {
const secondDataChild = intervals[1]

expect(intervals.length).toEqual(2)
expect(firstDataChild.style.left).toEqual('68.4931506849315px')
expect(firstDataChild.style.width).toEqual('12.32876712328767px')
expect(secondDataChild.style.left).toEqual('82.1917808219178px')
expect(secondDataChild.style.width).toEqual('10.95890410958904px')
expect(firstDataChild.style.left).toEqual('68.30601092896175px')
expect(firstDataChild.style.width).toEqual('12.295081967213115px')
expect(secondDataChild.style.left).toEqual('81.96721311475409px')
expect(secondDataChild.style.width).toEqual('10.92896174863388px')
})

test('sets a default color', () => {
Expand Down
24 changes: 12 additions & 12 deletions src/components/TimelineList/__tests__/TimelineList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ describe('TimelineList component', () => {
const endMarker = screen.getByLabelText('Temporal range end')

expect(startMarker).toBeInTheDocument()
expect(startMarker.style.left).toEqual('200.43835616438355px')
expect(startMarker.style.left).toEqual('199.89071038251365px')
expect(endMarker).toBeInTheDocument()
expect(endMarker.style.left).toEqual('305.75342465753425px')
expect(endMarker.style.left).toEqual('304.91803278688525px')
})

test('renders highlighted area correctly if temporal range has start and end', () => {
Expand All @@ -179,8 +179,8 @@ describe('TimelineList component', () => {
const temporalRange = container.getElementsByClassName('edsc-timeline-list__temporal-range')[0]

expect(temporalRange).toBeInTheDocument()
expect(temporalRange.style.left).toEqual('200.43835616438355px')
expect(temporalRange.style.width).toEqual('105.31506849315068px')
expect(temporalRange.style.left).toEqual('199.89071038251365px')
expect(temporalRange.style.width).toEqual('105.02732240437159px')
})

test('renders only a start marker if temporal range does not have an end', () => {
Expand All @@ -207,8 +207,8 @@ describe('TimelineList component', () => {
const temporalRange = container.getElementsByClassName('edsc-timeline-list__temporal-range')[0]

expect(temporalRange).toBeInTheDocument()
expect(temporalRange.style.left).toEqual('200.43835616438355px')
expect(temporalRange.style.width).toEqual('312.54794520547944px')
expect(temporalRange.style.left).toEqual('199.89071038251365px')
expect(temporalRange.style.width).toEqual('311.69398907103823px')
})

test('renders only a end marker if temporal range does not have a start', () => {
Expand Down Expand Up @@ -236,7 +236,7 @@ describe('TimelineList component', () => {

expect(temporalRange).toBeInTheDocument()
expect(temporalRange.style.left).toEqual('0px')
expect(temporalRange.style.width).toEqual('200.43835616438355px')
expect(temporalRange.style.width).toEqual('199.89071038251365px')
})

describe('when the temporal markers are not dragging', () => {
Expand Down Expand Up @@ -422,16 +422,16 @@ describe('TimelineList component', () => {
const focusedRangeMaskRight = container.getElementsByClassName('edsc-timeline-list__focused-range-mask')[1]

expect(focusedRange).toBeInTheDocument()
expect(focusedRange.style.left).toEqual('200.43835616438355px')
expect(focusedRange.style.width).toEqual('103.91780821917807px')
expect(focusedRange.style.left).toEqual('199.89071038251365px')
expect(focusedRange.style.width).toEqual('103.63934426229508px')

expect(focusedRangeMaskLeft).toBeInTheDocument()
expect(focusedRangeMaskLeft.style.left).toEqual('0px')
expect(focusedRangeMaskLeft.style.width).toEqual('200.43835616438355px')
expect(focusedRangeMaskLeft.style.width).toEqual('199.89071038251365px')

expect(focusedRangeMaskRight).toBeInTheDocument()
expect(focusedRangeMaskRight.style.left).toEqual('304.35616438356163px')
expect(focusedRangeMaskRight.style.width).toEqual('210.63013698630135px')
expect(focusedRangeMaskRight.style.left).toEqual('303.53005464480873px')
expect(focusedRangeMaskRight.style.width).toEqual('210.05464480874318px')
})

describe('Data', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/__tests__/determineScaledWidth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ describe('determineScaledWidth', () => {

const width = determineScaledWidth(intervalDurationInMs, zoomLevel, wrapperWidth)

expect(width).toEqual(105.31506849315068)
expect(width).toEqual(105.02732240437159)
})
})
2 changes: 1 addition & 1 deletion src/utils/__tests__/getPositionByTimestamp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ describe('getPositionByTimestamp', () => {
timeIntervals,
zoomLevel,
wrapperWidth
})).toEqual(66.03458630136986)
})).toEqual(65.85416393442624)
})
})

0 comments on commit fdd5794

Please sign in to comment.