Skip to content

Commit

Permalink
Merge branch 'main' into fix/SILVA-563
Browse files Browse the repository at this point in the history
  • Loading branch information
paulushcgcj authored Nov 9, 2024
2 parents 5743332 + 59a2ec8 commit c554ac1
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package ca.bc.gov.restapi.results.oracle.enums;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.stream.Stream;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

@DisplayName("Unit Test | AuditActionCodeEnum")
class AuditActionCodeEnumTest {

@DisplayName("Test enum conversion")
@ParameterizedTest(name = "Test enum conversion for code {0} and description {1}")
@MethodSource("enumConversion")
void testEnumConversion(String code, String description, AuditActionCodeEnum expected) {
AuditActionCodeEnum actual = AuditActionCodeEnum.of(code);
assertEquals(expected, actual);
if (expected != null) {
assertEquals(expected.getCode(), actual.getCode());
assertEquals(description, actual.getDescription());
}
}

private static Stream<Arguments> enumConversion() {
return Stream.of(
Arguments.of("UPD", "Update", AuditActionCodeEnum.UPD),
Arguments.of("COR", "Correction", AuditActionCodeEnum.COR),
Arguments.of("O", "Original", AuditActionCodeEnum.O),
Arguments.of("197", "Section 197", AuditActionCodeEnum.SEC197),
Arguments.of("AMG", "Amalgamate", AuditActionCodeEnum.AMG),
Arguments.of("ES", "E-submission", AuditActionCodeEnum.ES),
Arguments.of("MIL", "Milestone", AuditActionCodeEnum.MIL),
Arguments.of("MIN", "Amended (Minor)", AuditActionCodeEnum.MIN),
Arguments.of("SPA", "Site Plan Amendment", AuditActionCodeEnum.SPA),
Arguments.of("VAR", "Variation", AuditActionCodeEnum.VAR),
Arguments.of("AMD", "Amended", AuditActionCodeEnum.AMD),
Arguments.of("APP", "Approved", AuditActionCodeEnum.APP),
Arguments.of("DEL", "Deleted", AuditActionCodeEnum.DEL),
Arguments.of("REJ", "Rejected", AuditActionCodeEnum.REJ),
Arguments.of("RET", "Retired", AuditActionCodeEnum.RET),
Arguments.of("RMD", "Removed", AuditActionCodeEnum.RMD),
Arguments.of("SUB", "Submitted", AuditActionCodeEnum.SUB),
Arguments.of(null, null, null),
Arguments.of("", null, null)
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,8 @@ void getUserRecentOpeningsActions_happyPath_shouldSucceed() throws Exception {
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$[0].activityType").value("Submitted"))
.andExpect(jsonPath("$[0].openingId").value("102"))
.andExpect(jsonPath("$[0].statusCode").value("APP"))
.andExpect(jsonPath("$[0].statusDescription").value("Approved"))
.andExpect(jsonPath("$[0].lastUpdatedLabel").value("2 minutes ago"))
.andExpect(jsonPath("$[0].statusCode").value("FTML"))
.andExpect(jsonPath("$[0].statusDescription").value("Forest Tenure - Major Licensee"))
.andReturn();
}

Expand Down
6 changes: 4 additions & 2 deletions frontend/src/__test__/screens/Opening.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { NotificationProvider } from '../../contexts/NotificationProvider';
import { BrowserRouter } from 'react-router-dom';
import { RecentOpening } from '../../types/RecentOpening';
import { getWmsLayersWhitelistUsers } from '../../services/SecretsService';
import { fetchFreeGrowingMilestones, fetchOpeningsPerYear, fetchRecentOpenings } from '../../services/OpeningService';
import { fetchFreeGrowingMilestones, fetchOpeningsPerYear, fetchRecentOpenings, fetchRecentActions } from '../../services/OpeningService';
import { fetchOpeningFavourites } from '../../services/OpeningFavouriteService';
import { AuthProvider } from '../../contexts/AuthProvider';

Expand All @@ -34,7 +34,8 @@ vi.mock('../../services/OpeningService', async () => {
...actual,
fetchRecentOpenings: vi.fn(),
fetchOpeningsPerYear: vi.fn(),
fetchFreeGrowingMilestones: vi.fn(),
fetchFreeGrowingMilestones: vi.fn(),
fetchRecentActions: vi.fn(),
};
});

Expand Down Expand Up @@ -85,6 +86,7 @@ describe('Opening screen test cases', () => {
]);
(fetchFreeGrowingMilestones as vi.Mock).mockResolvedValue([{ group: '1-5', value: 11 }]);
(fetchOpeningFavourites as vi.Mock).mockResolvedValue([1,2,3]);
(fetchRecentActions as vi.Mock).mockResolvedValue([data]);



Expand Down
14 changes: 13 additions & 1 deletion frontend/src/components/ActionsTable/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ReactNode } from 'react';
import {
Table,
TableHead,
Expand All @@ -15,6 +16,7 @@ import { ITableHeader } from '../../types/TableHeader';
interface IActionsTable {
readonly rows: RecentAction[];
readonly headers: ITableHeader[];
readonly emptySection?: ReactNode;
}

/**
Expand Down Expand Up @@ -47,6 +49,7 @@ function ActionsTable(props: IActionsTable): JSX.Element {
const headerKeys = props.headers.map(header => header.key);

return (
<>
<Table size="lg" useZebraStyles={false} aria-label="actions table">
<TableHead>
<TableRow>
Expand Down Expand Up @@ -78,8 +81,17 @@ function ActionsTable(props: IActionsTable): JSX.Element {
))}
</TableRow>
))}
</TableBody>
{props.rows.length === 0 && (
<TableRow>
<TableCell colSpan={headerKeys.length}>
{props.emptySection}
</TableCell>
</TableRow>
)}
</TableBody>
</Table>

</>
);
};

Expand Down
26 changes: 14 additions & 12 deletions frontend/src/components/MyRecentActions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,31 @@ const MyRecentActions: React.FC = () => {
</Tab>
</TabList>
<TabPanels>
<TabPanel className="tab-content">
{recentActions && recentActions.length > 0 ? (
<ActionsTable rows={recentActions} headers={headers}/>
):(
<TabPanel className="tab-content">
<ActionsTable
rows={recentActions}
headers={headers}
emptySection={
<EmptySection
pictogram="Time"
fill="#0073E6"
title={"There is no actions to show yet!"}
description={"Your recent actions and files will appear here once you generate them"}
/>
)}
/>}
/>
</TabPanel>
<TabPanel className="tab-content">
{fileRows && fileRows.length > 0 ? (
<ActionsTable rows={fileRows} headers={fileHeaders} />
) : (
<TabPanel className="tab-content">
<ActionsTable
rows={fileRows}
headers={fileHeaders}
emptySection={
<EmptySection
pictogram="Time"
fill="#0073E6"
title={"There is no files to show yet!"}
description={"Your recent actions and files will appear here once you generate them"}
/>
)}
/>}
/>
</TabPanel>
</TabPanels>
</Tabs>
Expand Down

0 comments on commit c554ac1

Please sign in to comment.