Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release to val #1116

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/lambda/sinkChangelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const processAndIndex = async ({
const result = schema.safeParse(record);

if (result.success) {
if (result.data.adminChangeType === "update-id") {
if (result.data.adminChangeType === "update-id" && "idToBeUpdated" in result.data) {
// Push doc with package being soft deleted
docs.forEach((log) => {
const recordOffset = log.id.split("-").at(-1);
Expand All @@ -97,7 +97,10 @@ const processAndIndex = async ({
packageId: result.data.id,
});
});
} else if (result.data.adminChangeType === "split-spa") {
} else if (
result.data.adminChangeType === "split-spa" &&
"idToBeUpdated" in result.data
) {
// Push doc with new split package
docs.push(result.data);

Expand Down
9 changes: 6 additions & 3 deletions lib/lambda/submit/submitSplitSPA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { z } from "zod";
EXAMPLE EVENT JSON:
{
"body": {
"packageId": "MD-25-9999",
"packageId": "MD-25-9999"
}
}
*/
Expand All @@ -26,6 +26,8 @@ const sendSubmitSplitSPAMessage = async (currentPackage: ItemResult) => {
throw new Error("Error getting next Split SPA Id");
}

const currentTime = Date.now();

// ID and changeMade are excluded; the rest of the object has to be spread into the new package
const {
id: _id,
Expand All @@ -41,8 +43,9 @@ const sendSubmitSplitSPAMessage = async (currentPackage: ItemResult) => {
id: newId,
idToBeUpdated: currentPackage._id,
...remainingFields,
makoChangedDate: Date.now(),
changedDate: Date.now(),
makoChangedDate: currentTime,
changedDate: currentTime,
timestamp: currentTime,
origin: "OneMAC",
changeMade: "OneMAC Admin has added a package to OneMAC.",
changeReason: "Per request from CMS, this package was added to OneMAC.",
Expand Down
5 changes: 0 additions & 5 deletions lib/lambda/update/adminChangeSchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ export const transformUpdateValuesSchema = (offset: number) =>
timestamp: Date.now(),
}));

const currentTime = Date.now();

export const transformedUpdateIdSchema = updateIdAdminChangeSchema.transform((data) => ({
...data,
event: "update-id",
Expand All @@ -64,9 +62,6 @@ export const transformedSplitSPASchema = splitSPAAdminChangeSchema.transform((da
event: "split-spa",
packageId: data.id,
id: `${data.id}`,
timestamp: currentTime,
makoChangedDate: currentTime,
changedDate: currentTime,
}));

export const submitNOSOAdminSchema = z.object({
Expand Down
2 changes: 1 addition & 1 deletion react-app/src/features/package/admin-changes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const AdminChange: FC<opensearch.changelog.Document> = (props) => {
<p className="flex flex-row gap-2 text-gray-600">
<strong>{label as string}</strong>
{" - "}
{format(new UTCDate(props.timestamp), "eee, MMM d, yyyy hh:mm:ss a")}
{format(new UTCDate(props.timestamp).getTime(), "eee, MMM d, yyyy hh:mm:ss a")}
</p>
</AccordionTrigger>
<AccordionContent className="p-4">
Expand Down
2 changes: 1 addition & 1 deletion react-app/vitest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ vi.spyOn(Auth, "userAttributes").mockImplementation(mockUserAttributes);
vi.spyOn(Auth, "signOut").mockImplementation(async () => {
setMockUsername(null);
});

process.env.TZ = "UTC";
// Add this to remove all the expected errors in console when running unit tests.
beforeAll(() => {
setDefaultStateSubmitter();
Expand Down
1 change: 1 addition & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default defineConfig({
test: {
globals: true,
environmentMatchGlobs: [["**/*.test.ts", "**/*.test.tsx"]],
testTimeout: 10000,
coverage: {
provider: "istanbul",
reportsDirectory: join(__dirname, "coverage"),
Expand Down
Loading