This commit is contained in:
Zeeshaun
2026-03-17 11:09:46 -05:00
parent bd1a9744ad
commit 6e7edcfe1b
332 changed files with 64174 additions and 0 deletions
@@ -0,0 +1,3 @@
.repo-status-change-history-table td {
min-width: 7.5em;
}
@@ -0,0 +1,48 @@
import React from 'react';
import { shallow, ShallowWrapper } from 'enzyme';
import moment from 'moment';
import RepoStatusChangeHistoryTable from './RepoStatusChangeHistoryTable';
import { IRepoStatusChange } from '../../services/service-types/RepoAccountTypes';
describe('RepoStatusChangeHistoryTable Container', () => {
let wrapper: ShallowWrapper;
const dummyRepoStatusChanges: IRepoStatusChange[] = [
{
repoId: 1,
changedDate: moment("2017-12-21"),
statusFrom: "From status",
statusTo: "To status",
changedBy: "System"
}
];
beforeEach(() => {
wrapper = shallow(<RepoStatusChangeHistoryTable accountNo='1234' repoStatusChanges={dummyRepoStatusChanges} />);
});
it ('Renders Notification Bar When No Status Changes', () => {
wrapper = shallow(<RepoStatusChangeHistoryTable accountNo='1234' repoStatusChanges={[]} />);
const component = wrapper.find(`[data-test='warning-alert']`);
expect(component.length).toBe(1);
});
it ('Renders Repo Status Change History Table', () => {
const component = wrapper.find(`[data-test='repo-status-change-history-table']`);
expect(component.length).toBe(1);
});
it ('Renders Valid Rows', () => {
const firstRowDate = wrapper.find(`[data-test='repo-status-change-history-date']`);
const firstRowFrom = wrapper.find(`[data-test='repo-status-change-history-status-from']`);
const firstRowTo = wrapper.find(`[data-test='repo-status-change-history-status-to']`);
const firstRowChangedBy = wrapper.find(`[data-test='repo-status-change-history-changed-by']`);
expect(firstRowDate.text()).toEqual('12/21/2017 - 12:00 AM');
expect(firstRowFrom.text()).toEqual('From status');
expect(firstRowTo.text()).toEqual('To status');
expect(firstRowChangedBy.text()).toEqual('System');
});
});
@@ -0,0 +1,57 @@
import React from 'react';
import NotificationBar, { NotificationBarType } from '../../components/notification-bar/NotificationBar';
import DateFormatting from '../../shared/formatting/DateFormatting';
import { IRepoStatusChange } from '../../services/service-types/RepoAccountTypes';
export interface IRepoStatusChangeHistoryTableProps {
accountNo: string;
repoStatusChanges: IRepoStatusChange[];
}
const RepoStatusChangeHistoryTable: React.FC<IRepoStatusChangeHistoryTableProps> = (props) => {
const result = [];
if (!props.repoStatusChanges.length) {
result.push(
<NotificationBar
key="alert-notification"
type={NotificationBarType.Warning}
text={`No Repo Status Change History for account: ${props.accountNo}`}
data-test="warning-alert"
/>
)
} else {
result.push(
<table key='table' className="table table-striped">
<thead className="thead-dark">
<tr>
<th scope="col">Date</th>
<th scope="col">Status From</th>
<th scope="col">Status To</th>
<th scope="col">Changed By</th>
</tr>
</thead>
<tbody>
{
props.repoStatusChanges.map((statusChange, index) => {
return (
<tr key={index}>
<td data-test="repo-status-change-history-date">{DateFormatting.FormatMMDDYYYHHMMA(statusChange.changedDate)}</td>
<td data-test="repo-status-change-history-status-from">{statusChange.statusFrom}</td>
<td data-test="repo-status-change-history-status-to">{statusChange.statusTo}</td>
<td data-test="repo-status-change-history-changed-by">{statusChange.changedBy}</td>
</tr>
)
})
}
</tbody>
</table>
)
}
return(
<div className="repo-status-change-history-table" data-test="repo-status-change-history-table">{result}</div>
);
}
export default RepoStatusChangeHistoryTable;