From 27fa8e0906d2a0d1b9346806f73dc1d326686e99 Mon Sep 17 00:00:00 2001 From: Charlie Greenman Date: Thu, 9 May 2024 16:02:48 -0400 Subject: [PATCH 1/2] ZETA-8715: Update the jm to markdown test so has logic for code --- src/__tests__/jm-to-markdown.test.ts | 18 ++++++++++++++++++ src/jm-to-markdown.ts | 1 + 2 files changed, 19 insertions(+) diff --git a/src/__tests__/jm-to-markdown.test.ts b/src/__tests__/jm-to-markdown.test.ts index b12f3e0..169e656 100644 --- a/src/__tests__/jm-to-markdown.test.ts +++ b/src/__tests__/jm-to-markdown.test.ts @@ -19,6 +19,24 @@ Notes: 1. Will be within the importJiraTickets function`; expect(result).toEqual(expected); }); + +it('should convert jira markdown with special curly braces to markdown', () => { + const jiraMarkdown = "{noformat}Scenario We are not sure whether or not scheduling via close is a users local time on their computer or via timezone in close.com system\n Given I am Caitlin \n And I am acting on behalf of Charlie Greenman\n When I use Charlie Greenman's Close.com account \n And Send out an email via send later\n Then It should send an email at the expected time{noformat}\n\nNotes: \n\n# I will send an email to my email address 10 minutes later than the current time to test. Feel free to use this method to test. Once receive email can mark this ticket as complete" + const result = convertJiraMarkdownToRegularMarkdown(jiraMarkdown); + const expected = `**Feature**: Convert Jira ticket ADF description to HTML + +Scenario: User converts Jira ticket ADF to HTML +Given that I have a Jira ticket ADF description +When I initiate the conversion process + And use the importJiraTicket function +Then the ADF description is successfully converted to HTML + +Notes: + +1. Will use the function here: [https://github.com/razroo/html-to-adf?tab=readme-ov-file#convertadftohtml](https://github.com/razroo/html-to-adf?tab=readme-ov-file#convertadftohtml) +1. Will be within the importJiraTickets function`; +expect(result).toEqual(expected); +}) }); describe('convertJiraMarkdownToHtml', () => { diff --git a/src/jm-to-markdown.ts b/src/jm-to-markdown.ts index e728e2f..1a479a3 100644 --- a/src/jm-to-markdown.ts +++ b/src/jm-to-markdown.ts @@ -53,6 +53,7 @@ export function convertJiraMarkdownToRegularMarkdown(jiraMarkdown: string): stri /\{code(:([a-z]+))?([:|]?(title|borderStyle|borderColor|borderWidth|bgColor|titleBGColor)=.+?)*\}([^]*?)\n?\{code\}/gm, '```$2$5\n```' ) + .replace('{noformat}', '```') } export async function convertJiraMarkdownToHtml(jiraMarkdown: string): Promise { From 147b4e243f10e9c9f2e4e1e15212743d8dcc1c1b Mon Sep 17 00:00:00 2001 From: Charlie Greenman Date: Thu, 9 May 2024 16:14:56 -0400 Subject: [PATCH 2/2] ZETA-8715: Update the convertJiraMarkdownToRegularMarkdown logic to include no format logic --- src/__tests__/jm-to-markdown.test.ts | 22 ++++++++++------------ src/jm-to-markdown.ts | 2 +- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/__tests__/jm-to-markdown.test.ts b/src/__tests__/jm-to-markdown.test.ts index 169e656..f70fad4 100644 --- a/src/__tests__/jm-to-markdown.test.ts +++ b/src/__tests__/jm-to-markdown.test.ts @@ -21,22 +21,20 @@ expect(result).toEqual(expected); }); it('should convert jira markdown with special curly braces to markdown', () => { - const jiraMarkdown = "{noformat}Scenario We are not sure whether or not scheduling via close is a users local time on their computer or via timezone in close.com system\n Given I am Caitlin \n And I am acting on behalf of Charlie Greenman\n When I use Charlie Greenman's Close.com account \n And Send out an email via send later\n Then It should send an email at the expected time{noformat}\n\nNotes: \n\n# I will send an email to my email address 10 minutes later than the current time to test. Feel free to use this method to test. Once receive email can mark this ticket as complete" + const jiraMarkdown = "{noformat}Scenario We are not sure whether or not scheduling via close is a users local time on their computer or via timezone in close.com system\n Given I am Henry \n And I am acting on behalf of Charlie Greenman\n When I use Charlie Greenman's Close.com account \n And Send out an email via send later\n Then It should send an email at the expected time{noformat}\n\nNotes: \n\n# I will send an email to my email address 10 minutes later than the current time to test. Feel free to use this method to test. Once receive email can mark this ticket as complete" const result = convertJiraMarkdownToRegularMarkdown(jiraMarkdown); - const expected = `**Feature**: Convert Jira ticket ADF description to HTML - -Scenario: User converts Jira ticket ADF to HTML -Given that I have a Jira ticket ADF description -When I initiate the conversion process - And use the importJiraTicket function -Then the ADF description is successfully converted to HTML + const expected = `\`\`\`Scenario We are not sure whether or not scheduling via close is a users local time on their computer or via timezone in close.com system + Given I am Henry + And I am acting on behalf of Charlie Greenman + When I use Charlie Greenman's Close.com account + And Send out an email via send later + Then It should send an email at the expected time\`\`\` Notes: -1. Will use the function here: [https://github.com/razroo/html-to-adf?tab=readme-ov-file#convertadftohtml](https://github.com/razroo/html-to-adf?tab=readme-ov-file#convertadftohtml) -1. Will be within the importJiraTickets function`; -expect(result).toEqual(expected); -}) +1. I will send an email to my email address 10 minutes later than the current time to test. Feel free to use this method to test. Once receive email can mark this ticket as complete`; + expect(result).toEqual(expected); + }); }); describe('convertJiraMarkdownToHtml', () => { diff --git a/src/jm-to-markdown.ts b/src/jm-to-markdown.ts index 1a479a3..ee8546e 100644 --- a/src/jm-to-markdown.ts +++ b/src/jm-to-markdown.ts @@ -53,7 +53,7 @@ export function convertJiraMarkdownToRegularMarkdown(jiraMarkdown: string): stri /\{code(:([a-z]+))?([:|]?(title|borderStyle|borderColor|borderWidth|bgColor|titleBGColor)=.+?)*\}([^]*?)\n?\{code\}/gm, '```$2$5\n```' ) - .replace('{noformat}', '```') + .replace(/\{noformat\}/g, '```') } export async function convertJiraMarkdownToHtml(jiraMarkdown: string): Promise {