• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 1493849842

13 Oct 2024 07:39AM UTC coverage: 83.457% (-16.5%) from 99.965%
1493849842

Pull #4531

gitlab-ci

web-flow
chore: Bump send and express in /tests/e2e_tests

Bumps [send](https://github.com/pillarjs/send) and [express](https://github.com/expressjs/express). These dependencies needed to be updated together.

Updates `send` from 0.18.0 to 0.19.0
- [Release notes](https://github.com/pillarjs/send/releases)
- [Changelog](https://github.com/pillarjs/send/blob/master/HISTORY.md)
- [Commits](https://github.com/pillarjs/send/compare/0.18.0...0.19.0)

Updates `express` from 4.19.2 to 4.21.1
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/4.21.1/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.19.2...4.21.1)

---
updated-dependencies:
- dependency-name: send
  dependency-type: indirect
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #4531: chore: Bump send and express in /tests/e2e_tests

4486 of 6422 branches covered (69.85%)

8551 of 10246 relevant lines covered (83.46%)

151.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.76
/src/js/components/common/forms/timeframe-picker.js
1
// Copyright 2020 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React, { useEffect, useState } from 'react';
15
import { Controller, useFormContext } from 'react-hook-form';
16

17
import { DatePicker } from '@mui/x-date-pickers/DatePicker';
18

19
import moment from 'moment';
20

21
const ensureStartOfDay = date => {
8✔
22
  const momentDate = typeof date === 'string' ? moment(date.replace('Z', '')) : moment(date);
×
23
  return `${momentDate.format().split('T')[0]}T00:00:00.000`;
×
24
};
25

26
const ensureEndOfDay = date => {
8✔
27
  const momentDate = typeof date === 'string' ? moment(date.replace('Z', '')) : moment(date);
×
28
  return `${momentDate.format().split('T')[0]}T23:59:59.999`;
×
29
};
30

31
export const TimeframePicker = ({ tonight: propsTonight }) => {
8✔
32
  const [tonight] = useState(moment(propsTonight));
65✔
33
  const [maxStartDate, setMaxStartDate] = useState(tonight);
65✔
34
  const [minEndDate, setMinEndDate] = useState(tonight);
65✔
35

36
  const { control, setValue, watch, getValues } = useFormContext();
65✔
37

38
  const startDate = watch('startDate');
65✔
39
  const endDate = watch('endDate');
65✔
40

41
  useEffect(() => {
65✔
42
    let currentEndDate = getValues('endDate');
20✔
43
    const now = new Date().toISOString().replace('Z', '');
20✔
44
    if (startDate > currentEndDate) {
20!
45
      setValue('endDate', ensureEndOfDay(startDate));
×
46
    } else if (currentEndDate > now) {
20✔
47
      setValue('endDate', now);
11✔
48
    }
49
    setMinEndDate(moment(startDate));
20✔
50
  }, [startDate, getValues, setValue]);
51

52
  useEffect(() => {
65✔
53
    let currentStartDate = getValues('startDate');
23✔
54
    if (endDate < currentStartDate) {
23!
55
      setValue('startDate', ensureStartOfDay(endDate));
×
56
    }
57
    setMaxStartDate(moment(endDate));
23✔
58
  }, [endDate, getValues, setValue]);
59

60
  const handleChangeStartDate = date => ensureStartOfDay(date);
65✔
61

62
  const handleChangeEndDate = date => ensureEndOfDay(date);
65✔
63

64
  return (
65✔
65
    <div className="flexbox" style={{ flexWrap: 'wrap', gap: 15 }}>
66
      <Controller
67
        name="startDate"
68
        control={control}
69
        render={({ field: { onChange, value } }) => (
70
          <DatePicker
65✔
71
            disabled={!value}
72
            disableFuture
73
            format="MMMM Do"
74
            label="From"
75
            maxDate={maxStartDate}
76
            onChange={e => onChange(handleChangeStartDate(e))}
×
77
            value={value ? moment(value) : moment()}
65✔
78
          />
79
        )}
80
      />
81
      <Controller
82
        name="endDate"
83
        control={control}
84
        render={({ field: { onChange, value } }) => (
85
          <DatePicker
65✔
86
            disableFuture
87
            format="MMMM Do"
88
            label="To"
89
            minDate={minEndDate}
90
            onChange={e => onChange(handleChangeEndDate(e))}
×
91
            value={value ? moment(value) : moment()}
65✔
92
          />
93
        )}
94
      />
95
    </div>
96
  );
97
};
98

99
export default TimeframePicker;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc