Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
daniele-mng committed Dec 2, 2024
1 parent b9c6a7d commit b6d19b2
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 13 deletions.
4 changes: 2 additions & 2 deletions public/locales/gsa-de.json
Original file line number Diff line number Diff line change
Expand Up @@ -1503,8 +1503,8 @@
"Show all Hosts with IP {{ip}}": "Zeige alle Hosts mit IP {{ip}}",
"Show all Identifiers": "Alle Identifikatoren anzeigen",
"Show latest Identifiers": "Die letzten Identifikatoren anzeigen",
"Sign In": "Anmelden",
"Sign In as Guest": "Als Gast anmelden",
"Sign in": "Anmelden",
"Sign in as Guest": "Als Gast anmelden",
"Sign in to your account": "Anmelden",
"Simple Notice": "Einfache Notiz",
"Single": "Einzeln",
Expand Down
12 changes: 8 additions & 4 deletions src/web/pages/login/loginform.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const Panel = styled.div`
margin-bottom: 10px;
`;

const Error = styled.p`
const StyledWarningError = styled.p`
color: ${Theme.warningRed};
font-weight: bold;
text-align: center;
Expand Down Expand Up @@ -109,7 +109,9 @@ const LoginForm = ({
<Layout flex="column">
{showProtocolInsecure && (
<StyledPanel data-testid="protocol-insecure">
<Error>{_('Warning: Connection unencrypted')}</Error>
<StyledWarningError>
{_('Warning: Connection unencrypted')}
</StyledWarningError>
<p>
{_(
'The connection to this GSA is not encrypted, allowing ' +
Expand All @@ -129,7 +131,9 @@ const LoginForm = ({
<Layout>
{isIE11 && (
<Panel data-testid="IE11">
<Error>{_('Warning: You are using IE11')}</Error>
<StyledWarningError>
{_('Warning: You are using IE11')}
</StyledWarningError>
<p>
{_(
'You are using Internet Explorer 11. This browser is not supported anymore. Please use an up-to-date alternative or contact your system administrator.',
Expand Down Expand Up @@ -169,7 +173,7 @@ const LoginForm = ({
onChange={handleValueChange}
/>
<Button data-testid="login-button" onClick={handleSubmit}>
{_('Sign In')}
{_('Sign in')}
</Button>
</FormGroup>
)}
Expand Down
68 changes: 65 additions & 3 deletions src/web/pages/performance/__tests__/startendtimeselection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe('StartTimeSelection tests', () => {
const checkElementVisibilityAndContent = (
labelText,
inputValue,
buttonContent,
timePickerLabel,
timePickerValue,
) => {
Expand All @@ -51,14 +50,12 @@ describe('StartTimeSelection tests', () => {
checkElementVisibilityAndContent(
'Start Date',
'01/01/2019',
'01/01/2019',
'Start Time',
'13:00',
);
checkElementVisibilityAndContent(
'End Date',
'01/02/2019',
'01/02/2019',
'End Time',
'14:00',
);
Expand Down Expand Up @@ -93,4 +90,69 @@ describe('StartTimeSelection tests', () => {

expect(handleChange).toHaveBeenCalledTimes(1);
});

test.each([
{
initialStartDate: startDate,
initialEndDate: endDate,
newStartDate: startDate.clone().add(1, 'hour'),
newEndDate: endDate.clone().add(1, 'hour'),
expectedStartTime: '14:00',
expectedEndTime: '15:00',
expectedStartDate: '01/01/2019',
expectedEndDate: '01/02/2019',
description: 'should update startTime and endTime on props change',
},
{
initialStartDate: startDate,
initialEndDate: endDate,
newStartDate: startDate.clone().subtract(1, 'day'),
newEndDate: endDate.clone().add(1, 'day'),
expectedStartTime: '13:00',
expectedEndTime: '14:00',
expectedStartDate: '31/12/2018',
expectedEndDate: '02/02/2019',
description: 'should update startDate and endDate on props change',
},
])(
'$description',
({
initialStartDate,
initialEndDate,
newStartDate,
newEndDate,
expectedStartTime,
expectedEndTime,
expectedStartDate,
expectedEndDate,
}) => {
const {rerender, getByLabelText} = render(
<StartTimeSelection
timezone={timezone}
startDate={initialStartDate}
endDate={initialEndDate}
onChange={handleChange}
/>,
);

expect(getByLabelText('Start Time')).toHaveValue('13:00');
expect(getByLabelText('End Time')).toHaveValue('14:00');
expect(getByLabelText('Start Date')).toHaveValue('01/01/2019');
expect(getByLabelText('End Date')).toHaveValue('01/02/2019');

rerender(
<StartTimeSelection
timezone={timezone}
startDate={newStartDate}
endDate={newEndDate}
onChange={handleChange}
/>,
);

expect(getByLabelText('Start Time')).toHaveValue(expectedStartTime);
expect(getByLabelText('End Time')).toHaveValue(expectedEndTime);
expect(getByLabelText('Start Date')).toHaveValue(expectedStartDate);
expect(getByLabelText('End Date')).toHaveValue(expectedEndDate);
},
);
});
5 changes: 2 additions & 3 deletions src/web/pages/performance/performancepage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ class PerformancePage extends React.Component {
endDate: end,
scanners: [],
};

this.handleDurationChange = this.handleDurationChange.bind(this);
this.handleValueChange = this.handleValueChange.bind(this);
this.handleStartEndChange = this.handleStartEndChange.bind(this);
Expand All @@ -192,7 +191,7 @@ class PerformancePage extends React.Component {
let startDate = date(start);

if (!startDate.isValid()) {
startDate = date();
startDate = date().subtract(1, 'day');
}

let endDate = date(end);
Expand Down Expand Up @@ -235,7 +234,6 @@ class PerformancePage extends React.Component {
startDate: start,
endDate: end,
});

this.handleInteraction();
}
}
Expand Down Expand Up @@ -264,6 +262,7 @@ class PerformancePage extends React.Component {
render() {
const {scanners = [], gmp} = this.props;
const {duration, reports, scannerId, startDate, endDate} = this.state;

const sensorId = selectSaveId(scanners, scannerId, 0);
return (
<React.Fragment>
Expand Down
6 changes: 5 additions & 1 deletion src/web/pages/performance/startendtimeselection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,22 @@ const StartTimeSelection = props => {
timezone,
onChanged,
} = props;

const [startDate, setStartDate] = useState(initialStartDate);
const [endDate, setEndDate] = useState(initialEndDate);
const [startTime, setStartTime] = useState(
formatTimeForTimePicker(initialStartDate),
);

const [endTime, setEndTime] = useState(
formatTimeForTimePicker(initialEndDate),
);

useEffect(() => {
setStartDate(initialStartDate);
setEndDate(initialEndDate);
setStartTime(formatTimeForTimePicker(initialStartDate));
setEndTime(formatTimeForTimePicker(initialEndDate));
}, [initialStartDate, initialEndDate]);

const handleTimeChange = (selectedTime, type) => {
Expand All @@ -63,7 +67,7 @@ const StartTimeSelection = props => {
return (
<Column>
<FormGroup data-testid="timezone" title={_('Timezone')}>
{timezone}
{timezone.replace('_', ' ')}
</FormGroup>
<FormGroup direction="row">
<DatePicker
Expand Down

0 comments on commit b6d19b2

Please sign in to comment.