From 224cc9cd2abd82f39c27467cf7a6f597d7fa75cc Mon Sep 17 00:00:00 2001 From: Alex Mickelson Date: Thu, 21 Aug 2025 08:38:48 -0600 Subject: [PATCH] replacing text can work --- .../local/parsingTests/assignmentHtml.test.ts | 49 +++++++++++++++++++ src/services/htmlMarkdownUtils.ts | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 src/features/local/parsingTests/assignmentHtml.test.ts diff --git a/src/features/local/parsingTests/assignmentHtml.test.ts b/src/features/local/parsingTests/assignmentHtml.test.ts new file mode 100644 index 0000000..789d1dd --- /dev/null +++ b/src/features/local/parsingTests/assignmentHtml.test.ts @@ -0,0 +1,49 @@ +import { describe, it, expect } from "vitest"; +import { LocalAssignment } from "../assignments/models/localAssignment"; +import { AssignmentSubmissionType } from "../assignments/models/assignmentSubmissionType"; +import { markdownToHTMLSafe } from "@/services/htmlMarkdownUtils"; +import { DayOfWeek, LocalCourseSettings } from "../course/localCourseSettings"; + +describe("AssignmentHtmlTest", () => { + it("github classroom share link is replaced in html", () => { + const name = "test assignment"; + const assignment: LocalAssignment = { + name, + description: `here is the description +[Github Classroom](insert_github_classroom_url)`, + dueAt: "08/21/2023 23:59:00", + lockAt: "08/21/2023 23:59:00", + submissionTypes: [AssignmentSubmissionType.ONLINE_UPLOAD], + localAssignmentGroupName: "Final Project", + rubric: [], + allowedFileUploadExtensions: [], + githubClassroomAssignmentShareLink: "findme", + }; + const settings: LocalCourseSettings = { + name: "test empty course", + assignmentGroups: [], + daysOfWeek: [DayOfWeek.Monday, DayOfWeek.Wednesday], + startDate: "07/09/2024 23:59:00", + endDate: "07/09/2024 23:59:00", + defaultDueTime: { hour: 1, minute: 59 }, + canvasId: 0, + defaultAssignmentSubmissionTypes: [], + defaultFileUploadTypes: [], + holidays: [], + assets: [], + }; + const html = markdownToHTMLSafe({ + markdownString: assignment.description, + settings, + convertImages: false, + replaceText: [ + { + source: "insert_github_classroom_url", + destination: "findme", + }, + ], + }); + + expect(html).toContain(`href="findme"`); + }); +}); diff --git a/src/services/htmlMarkdownUtils.ts b/src/services/htmlMarkdownUtils.ts index 7c61ee0..5686571 100644 --- a/src/services/htmlMarkdownUtils.ts +++ b/src/services/htmlMarkdownUtils.ts @@ -97,7 +97,7 @@ export function markdownToHTMLSafe({ (acc, { source, destination }) => acc.replaceAll(source, destination), html ); - return html; + // return html; return replacedHtml; }