Skip to content

Commit d033d0e

Browse files
daniele-mngtimopollmeier
authored andcommitted
fix: address comments
1 parent 7340829 commit d033d0e

File tree

5 files changed

+82
-13
lines changed

5 files changed

+82
-13
lines changed

public/locales/gsa-de.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1503,8 +1503,8 @@
15031503
"Show all Hosts with IP {{ip}}": "Zeige alle Hosts mit IP {{ip}}",
15041504
"Show all Identifiers": "Alle Identifikatoren anzeigen",
15051505
"Show latest Identifiers": "Die letzten Identifikatoren anzeigen",
1506-
"Sign In": "Anmelden",
1507-
"Sign In as Guest": "Als Gast anmelden",
1506+
"Sign in": "Anmelden",
1507+
"Sign in as Guest": "Als Gast anmelden",
15081508
"Sign in to your account": "Anmelden",
15091509
"Simple Notice": "Einfache Notiz",
15101510
"Single": "Einzeln",

src/web/pages/login/loginform.jsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const Panel = styled.div`
4646
margin-bottom: 10px;
4747
`;
4848

49-
const Error = styled.p`
49+
const StyledWarningError = styled.p`
5050
color: ${Theme.warningRed};
5151
font-weight: bold;
5252
text-align: center;
@@ -109,7 +109,9 @@ const LoginForm = ({
109109
<Layout flex="column">
110110
{showProtocolInsecure && (
111111
<StyledPanel data-testid="protocol-insecure">
112-
<Error>{_('Warning: Connection unencrypted')}</Error>
112+
<StyledWarningError>
113+
{_('Warning: Connection unencrypted')}
114+
</StyledWarningError>
113115
<p>
114116
{_(
115117
'The connection to this GSA is not encrypted, allowing ' +
@@ -129,7 +131,9 @@ const LoginForm = ({
129131
<Layout>
130132
{isIE11 && (
131133
<Panel data-testid="IE11">
132-
<Error>{_('Warning: You are using IE11')}</Error>
134+
<StyledWarningError>
135+
{_('Warning: You are using IE11')}
136+
</StyledWarningError>
133137
<p>
134138
{_(
135139
'You are using Internet Explorer 11. This browser is not supported anymore. Please use an up-to-date alternative or contact your system administrator.',
@@ -169,7 +173,7 @@ const LoginForm = ({
169173
onChange={handleValueChange}
170174
/>
171175
<Button data-testid="login-button" onClick={handleSubmit}>
172-
{_('Sign In')}
176+
{_('Sign in')}
173177
</Button>
174178
</FormGroup>
175179
)}

src/web/pages/performance/__tests__/startendtimeselection.jsx

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ describe('StartTimeSelection tests', () => {
3232
const checkElementVisibilityAndContent = (
3333
labelText,
3434
inputValue,
35-
buttonContent,
3635
timePickerLabel,
3736
timePickerValue,
3837
) => {
@@ -51,14 +50,12 @@ describe('StartTimeSelection tests', () => {
5150
checkElementVisibilityAndContent(
5251
'Start Date',
5352
'01/01/2019',
54-
'01/01/2019',
5553
'Start Time',
5654
'13:00',
5755
);
5856
checkElementVisibilityAndContent(
5957
'End Date',
6058
'01/02/2019',
61-
'01/02/2019',
6259
'End Time',
6360
'14:00',
6461
);
@@ -93,4 +90,69 @@ describe('StartTimeSelection tests', () => {
9390

9491
expect(handleChange).toHaveBeenCalledTimes(1);
9592
});
93+
94+
test.each([
95+
{
96+
initialStartDate: startDate,
97+
initialEndDate: endDate,
98+
newStartDate: startDate.clone().add(1, 'hour'),
99+
newEndDate: endDate.clone().add(1, 'hour'),
100+
expectedStartTime: '14:00',
101+
expectedEndTime: '15:00',
102+
expectedStartDate: '01/01/2019',
103+
expectedEndDate: '01/02/2019',
104+
description: 'should update startTime and endTime on props change',
105+
},
106+
{
107+
initialStartDate: startDate,
108+
initialEndDate: endDate,
109+
newStartDate: startDate.clone().subtract(1, 'day'),
110+
newEndDate: endDate.clone().add(1, 'day'),
111+
expectedStartTime: '13:00',
112+
expectedEndTime: '14:00',
113+
expectedStartDate: '31/12/2018',
114+
expectedEndDate: '02/02/2019',
115+
description: 'should update startDate and endDate on props change',
116+
},
117+
])(
118+
'$description',
119+
({
120+
initialStartDate,
121+
initialEndDate,
122+
newStartDate,
123+
newEndDate,
124+
expectedStartTime,
125+
expectedEndTime,
126+
expectedStartDate,
127+
expectedEndDate,
128+
}) => {
129+
const {rerender, getByLabelText} = render(
130+
<StartTimeSelection
131+
timezone={timezone}
132+
startDate={initialStartDate}
133+
endDate={initialEndDate}
134+
onChange={handleChange}
135+
/>,
136+
);
137+
138+
expect(getByLabelText('Start Time')).toHaveValue('13:00');
139+
expect(getByLabelText('End Time')).toHaveValue('14:00');
140+
expect(getByLabelText('Start Date')).toHaveValue('01/01/2019');
141+
expect(getByLabelText('End Date')).toHaveValue('01/02/2019');
142+
143+
rerender(
144+
<StartTimeSelection
145+
timezone={timezone}
146+
startDate={newStartDate}
147+
endDate={newEndDate}
148+
onChange={handleChange}
149+
/>,
150+
);
151+
152+
expect(getByLabelText('Start Time')).toHaveValue(expectedStartTime);
153+
expect(getByLabelText('End Time')).toHaveValue(expectedEndTime);
154+
expect(getByLabelText('Start Date')).toHaveValue(expectedStartDate);
155+
expect(getByLabelText('End Date')).toHaveValue(expectedEndDate);
156+
},
157+
);
96158
});

src/web/pages/performance/performancepage.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ class PerformancePage extends React.Component {
170170
endDate: end,
171171
scanners: [],
172172
};
173-
174173
this.handleDurationChange = this.handleDurationChange.bind(this);
175174
this.handleValueChange = this.handleValueChange.bind(this);
176175
this.handleStartEndChange = this.handleStartEndChange.bind(this);
@@ -192,7 +191,7 @@ class PerformancePage extends React.Component {
192191
let startDate = date(start);
193192

194193
if (!startDate.isValid()) {
195-
startDate = date();
194+
startDate = date().subtract(1, 'day');
196195
}
197196

198197
let endDate = date(end);
@@ -235,7 +234,6 @@ class PerformancePage extends React.Component {
235234
startDate: start,
236235
endDate: end,
237236
});
238-
239237
this.handleInteraction();
240238
}
241239
}
@@ -264,6 +262,7 @@ class PerformancePage extends React.Component {
264262
render() {
265263
const {scanners = [], gmp} = this.props;
266264
const {duration, reports, scannerId, startDate, endDate} = this.state;
265+
267266
const sensorId = selectSaveId(scanners, scannerId, 0);
268267
return (
269268
<React.Fragment>

src/web/pages/performance/startendtimeselection.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,22 @@ const StartTimeSelection = props => {
2525
timezone,
2626
onChanged,
2727
} = props;
28+
2829
const [startDate, setStartDate] = useState(initialStartDate);
2930
const [endDate, setEndDate] = useState(initialEndDate);
3031
const [startTime, setStartTime] = useState(
3132
formatTimeForTimePicker(initialStartDate),
3233
);
34+
3335
const [endTime, setEndTime] = useState(
3436
formatTimeForTimePicker(initialEndDate),
3537
);
3638

3739
useEffect(() => {
3840
setStartDate(initialStartDate);
3941
setEndDate(initialEndDate);
42+
setStartTime(formatTimeForTimePicker(initialStartDate));
43+
setEndTime(formatTimeForTimePicker(initialEndDate));
4044
}, [initialStartDate, initialEndDate]);
4145

4246
const handleTimeChange = (selectedTime, type) => {
@@ -63,7 +67,7 @@ const StartTimeSelection = props => {
6367
return (
6468
<Column>
6569
<FormGroup data-testid="timezone" title={_('Timezone')}>
66-
{timezone}
70+
{timezone.replace('_', ' ')}
6771
</FormGroup>
6872
<FormGroup direction="row">
6973
<DatePicker

0 commit comments

Comments
 (0)