diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..1cb9db4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,37 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +Before contributing to this project, please review [Contribution.md](https://github.com/nasa/earthdata-search/blob/master/CONTRIBUTING.md). + +### Description +A clear and concise description of what the bug is. + +**Reproduction Steps** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**System Information (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +### Additional context +Add any other context about the problem here. + +### Acceptance Criteria +Steps to produce expected behavior. diff --git a/.github/ISSUE_TEMPLATE/custom.md b/.github/ISSUE_TEMPLATE/custom.md new file mode 100644 index 0000000..cc9b875 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/custom.md @@ -0,0 +1,18 @@ +--- +name: Custom issue template +about: Template for general tasks and improvements +title: '' +labels: '' +assignees: '' + +--- + +Please review [Contribution.md](https://github.com/nasa/earthdata-search/blob/master/CONTRIBUTING.md) before contributing to this project. + +### Description +Describe the purpose of the issue + +### Files +Attach any relevant images or files + +### Acceptance Criteria diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..a771a6a --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,33 @@ +# Overview + +### What is the feature? + +Please summarize the feature or fix. + +### What is the Solution? + +Summarize what you changed. + +### What areas of the application does this impact? + +List impacted areas. + +# Testing + +### Reproduction steps + +1. Step 1 +2. Step 2... + +### Attachments + +Please include relevant screenshots or files that would be helpful in reviewing and verifying this change. + +# Checklist + +- [ ] I have added automated tests that prove my fix is effective or that my feature works +- [ ] New and existing unit tests pass locally with my changes +- [ ] I have performed a self-review of my own code +- [ ] I have commented my code, particularly in hard-to-understand areas +- [ ] I have made corresponding changes to the documentation +- [ ] My changes generate no new warnings diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18d3a9c..497154d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: ['lts/hydrogen'] + node-version: ['lts/jod'] steps: - name: Checkout code uses: actions/checkout@v4 @@ -40,7 +40,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: ['lts/hydrogen'] + node-version: ['lts/iron', 'lts/jod'] steps: - name: Checkout code uses: actions/checkout@v4 @@ -74,7 +74,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: ['lts/hydrogen'] + node-version: ['lts/jod'] steps: - name: Checkout code uses: actions/checkout@v4 @@ -105,9 +105,15 @@ jobs: directory: 'cypress-coverage' env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + tests-passed: + needs: [jest, cypress] + runs-on: ubuntu-latest + steps: + - name: All Tests Have Passed + run: 'echo true' deploy: if: success() && github.ref == 'refs/heads/main' # only run on main success - needs: [jest, cypress] # only run after jest and cypress jobs complete + needs: [tests-passed] # only run after all test jobs complete runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.nvmrc b/.nvmrc index a77793e..0559089 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -lts/hydrogen +lts/jod \ No newline at end of file diff --git a/babel.config.js b/babel.config.js index 2096c74..43c1144 100644 --- a/babel.config.js +++ b/babel.config.js @@ -3,9 +3,8 @@ module.exports = { [ '@babel/preset-env', { targets: { - node: '12', - esmodules: true, - ie: '10' + node: '22', + esmodules: true } } ], diff --git a/cypress/e2e/callbacks.cy.js b/cypress/e2e/callbacks.cy.js index eeb4e27..3bae879 100644 --- a/cypress/e2e/callbacks.cy.js +++ b/cypress/e2e/callbacks.cy.js @@ -17,13 +17,20 @@ describe('Callbacks', () => { getByTestId('timelineInterval-31').trigger('click') // Click the focus next button - getByTestId('timelineList') - .trigger('keydown', { key: 'ArrowLeft' }) + getByTestId('timelineList').trigger('keydown', { key: 'ArrowLeft' }) cy.window().then((win) => { - expect(win.console.log.getCall(0).args[0]).to.equal('handleFocusedIntervalClick called') - expect(win.console.log.getCall(1).args[0]).to.equal('handleArrowKeyPan called') - expect(win.console.log.getCall(1).args[1]).to.equal('{"center":1609459200000,"focusedEnd":1612137599999,"focusedStart":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}') + expect(win.console.log.getCall(0).args[0]).to.equal( + 'handleFocusedIntervalClick called' + ) + + expect(win.console.log.getCall(1).args[0]).to.equal( + 'handleArrowKeyPan called' + ) + + expect(win.console.log.getCall(1).args[1]).to.equal( + '{"center":1609459200000,"focusedEnd":1612137599999,"focusedStart":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}' + ) }) }) @@ -35,9 +42,17 @@ describe('Callbacks', () => { getByTestId('focusNext').trigger('click') cy.window().then((win) => { - expect(win.console.log.getCall(0).args[0]).to.equal('handleFocusedIntervalClick called') - expect(win.console.log.getCall(1).args[0]).to.equal('handleButtonPan called') - expect(win.console.log.getCall(1).args[1]).to.equal('{"center":1609459200000,"focusedEnd":1612137599999,"focusedStart":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}') + expect(win.console.log.getCall(0).args[0]).to.equal( + 'handleFocusedIntervalClick called' + ) + + expect(win.console.log.getCall(1).args[0]).to.equal( + 'handleButtonPan called' + ) + + expect(win.console.log.getCall(1).args[1]).to.equal( + '{"center":1609459200000,"focusedEnd":1612137599999,"focusedStart":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}' + ) }) }) @@ -46,8 +61,13 @@ describe('Callbacks', () => { getByTestId('zoomUp').trigger('click') cy.window().then((win) => { - expect(win.console.log.getCall(0).args[0]).to.equal('handleButtonZoom called') - expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":4}') + expect(win.console.log.getCall(0).args[0]).to.equal( + 'handleButtonZoom called' + ) + + expect(win.console.log.getCall(0).args[1]).to.equal( + '{"center":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":4}' + ) }) }) @@ -67,8 +87,13 @@ describe('Callbacks', () => { .trigger('pointerup', { pointerId: 1 }) 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":1610769677838,"temporalStart":1608006278919,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}') + 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":1610498221714,"temporalStart":1608307241143,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}' + ) }) }) @@ -86,8 +111,13 @@ describe('Callbacks', () => { .trigger('pointerup', { pointerId: 1 }) 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":1608120233514,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}') + expect(win.console.log.getCall(0).args[0]).to.equal( + 'handleDragPan called' + ) + + expect(win.console.log.getCall(0).args[1]).to.equal( + '{"center":1608397590857,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}' + ) }) }) @@ -96,33 +126,46 @@ describe('Callbacks', () => { getByTestId('timelineInterval-31').trigger('click') cy.window().then((win) => { - expect(win.console.log.getCall(0).args[0]).to.equal('handleFocusedIntervalClick called') - expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1609459200000,"focusedEnd":1612137599999,"focusedStart":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}') + expect(win.console.log.getCall(0).args[0]).to.equal( + 'handleFocusedIntervalClick called' + ) + + expect(win.console.log.getCall(0).args[1]).to.equal( + '{"center":1609459200000,"focusedEnd":1612137599999,"focusedStart":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}' + ) }) }) it('calls onScrollPan', () => { // Scroll the timeline - getByTestId('timelineList') - .trigger('wheel', { deltaX: 47 }) + getByTestId('timelineList').trigger('wheel', { deltaX: 47 }) // Wait for the wheel event to end cy.wait(300) 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":1610798166486,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}') + expect(win.console.log.getCall(0).args[0]).to.equal( + 'handleScrollPan called' + ) + + expect(win.console.log.getCall(0).args[1]).to.equal( + '{"center":1610520809143,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":3}' + ) }) }) it('calls onScrollZoom', () => { // Scroll the timeline - getByTestId('timelineList') - .trigger('wheel', { deltaY: 1 }) + getByTestId('timelineList').trigger('wheel', { deltaY: 1 }) cy.window().then((win) => { - expect(win.console.log.getCall(0).args[0]).to.equal('handleScrollZoom called') - expect(win.console.log.getCall(0).args[1]).to.equal('{"center":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":2}') + expect(win.console.log.getCall(0).args[0]).to.equal( + 'handleScrollZoom called' + ) + + expect(win.console.log.getCall(0).args[1]).to.equal( + '{"center":1609459200000,"timelineEnd":1688169600000,"timelineStart":1530403200000,"zoom":2}' + ) }) }) }) diff --git a/cypress/e2e/focused_intervals.cy.js b/cypress/e2e/focused_intervals.cy.js index 963ee48..27cb699 100644 --- a/cypress/e2e/focused_intervals.cy.js +++ b/cypress/e2e/focused_intervals.cy.js @@ -2,7 +2,7 @@ import { getByTestId } from '../support/getByTestId' -describe('Focused intervals', () => { +describe('intervals', () => { describe('when no temporal range exists', () => { beforeEach(() => { cy.visit('/empty') @@ -13,16 +13,16 @@ describe('Focused intervals', () => { // Click on a timeline interval bottom getByTestId('timelineInterval-31').trigger('click') - getByTestId('focusedStart').should('have.text', 'Focused Start: 2021-01-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2021-01-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2021-01-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2021-01-31T23:59:59.999Z') }) it('clicking an interval in the middle does not select it as the focused interval', () => { // Click in the middle of the timeline list getByTestId('timelineList').trigger('click') - getByTestId('focusedStart').should('have.text', 'Focused Start: null') - getByTestId('focusedEnd').should('have.text', 'Focused End: null') + getByTestId('focusedStart').should('have.text', 'Start: null') + getByTestId('focusedEnd').should('have.text', 'End: null') }) it('clicking a focused interval removes focus', () => { @@ -45,24 +45,24 @@ describe('Focused intervals', () => { // force: true - force the click to happen through the temporal range getByTestId('timelineInterval-31').trigger('click', { force: true }) - getByTestId('focusedStart').should('have.text', 'Focused Start: 2021-01-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2021-01-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2021-01-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2021-01-31T23:59:59.999Z') }) it('clicking an interval outside the temporal range does not select it as the focused interval', () => { // Click on a timeline interval bottom that is outside the temporal range getByTestId('timelineInterval-30').trigger('click') - getByTestId('focusedStart').should('have.text', 'Focused Start: null') - getByTestId('focusedEnd').should('have.text', 'Focused End: null') + getByTestId('focusedStart').should('have.text', 'Start: null') + getByTestId('focusedEnd').should('have.text', 'End: null') }) it('clicking an interval in the middle does not select it as the focused interval', () => { // Click in the middle of the timeline list getByTestId('timelineList').trigger('click') - getByTestId('focusedStart').should('have.text', 'Focused Start: null') - getByTestId('focusedEnd').should('have.text', 'Focused End: null') + getByTestId('focusedStart').should('have.text', 'Start: null') + getByTestId('focusedEnd').should('have.text', 'End: null') }) it('selects the correct interval when pressing the left arrow button', () => { @@ -70,13 +70,13 @@ describe('Focused intervals', () => { // force: true - force the click to happen through the temporal range getByTestId('timelineInterval-31').trigger('click', { force: true }) - getByTestId('focusedStart').should('have.text', 'Focused Start: 2021-01-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2021-01-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2021-01-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2021-01-31T23:59:59.999Z') getByTestId('timeline').type('{leftArrow}') - getByTestId('focusedStart').should('have.text', 'Focused Start: 2020-12-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2020-12-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2020-12-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2020-12-31T23:59:59.999Z') }) it('selects the correct interval when pressing the right arrow button', () => { @@ -84,13 +84,13 @@ describe('Focused intervals', () => { // force: true - force the click to happen through the temporal range getByTestId('timelineInterval-32').trigger('click', { force: true }) - getByTestId('focusedStart').should('have.text', 'Focused Start: 2020-12-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2020-12-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2020-12-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2020-12-31T23:59:59.999Z') getByTestId('timeline').type('{rightArrow}') - getByTestId('focusedStart').should('have.text', 'Focused Start: 2021-01-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2021-01-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2021-01-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2021-01-31T23:59:59.999Z') }) it('selects the correct interval when pressing the focus previous button', () => { @@ -98,13 +98,13 @@ describe('Focused intervals', () => { // force: true - force the click to happen through the temporal range getByTestId('timelineInterval-31').trigger('click', { force: true }) - getByTestId('focusedStart').should('have.text', 'Focused Start: 2021-01-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2021-01-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2021-01-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2021-01-31T23:59:59.999Z') getByTestId('focusPrevious').click() - getByTestId('focusedStart').should('have.text', 'Focused Start: 2020-12-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2020-12-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2020-12-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2020-12-31T23:59:59.999Z') }) it('selects the correct interval when pressing the focus next button', () => { @@ -112,13 +112,13 @@ describe('Focused intervals', () => { // force: true - force the click to happen through the temporal range getByTestId('timelineInterval-32').trigger('click', { force: true }) - getByTestId('focusedStart').should('have.text', 'Focused Start: 2020-12-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2020-12-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2020-12-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2020-12-31T23:59:59.999Z') getByTestId('focusNext').click() - getByTestId('focusedStart').should('have.text', 'Focused Start: 2021-01-01T00:00:00.000Z') - getByTestId('focusedEnd').should('have.text', 'Focused End: 2021-01-31T23:59:59.999Z') + getByTestId('focusedStart').should('have.text', 'Start: 2021-01-01T00:00:00.000Z') + getByTestId('focusedEnd').should('have.text', 'End: 2021-01-31T23:59:59.999Z') }) }) diff --git a/cypress/e2e/resizing.cy.js b/cypress/e2e/resizing.cy.js index e17ad5d..90e8f65 100644 --- a/cypress/e2e/resizing.cy.js +++ b/cypress/e2e/resizing.cy.js @@ -9,9 +9,9 @@ describe('Window resizing', () => { // Mouse over the temporal range getByTestId('timelineList').rightclick() - getByTestId('center').should('have.text', 'Center: Fri, 01 Jan 2021 00:00:00 GMT') + 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.507px') + getByTestId('tooltip').should('have.css', 'left', '696.856px') getByTestId('tooltip').should('have.css', 'bottom', '2px') // Change the window from 1400x1100 to 1000x1100 @@ -20,9 +20,9 @@ describe('Window resizing', () => { // Mouse over the temporal range getByTestId('timelineList').rightclick() - getByTestId('center').should('have.text', 'Center: Fri, 01 Jan 2021 00:00:00 GMT') + 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.911px') + getByTestId('tooltip').should('have.css', 'left', '497.754px') getByTestId('tooltip').should('have.css', 'bottom', '2px') // Drag the timeline a little @@ -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 11:55:21 GMT') + getByTestId('center').should('have.text', 'Center:Mon, 18 Jan 2021 04:50:52 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.911px') + getByTestId('tooltip').should('have.css', 'left', '450.754px') getByTestId('tooltip').should('have.css', 'bottom', '2px') // Reset the window size @@ -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 11:55:21 GMT') + getByTestId('center').should('have.text', 'Center:Mon, 18 Jan 2021 04:50:52 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.41px') + getByTestId('tooltip').should('have.css', 'left', '631.056px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) }) diff --git a/cypress/e2e/temporal_dragging.cy.js b/cypress/e2e/temporal_dragging.cy.js index 72b13f3..572bf1c 100644 --- a/cypress/e2e/temporal_dragging.cy.js +++ b/cypress/e2e/temporal_dragging.cy.js @@ -1,6 +1,6 @@ import { getByTestId } from '../support/getByTestId' -describe('Temporal dragging', () => { +describe('dragging', () => { describe('creating temporal range', () => { beforeEach(() => { cy.visit('/empty') @@ -70,8 +70,8 @@ describe('Temporal dragging', () => { clientY: 10 }) - 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') + getByTestId('temporalStart').should('have.text', 'Start: 2020-12-18T16:00:41.143Z') + getByTestId('temporalEnd').should('have.text', 'End: 2021-01-13T00:37:01.714Z') }) it('when mousing out of a temporal marker does not hover the marker ', () => { @@ -114,8 +114,8 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - 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') + getByTestId('temporalStart').should('have.text', 'Start: 2020-11-23T07:24:20.571Z') + getByTestId('temporalEnd').should('have.text', 'End: 2020-12-18T16:00:41.143Z') }) }) }) @@ -136,8 +136,8 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - getByTestId('temporalStart').should('have.text', 'Temporal Start: null') - getByTestId('temporalEnd').should('have.text', 'Temporal End: null') + getByTestId('temporalStart').should('have.text', 'Start: null') + getByTestId('temporalEnd').should('have.text', 'End: null') }) it('clicking on the middle of the timeline does not removes the temporal range', () => { @@ -148,8 +148,8 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - 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') + getByTestId('temporalStart').should('have.text', 'Start: 2020-12-15T05:30:49.884Z') + getByTestId('temporalEnd').should('have.text', 'End: 2021-01-16T03:01:38.533Z') }) }) @@ -175,8 +175,8 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - 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') + getByTestId('temporalStart').should('have.text', 'Start: 2020-11-23T07:24:20.571Z') + getByTestId('temporalEnd').should('have.text', 'End: 2021-01-16T03:01:38.533Z') }) it('dragging the start marker past the end marker changes the temporal range', () => { @@ -194,8 +194,8 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - 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') + getByTestId('temporalStart').should('have.text', 'Start: 2021-01-16T03:01:38.533Z') + getByTestId('temporalEnd').should('have.text', 'End: 2021-02-08T04:02:44.571Z') }) it('dragging the end marker changes the temporal range', () => { @@ -213,8 +213,8 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - 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') + getByTestId('temporalStart').should('have.text', 'Start: 2020-12-15T05:30:49.884Z') + getByTestId('temporalEnd').should('have.text', 'End: 2021-02-08T04:02:44.571Z') }) it('dragging the end marker past the start marker changes the temporal range', () => { @@ -232,8 +232,8 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - 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') + getByTestId('temporalStart').should('have.text', 'Start: 2020-11-23T07:24:20.571Z') + getByTestId('temporalEnd').should('have.text', 'End: 2020-12-15T05:30:49.884Z') }) }) @@ -257,7 +257,7 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - getByTestId('temporalStart').should('have.text', 'Temporal Start: 2020-11-13T04:48:00.000Z') + getByTestId('temporalStart').should('have.text', 'Start: 2020-11-23T07:24:20.571Z') }) it('dragging the end marker changes the temporal range', () => { @@ -279,7 +279,7 @@ describe('Temporal dragging', () => { }) .trigger('pointerup', { pointerId: 1 }) - getByTestId('temporalEnd').should('have.text', 'Temporal End: 2021-02-18T03:22:22.703Z') + getByTestId('temporalEnd').should('have.text', 'End: 2021-02-08T04:02:44.571Z') }) }) }) diff --git a/cypress/e2e/temporal_tooltips.cy.js b/cypress/e2e/temporal_tooltips.cy.js index c595305..ee66143 100644 --- a/cypress/e2e/temporal_tooltips.cy.js +++ b/cypress/e2e/temporal_tooltips.cy.js @@ -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.507px') + getByTestId('tooltip').should('have.css', 'left', '696.856px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) @@ -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', '504.139px') + getByTestId('tooltip').should('have.css', 'left', '635.852px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) @@ -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', '600.874px') + getByTestId('tooltip').should('have.css', 'left', '757.86px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) }) @@ -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.568px') + getByTestId('tooltip').should('have.css', 'left', '1018.55px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) @@ -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', '505.137px') + getByTestId('tooltip').should('have.css', 'left', '637.109px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) }) @@ -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', '300.936px') + getByTestId('tooltip').should('have.css', 'left', '379.559px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) @@ -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', '601.872px') + getByTestId('tooltip').should('have.css', 'left', '759.117px') getByTestId('tooltip').should('have.css', 'bottom', '2px') }) }) diff --git a/cypress/e2e/timeline_dragging.cy.js b/cypress/e2e/timeline_dragging.cy.js index 2b3114d..e966d02 100644 --- a/cypress/e2e/timeline_dragging.cy.js +++ b/cypress/e2e/timeline_dragging.cy.js @@ -1,10 +1,10 @@ import { getByTestId } from '../support/getByTestId' -const startCenter = 'Center: Fri, 01 Jan 2021 00:00:00 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' +const startCenter = 'Center:Fri, 01 Jan 2021 00:00:00 GMT' +const backwardCenter = 'Center:Sat, 19 Dec 2020 17:06:30 GMT' +const forwardCenter = 'Center:Wed, 13 Jan 2021 06:53:29 GMT' +const timelineRangeStart = 'Start:2018-07-01T00:00:00.000Z' +const timelineRangeEnd = 'End:2023-07-01T00:00:00.000Z' describe('Timeline dragging', () => { beforeEach(() => { @@ -24,7 +24,9 @@ describe('Timeline dragging', () => { pointerId: 1, clientX: 550 }) - .trigger('pointerup', { pointerId: 1 }) + .trigger('pointerup', { + pointerId: 1 + }) getByTestId('center').should('have.text', backwardCenter) getByTestId('timelineStart').should('have.text', timelineRangeStart) @@ -39,18 +41,20 @@ describe('Timeline dragging', () => { .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: 1900, - clientY: 200 + clientX: 2400, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timelineInterval').should('have.length', 91) getByTestId('timelineInterval').eq(0).should('have.text', '2016Jan') - getByTestId('timelineStart').should('have.text', 'Timeline Start: 2016-01-01T00:00:00.000Z') + getByTestId('timelineStart').should('have.text', 'Start:2016-01-01T00:00:00.000Z') }) }) @@ -62,53 +66,61 @@ describe('Timeline dragging', () => { .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: 1900, - clientY: 200 + clientX: 2400, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timeline') .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: 2800, - clientY: 200 + clientX: 3800, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timeline') .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: 2800, - clientY: 200 + clientX: 3800, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timeline') .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: 2800, - clientY: 200 + clientX: 3800, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timelineInterval').should('have.length', 151) }) @@ -128,7 +140,9 @@ describe('Timeline dragging', () => { pointerId: 1, clientX: 450 }) - .trigger('pointerup', { pointerId: 1 }) + .trigger('pointerup', { + pointerId: 1 + }) getByTestId('center').should('have.text', forwardCenter) getByTestId('timelineStart').should('have.text', timelineRangeStart) @@ -143,18 +157,20 @@ describe('Timeline dragging', () => { .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: -2000, - clientY: 200 + clientX: -2500, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timelineInterval').should('have.length', 91) getByTestId('timelineInterval').eq(-1).should('have.text', '2026Jan') - getByTestId('timelineEnd').should('have.text', 'Timeline End: 2026-01-01T00:00:00.000Z') + getByTestId('timelineEnd').should('have.text', 'End:2026-01-01T00:00:00.000Z') }) }) @@ -166,53 +182,61 @@ describe('Timeline dragging', () => { .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: -1900, - clientY: 200 + clientX: -2400, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timeline') .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: -2800, - clientY: 200 + clientX: -3800, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timeline') .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: -2800, - clientY: 200 + clientX: -3800, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timeline') .trigger('pointerdown', { pointerId: 1, clientX: 0, - clientY: 200 + clientY: 350 }) .trigger('pointermove', { pointerId: 1, - clientX: -2800, - clientY: 200 + clientX: -3800, + clientY: 350 + }) + .trigger('pointerup', { + pointerId: 1 }) - .trigger('pointerup', { pointerId: 1 }) getByTestId('timelineInterval').should('have.length', 151) }) diff --git a/cypress/e2e/timeline_zooming.cy.js b/cypress/e2e/timeline_zooming.cy.js index 2e9eb16..be1322e 100644 --- a/cypress/e2e/timeline_zooming.cy.js +++ b/cypress/e2e/timeline_zooming.cy.js @@ -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 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 15:30:24 GMT' -const zoom5Center = 'Center: Mon, 04 Jan 2010 06:27:34 GMT' +const startCenter = 'Center:Fri, 01 Jan 2021 00:00:00 GMT' +const zoom1Center = 'Center:Sat, 06 Mar 2021 22:01:42 GMT' +const zoom2Center = 'Center:Mon, 01 Mar 2021 13:58:17 GMT' +const zoom3Center = 'Center:Thu, 31 Dec 2020 23:59:59 GMT' +const zoom4Center = 'Center:Mon, 27 May 2019 09:12:14 GMT' +const zoom5Center = 'Center:Sat, 14 Apr 2012 21:22:21 GMT' const scrollWheel = (direction) => { getByTestId('timelineList') @@ -64,35 +64,35 @@ describe('Timeline zooming', () => { describe('when zooming with the mouse wheel', () => { it('does not scroll past min zoomLevel', () => { - getByTestId('zoom').should('have.text', 'Zoom: Month (3)') + getByTestId('zoom').should('have.text', 'Zoom:Month (3)') // Scroll down to zoom 2 scrollWheel(1) - getByTestId('zoom').should('have.text', 'Zoom: Day (2)') + getByTestId('zoom').should('have.text', 'Zoom:Day (2)') // Scroll down to zoom 1 scrollWheel(1) - getByTestId('zoom').should('have.text', 'Zoom: Hour (1)') + getByTestId('zoom').should('have.text', 'Zoom:Hour (1)') // Scroll down again scrollWheel(1) - getByTestId('zoom').should('have.text', 'Zoom: Hour (1)') + getByTestId('zoom').should('have.text', 'Zoom:Hour (1)') }) it('does not scroll past max zoomLevel', () => { - getByTestId('zoom').should('have.text', 'Zoom: Month (3)') + getByTestId('zoom').should('have.text', 'Zoom:Month (3)') // Scroll up to zoom 4 scrollWheel(-1) - getByTestId('zoom').should('have.text', 'Zoom: Year (4)') + getByTestId('zoom').should('have.text', 'Zoom:Year (4)') // Scroll up to zoom 5 scrollWheel(-1) - getByTestId('zoom').should('have.text', 'Zoom: Year (5)') + getByTestId('zoom').should('have.text', 'Zoom:Year (5)') // Scroll up again scrollWheel(-1) - getByTestId('zoom').should('have.text', 'Zoom: Year (5)') + getByTestId('zoom').should('have.text', 'Zoom:Year (5)') }) it('keeps the mouse position centered in the timeline', () => { diff --git a/example/src/components/ExampleWrapper/ExampleWrapper.js b/example/src/components/ExampleWrapper/ExampleWrapper.js new file mode 100644 index 0000000..9f16f6b --- /dev/null +++ b/example/src/components/ExampleWrapper/ExampleWrapper.js @@ -0,0 +1,88 @@ +import PropTypes from 'prop-types' +import React from 'react' +import { + Col, + Container, + Row, + Tab, + Tabs +} from 'react-bootstrap' + +const ExampleWrapper = ({ + code, + children, + description, + output, + pageHeading, + timeline +}) => ( +
{description}
+
+ {code}
+
+
+ + When callback functions are defined, the timeline provides them values + that represent its current position, zoom, and ranges. See the + {' '} + README.md + {' '} + in the + {' '} + @edsc/timeline + {' '} + repository for more information + about the callback functions. +
+ {output} + +- This example shows a timeline where all the callbacks are used. - Check the console log for the callback output. -
-
-
- {`
-
- `}
-
-
- - This example shows a timeline with only an empty row included. -
-
-
- {`
-
- `}
-
-
- - This example shows a timeline where a temporal range with only a end value is provided. -
-
-
- {`
-
- `}
-
-
- - This example shows a timeline with a temporal range provided. -
-
-
- {`
-
- `}
-
-
- - This example shows a timeline where a temporal range with only a start value is provided. -
-
-
- {`
-
- `}
-
-
- - This example shows a timeline with three rows of data, - a temporal range and a focused interval included. -
-
-
- {`
+ const code = `
{
end: new Date('2020-03-15').getTime()
}}
/>
- `}
-
-
-