Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

toMarkdown not working as expected for nodes with type variable #103

Closed
DianaLease opened this issue Aug 8, 2019 · 1 comment
Closed
Assignees
Labels
Type: Bug 🐛 Something isn't working

Comments

@DianaLease
Copy link
Member

DianaLease commented Aug 8, 2019

Describe the bug
toMarkdown.recursive() not working when node contains child node of type variable

To Reproduce
Steps to reproduce the behavior:

  1. Instantiate ToMarkdown with VariablePlugin
const clausePlugin = ClausePlugin(null, null);
const pluginManager = new PluginManager([List(), clausePlugin, VariablePlugin()]);
const toMarkdown = new ToMarkdown(pluginManager);
  1. Call toMarkdown.recursive on a clause node that contains child nodes of type variable
    For example...
{
   "object":"block",
   "type":"clause",
   "data":{
      "tag":"clause",
      "attributes":{
         "src":"ap://acceptance-of-delivery@0.12.0#b8eae2fb3c2571284b4dcfc1fc348d8234d0c5db158962043720828be2eb9085",
         "clauseid":"d3cdb02e-6982-47a1-9ba3-350d46212b63"
      },
      "attributeString":"src = \"ap://acceptance-of-delivery@0.12.0#b8eae2fb3c2571284b4dcfc1fc348d8234d0c5db158962043720828be2eb9085\"clauseid = \"d3cdb02e-6982-47a1-9ba3-350d46212b63\"",
      "content":"",
      "closed":false
   },
   "nodes":[
      {
         "object":"block",
         "type":"paragraph",
         "data":{

         },
         "nodes":[
            {
               "object":"block",
               "type":"paragraph",
               "data":{

               },
               "nodes":[
                  {
                     "object":"text",
                     "text":"Acceptance of Delivery. ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"shipper",
                           "value":"%22Party%20A%22"
                        },
                        "attributeString":"id = \"shipper\"value = \"%22Party%20A%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Party A\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" will be deemed to have completed its delivery obligations if in ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"receiver",
                           "value":"%22Party%20B%22"
                        },
                        "attributeString":"id = \"receiver\"value = \"%22Party%20B%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Party B\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":"'s opinion, the ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"deliverable",
                           "value":"%22Widgets%22"
                        },
                        "attributeString":"id = \"deliverable\"value = \"%22Widgets%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Widgets\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" satisfies the Acceptance Criteria, and ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"receiver",
                           "value":"%22Party%20B%22"
                        },
                        "attributeString":"id = \"receiver\"value = \"%22Party%20B%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Party B\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" notifies ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"shipper",
                           "value":"%22Party%20A%22"
                        },
                        "attributeString":"id = \"shipper\"value = \"%22Party%20A%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Party A\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" in writing that it is accepting the ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"deliverable",
                           "value":"%22Widgets%22"
                        },
                        "attributeString":"id = \"deliverable\"value = \"%22Widgets%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Widgets\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":".",
                     "marks":[

                     ]
                  }
               ]
            },
            {
               "object":"block",
               "type":"paragraph",
               "data":{

               },
               "nodes":[
                  {
                     "object":"text",
                     "text":"Inspection and Notice. ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"receiver",
                           "value":"%22Party%20B%22"
                        },
                        "attributeString":"id = \"receiver\"value = \"%22Party%20B%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Party B\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" will have ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"businessDays",
                           "value":"10"
                        },
                        "attributeString":"id = \"businessDays\"value = \"10\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"10",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" Business Days' to inspect and evaluate the ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"deliverable",
                           "value":"%22Widgets%22"
                        },
                        "attributeString":"id = \"deliverable\"value = \"%22Widgets%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Widgets\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" on the delivery date before notifying ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"shipper",
                           "value":"%22Party%20A%22"
                        },
                        "attributeString":"id = \"shipper\"value = \"%22Party%20A%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Party A\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" that it is either accepting or rejecting the ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"deliverable",
                           "value":"%22Widgets%22"
                        },
                        "attributeString":"id = \"deliverable\"value = \"%22Widgets%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Widgets\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":".",
                     "marks":[

                     ]
                  }
               ]
            },
            {
               "object":"block",
               "type":"paragraph",
               "data":{

               },
               "nodes":[
                  {
                     "object":"text",
                     "text":"Acceptance Criteria. The \"Acceptance Criteria\" are the specifications the ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"deliverable",
                           "value":"%22Widgets%22"
                        },
                        "attributeString":"id = \"deliverable\"value = \"%22Widgets%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Widgets\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" must meet for the ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"shipper",
                           "value":"%22Party%20A%22"
                        },
                        "attributeString":"id = \"shipper\"value = \"%22Party%20A%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Party A\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":" to comply with its requirements and obligations under this agreement, detailed in ",
                     "marks":[

                     ]
                  },
                  {
                     "object":"inline",
                     "type":"variable",
                     "data":{
                        "tag":"variable",
                        "attributes":{
                           "id":"attachment",
                           "value":"%22Attachment%20X%22"
                        },
                        "attributeString":"id = \"attachment\"value = \"%22Attachment%20X%22\"",
                        "content":"",
                        "closed":true
                     },
                     "nodes":[
                        {
                           "object":"text",
                           "text":"\"Attachment X\"",
                           "marks":[

                           ]
                        }
                     ]
                  },
                  {
                     "object":"text",
                     "text":", attached to this agreement.",
                     "marks":[

                     ]
                  }
               ]
            }
         ]
      }
   ]
}
  1. Note the output:
Acceptance of Delivery.  will be deemed to have completed its delivery obligations if in 's opinion, the  satisfies the Acceptance Criteria, and  notifies  in writing that it is accepting the .

Inspection and Notice.  will have  Business Days' to inspect and evaluate the  on the delivery date before notifying  that it is either accepting or rejecting the .

Acceptance Criteria. The "Acceptance Criteria" are the specifications the  must meet for the  to comply with its requirements and obligations under this agreement, detailed in , attached to this agreement.

Expected behavior
Expect the output to contain the variables.
For example...

Acceptance of Delivery. <variable id="shipper" value="%22Party%20A%22"/> will be deemed to have completed its delivery obligations if in <variable id="receiver" value="%22Party%20B%22"/>'s opinion, the <variable id="deliverable" value="%22Widgets%22"/> satisfies the Acceptance Criteria, and <variable id="receiver" value="%22Party%20B%22"/> notifies <variable id="shipper" value="%22Party%20A%22"/> in writing that it is accepting the <variable id="deliverable" value="%22Widgets%22"/>.

Inspection and Notice. <variable id="receiver" value="%22Party%20B%22"/> will have <variable id="businessDays" value="10"/> Business Days' to inspect and evaluate the <variable id="deliverable" value="%22Widgets%22"/> on the delivery date before notifying <variable id="shipper" value="%22Party%20A%22"/> that it is either accepting or rejecting the <variable id="deliverable" value="%22Widgets%22"/>.

Acceptance Criteria. The "Acceptance Criteria" are the specifications the <variable id="deliverable" value="%22Widgets%22"/> must meet for the <variable id="shipper" value="%22Party%20A%22"/> to comply with its requirements and obligations under this agreement, detailed in <variable id="attachment" value="%22Attachment%20X%22"/>, attached to this agreement.
historian.ts:245 clause text Acceptance of Delivery. <variable id="shipper" value="%22Party%20A%22"/> will be deemed to have completed its delivery obligations if in <variable id="receiver" value="%22Party%20B%22"/>'s opinion, the <variable id="deliverable" value="%22Widgets%22"/> satisfies the Acceptance Criteria, and <variable id="receiver" value="%22Party%20B%22"/> notifies <variable id="shipper" value="%22Party%20A%22"/> in writing that it is accepting the <variable id="deliverable" value="%22Widgets%22"/>.

Inspection and Notice. <variable id="receiver" value="%22Party%20B%22"/> will have <variable id="businessDays" value="10"/> Business Days' to inspect and evaluate the <variable id="deliverable" value="%22Widgets%22"/> on the delivery date before notifying <variable id="shipper" value="%22Party%20A%22"/> that it is either accepting or rejecting the <variable id="deliverable" value="%22Widgets%22"/>.

Acceptance Criteria. The "Acceptance Criteria" are the specifications the <variable id="deliverable" value="%22Widgets%22"/> must meet for the <variable id="shipper" value="%22Party%20A%22"/> to comply with its requirements and obligations under this agreement, detailed in <variable id="attachment" value="%22Attachment%20X%22"/>, attached to this agreement.
@dselman
Copy link
Sponsor Collaborator

dselman commented Aug 12, 2019

I can't reproduce this. I added a test for it here:
https://github.com/accordproject/cicero-ui/blob/master/src/plugins/ClausePlugin.test.js

The snapshot contains the embedded variables.

\`\`\` <clause src=ap://acceptance-of-delivery@0.12.0#b8eae2fb3c2571284b4dcfc1fc348d8234d0c5db158962043720828be2eb9085 clauseid=d3cdb02e-6982-47a1-9ba3-350d46212b63>
Acceptance of Delivery. <variable id=\\"shipper\\" value=\\"%22Party%20A%22\\"/> will be deemed to have completed its delivery obligations if in <variable id=\\"receiver\\" value=\\"%22Party%20B%22\\"/>'s opinion, the <variable id=\\"deliverable\\" value=\\"%22Widgets%22\\"/> satisfies the Acceptance Criteria, and <variable id=\\"receiver\\" value=\\"%22Party%20B%22\\"/> notifies <variable id=\\"shipper\\" value=\\"%22Party%20A%22\\"/> in writing that it is accepting the <variable id=\\"deliverable\\" value=\\"%22Widgets%22\\"/>.

Inspection and Notice. <variable id=\\"receiver\\" value=\\"%22Party%20B%22\\"/> will have <variable id=\\"businessDays\\" value=\\"10\\"/> Business Days' to inspect and evaluate the <variable id=\\"deliverable\\" value=\\"%22Widgets%22\\"/> on the delivery date before notifying <variable id=\\"shipper\\" value=\\"%22Party%20A%22\\"/> that it is either accepting or rejecting the <variable id=\\"deliverable\\" value=\\"%22Widgets%22\\"/>.

Acceptance Criteria. The \\"Acceptance Criteria\\" are the specifications the <variable id=\\"deliverable\\" value=\\"%22Widgets%22\\"/> must meet for the <variable id=\\"shipper\\" value=\\"%22Party%20A%22\\"/> to comply with its requirements and obligations under this agreement, detailed in <variable id=\\"attachment\\" value=\\"%22Attachment%20X%22\\"/>, attached to this agreement.
\`\`\`

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants