Skip to content

Commit

Permalink
Merge branch 'develop' into dependabot/156
Browse files Browse the repository at this point in the history
  • Loading branch information
mkimberlin authored Nov 21, 2024
2 parents 3fddecb + e7ac299 commit 923dcd2
Show file tree
Hide file tree
Showing 32 changed files with 462 additions and 161 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import com.objectcomputing.checkins.services.memberprofile.MemberProfile;
import com.objectcomputing.checkins.services.reviews.ReviewPeriod;
import jnr.constants.platform.Local;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.time.LocalDate;

Expand All @@ -18,6 +20,8 @@

public interface FeedbackRequestFixture extends RepositoryFixture, FeedbackTemplateFixture {

static final Logger LOG = LoggerFactory.getLogger(FeedbackRequestFixture.class);

/**
* Creates a sample feedback request
* @param creator The {@link MemberProfile} of the creator of the feedback request
Expand Down Expand Up @@ -59,6 +63,8 @@ default FeedbackRequest saveSampleFeedbackRequest(MemberProfile creator, MemberP
}

default LocalDate getRandomLocalDateTime(LocalDateTime start, LocalDateTime end) {
if(start.isEqual(end)) return end.toLocalDate();

LocalDate startDate = start.toLocalDate();
long daysBetween = ChronoUnit.DAYS.between(startDate, end.toLocalDate());
Random random = new Random();
Expand All @@ -81,6 +87,8 @@ default FeedbackRequest saveSampleFeedbackRequest(MemberProfile creator, MemberP

default FeedbackRequest saveSampleFeedbackRequest(MemberProfile creator, MemberProfile requestee, MemberProfile recipient, UUID templateId, ReviewPeriod reviewPeriod, String status) {
LocalDate submitDate = getRandomLocalDateTime(reviewPeriod.getPeriodStartDate(), reviewPeriod.getCloseDate());
LOG.info("Period start date: {} Generated Submit Date: {}", reviewPeriod.getPeriodStartDate(), submitDate.atStartOfDay());
if(submitDate.atStartOfDay().isAfter(LocalDateTime.now())) submitDate = LocalDateTime.now().toLocalDate();
LocalDate sendDate = getRandomLocalDateTime(reviewPeriod.getPeriodStartDate(), submitDate.atStartOfDay());
return getFeedbackRequestRepository().save(new FeedbackRequest(creator.getId(), requestee.getId(), recipient.getId(), templateId, sendDate, null, status, submitDate, reviewPeriod.getId()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import com.objectcomputing.checkins.services.reviews.ReviewPeriod;
import com.objectcomputing.checkins.services.reviews.ReviewStatus;

import java.time.temporal.TemporalUnit;
import java.util.UUID;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;

public interface ReviewPeriodFixture extends RepositoryFixture {

default ReviewPeriod createADefaultReviewPeriod() {
LocalDateTime launchDate = LocalDateTime.now().plusMinutes(1)
.truncatedTo(ChronoUnit.MILLIS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(1);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(1);
LocalDateTime startDate = launchDate.minusDays(30);
LocalDateTime endDate = closeDate.minusDays(1);
LocalDateTime launchDate = LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.DAYS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(2);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(2);
LocalDateTime startDate = launchDate.minusDays(31);
LocalDateTime endDate = launchDate.minusDays(1);
return getReviewPeriodRepository().save(
new ReviewPeriod("Period of Time", ReviewStatus.OPEN, null, null,
launchDate, selfReviewCloseDate, closeDate,
Expand All @@ -27,12 +27,11 @@ default ReviewPeriod createADefaultReviewPeriod(ReviewStatus reviewStatus) {
}

default ReviewPeriod createADefaultReviewPeriod(ReviewStatus reviewStatus, UUID templateId) {
LocalDateTime launchDate = LocalDateTime.now().plusMinutes(1)
.truncatedTo(ChronoUnit.MILLIS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(1);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(1);
LocalDateTime startDate = launchDate.minusDays(30);
LocalDateTime endDate = closeDate.minusDays(1);
LocalDateTime launchDate = LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.DAYS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(2);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(2);
LocalDateTime startDate = launchDate.minusDays(31);
LocalDateTime endDate = launchDate.minusDays(1);
return getReviewPeriodRepository().save(
new ReviewPeriod("Period of Time", reviewStatus, templateId, null,
launchDate, selfReviewCloseDate, closeDate,
Expand All @@ -43,12 +42,12 @@ default ReviewPeriod createADefaultReviewPeriod(
LocalDateTime launchDate,
ReviewStatus reviewStatus,
UUID templateId, UUID selfReviewTemplateId) {
launchDate = launchDate.truncatedTo(ChronoUnit.MILLIS);
launchDate = launchDate.truncatedTo(ChronoUnit.DAYS);

LocalDateTime selfReviewCloseDate = launchDate.plusDays(4);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(1);
LocalDateTime startDate = launchDate.minusDays(30);
LocalDateTime endDate = closeDate.minusDays(1);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(2);
LocalDateTime startDate = launchDate.minusDays(31);
LocalDateTime endDate = launchDate.minusDays(1);
return getReviewPeriodRepository().save(
new ReviewPeriod("Specific Launch Date", reviewStatus, templateId,
selfReviewTemplateId,
Expand All @@ -57,32 +56,27 @@ default ReviewPeriod createADefaultReviewPeriod(
}

default ReviewPeriod createASecondaryReviewPeriod() {
LocalDateTime launchDate = LocalDateTime.now().plusMinutes(1)
.truncatedTo(ChronoUnit.MILLIS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(1);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(1);
LocalDateTime startDate = launchDate.minusDays(30);
LocalDateTime endDate = closeDate.minusDays(1);
LocalDateTime launchDate = LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.DAYS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(2);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(2);
LocalDateTime startDate = launchDate.minusDays(31);
LocalDateTime endDate = launchDate.minusDays(1);
return getReviewPeriodRepository().save(
new ReviewPeriod("Period of Play", ReviewStatus.OPEN, null, null,
launchDate, selfReviewCloseDate, closeDate,
startDate, endDate));
}

default ReviewPeriod createAClosedReviewPeriod() {
LocalDateTime launchDate = LocalDateTime.now().plusMinutes(1)
.truncatedTo(ChronoUnit.MILLIS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(1);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(1);
LocalDateTime startDate = launchDate.minusDays(30);
LocalDateTime endDate = closeDate.minusDays(1);
LocalDateTime launchDate = LocalDateTime.now().plusDays(1).truncatedTo(ChronoUnit.DAYS);
LocalDateTime startDate = launchDate.minusDays(31);
LocalDateTime endDate = launchDate.minusDays(1);
return createAClosedReviewPeriod(startDate, endDate);
}

default ReviewPeriod createAClosedReviewPeriod(
LocalDateTime periodStart, LocalDateTime periodEnd) {
LocalDateTime launchDate = periodEnd.plusMinutes(1)
.truncatedTo(ChronoUnit.MILLIS).plusDays(1);
LocalDateTime launchDate = periodEnd.plusDays(1).truncatedTo(ChronoUnit.DAYS);
LocalDateTime selfReviewCloseDate = launchDate.plusDays(3);
LocalDateTime closeDate = selfReviewCloseDate.plusDays(7);
return getReviewPeriodRepository().save(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -833,7 +833,7 @@ void testSelfReviewThreeDaysEmail() {
// launch date, the self-review closes 4 days after the launch date.
// So, to get the three day email, we just need to add 1 day to the
// launch date.
LocalDateTime launchDate = LocalDateTime.now().plusMinutes(1);
LocalDateTime launchDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
checkSelfReviewEmail(launchDate, launchDate.plusDays(1),
" closes in three days!");
}
Expand All @@ -844,7 +844,7 @@ void testSelfReviewOneDayEmail() {
// launch date, the self-review closes 4 days after the launch date.
// So, to get the one day email, we just need to add 3 days to the
// launch date.
LocalDateTime launchDate = LocalDateTime.now().plusMinutes(1);
LocalDateTime launchDate = LocalDateTime.now().truncatedTo(ChronoUnit.DAYS);
checkSelfReviewEmail(launchDate, launchDate.plusDays(3),
" closes in one day!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const server = setupServer(
)
);

beforeAll(() => server.listen());
beforeAll(() => server.listen({ onUnhandledRequest(request, print) {} }));
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

Expand Down
2 changes: 1 addition & 1 deletion web-ui/src/components/agenda/Agenda.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const AgendaItems = () => {
const currentUserId = memberProfile?.id;
const currentCheckin = selectCheckin(state, checkinId);

const [agendaItems, setAgendaItems] = useState();
const [agendaItems, setAgendaItems] = useState([]);
const [description, setDescription] = useState('');
const [isLoading, setIsLoading] = useState(false);

Expand Down
2 changes: 1 addition & 1 deletion web-ui/src/components/celebrations/MyAnniversary.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import MyAnniversary from './MyAnniversary';
import { AppContextProvider } from '../../context/AppContext';
import { BrowserRouter } from 'react-router-dom';

const hideMyAnniversary = false;
const hideMyAnniversary = () => {};
const myAnniversary = {
name: 'Suman Maroju',
anniversary: '12/29/2012',
Expand Down
4 changes: 2 additions & 2 deletions web-ui/src/components/checkin/documents/CheckinDocs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const UploadDocs = () => {
});
}
} catch (e) {
console.log(e);
console.error("getCheckinFiles: " + e);
}
}
if (csrf) {
Expand Down Expand Up @@ -98,7 +98,7 @@ const UploadDocs = () => {
setFiles([...files, data]);
} catch (e) {
setFileColors(fileColors => ({ ...fileColors, [file.name]: 'red' }));
console.log({ e });
console.error("addFiles: " + e);
} finally {
setLoading(false);
}
Expand Down
8 changes: 6 additions & 2 deletions web-ui/src/components/contribution_hours/ProgressBar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import ProgressBar from './ProgressBar';
import renderer from 'react-test-renderer';

it('has billable hours', () => {
snapshot(<ProgressBar props={(1200, 1500, 1850, 0, 0, 0)} />);
snapshot(<ProgressBar billableHours={1200}
contributionHours={1500}
targetHours={1850} />);
});

it('has no billable hours', () => {
snapshot(<ProgressBar props={(0, 1500, 1850, 0, 0, 0)} />);
snapshot(<ProgressBar billableHours={0}
contributionHours={1500}
targetHours={1850} />);
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,20 @@ exports[`has billable hours 1`] = `
<span
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="50"
class="MuiLinearProgress-root MuiLinearProgress-colorPrimary MuiLinearProgress-determinate css-eglki6-MuiLinearProgress-root"
aria-valuenow="65"
class="MuiLinearProgress-root MuiLinearProgress-colorPrimary MuiLinearProgress-buffer css-fl5ss-MuiLinearProgress-root"
role="progressbar"
>
<span
class="MuiLinearProgress-bar MuiLinearProgress-barColorPrimary MuiLinearProgress-bar1Determinate css-5xe99f-MuiLinearProgress-bar1"
style="transform: translateX(-50%);"
class="MuiLinearProgress-dashed MuiLinearProgress-dashedColorPrimary css-8ub8io-MuiLinearProgress-dashed"
/>
<span
class="MuiLinearProgress-bar MuiLinearProgress-barColorPrimary MuiLinearProgress-bar1Buffer css-qhoknl-MuiLinearProgress-bar1"
style="transform: translateX(-35.13513513513513%);"
/>
<span
class="MuiLinearProgress-bar MuiLinearProgress-colorPrimary MuiLinearProgress-bar2Buffer css-1qdnzt4-MuiLinearProgress-bar2"
style="transform: translateX(-18.91891891891892%);"
/>
</span>
</div>
Expand All @@ -30,9 +37,10 @@ exports[`has billable hours 1`] = `
style="display: block;"
>
Billable Hours:
1200
- Contribution Hours:
925
1500
- Target Hours:
1850
- PTO Hours:
Expand Down Expand Up @@ -66,13 +74,13 @@ exports[`has no billable hours 1`] = `
<span
aria-valuemax="100"
aria-valuemin="0"
aria-valuenow="50"
aria-valuenow="81"
class="MuiLinearProgress-root MuiLinearProgress-colorPrimary MuiLinearProgress-determinate css-eglki6-MuiLinearProgress-root"
role="progressbar"
>
<span
class="MuiLinearProgress-bar MuiLinearProgress-barColorPrimary MuiLinearProgress-bar1Determinate css-5xe99f-MuiLinearProgress-bar1"
style="transform: translateX(-50%);"
style="transform: translateX(-18.91891891891892%);"
/>
</span>
</div>
Expand All @@ -82,9 +90,10 @@ exports[`has no billable hours 1`] = `
style="display: block;"
>
Billable Hours:
0
- Contribution Hours:
925
1500
- Target Hours:
1850
- PTO Hours:
Expand Down
2 changes: 1 addition & 1 deletion web-ui/src/components/edit_skills/EditSkillsCard.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const server = setupServer(
})
);

beforeAll(() => server.listen());
beforeAll(() => server.listen({ onUnhandledRequest(request, print) {} }));
afterEach(() => server.resetHandlers());
afterAll(() => server.close());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ const FeedbackRequestCard = ({
requestDate => {
let oldestDate = new Date();
switch (dateRange) {
case DateRange.THREE_MONTHS:
oldestDate.setMonth(oldestDate.getMonth() - 3);
break;
case DateRange.SIX_MONTHS:
oldestDate.setMonth(oldestDate.getMonth() - 6);
break;
Expand All @@ -117,6 +114,7 @@ const FeedbackRequestCard = ({
break;
case DateRange.ALL_TIME:
return true;
case DateRange.THREE_MONTHS:
default:
oldestDate.setMonth(oldestDate.getMonth() - 3);
}
Expand Down Expand Up @@ -181,10 +179,6 @@ const FeedbackRequestCard = ({

let sortMethod;
switch (sortType) {
case SortOption.SENT_DATE:
sortMethod = (a, b) =>
new Date(a.sendDate) > new Date(b.sendDate) ? -1 : 1;
break;
case SortOption.SUBMISSION_DATE:
sortMethod = (a, b) =>
!a.submitDate || new Date(a.submitDate) > new Date(b.submitDate)
Expand All @@ -205,6 +199,7 @@ const FeedbackRequestCard = ({
? -1
: 1;
break;
case SortOption.SENT_DATE:
default:
sortMethod = (a, b) =>
new Date(a.sendDate) > new Date(b.sendDate) ? -1 : 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ it('renders correctly', () => {
<BrowserRouter>
<AppContextProvider>
<FeedbackRequestCard
sortType="sent_date"
dateRange="3mo"
requesteeId="b2d35288-7f1e-4549-aa2b-68396b162490"
templateName="Sample Template"
responses={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ import { BrowserRouter } from 'react-router-dom';
import { AppContextProvider } from '../../../context/AppContext';
import FeedbackRequestSubcard from './FeedbackRequestSubcard';

const defaultTheme = {}

it('renders correctly', () => {
snapshot(
<BrowserRouter>
<AppContextProvider>
<ThemeProvider>
<ThemeProvider theme={defaultTheme}>
<FeedbackRequestSubcard
request={{
id: 'c15961e4-6e9b-42cd-8140-ece9efe2445c',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ it('renders the feedback submit question as text', () => {
id: '1',
question: 'How is the project going so far?',
questionNumber: 1,
questionType: 'TEXT'
inputType: 'TEXT'
}}
readOnly={false}
answer={{
Expand All @@ -34,7 +34,7 @@ it('renders the feedback submit question as radio buttons', () => {
id: '1',
question: 'Do you think the project is going well so far?',
questionNumber: 1,
questionType: 'RADIO'
inputType: 'RADIO'
}}
readOnly={false}
answer={{
Expand All @@ -58,7 +58,7 @@ it('renders the feedback submit question as a slider', () => {
id: '1',
question: 'Do you think the project is going well so far?',
questionNumber: 1,
questionType: 'SLIDER'
inputType: 'SLIDER'
}}
readOnly={false}
answer={{
Expand Down
Loading

0 comments on commit 923dcd2

Please sign in to comment.