Skip to content

Commit

Permalink
2245 no document md title (#205)
Browse files Browse the repository at this point in the history
* Remove md:title from test data

* Remove md:title from page template

* Update tests for fix-document-ids

I assume md:title was there to test that ids were not added to metadata
elements
I replaced it with md:uuid to test the same condition

* Add test for page title with nested text

I could not find an existing test for this
  • Loading branch information
TylerZeroMaster authored Jul 1, 2024
1 parent 7244d86 commit 3a3f92d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion modules/m00001/index.cnxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:content-id>m00001</md:content-id>
<md:uuid>baa77304-546c-4ff7-b757-99536556dc66</md:uuid>
</metadata>
Expand Down
1 change: 0 additions & 1 deletion modules/m00002/index.cnxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<document xmlns="http://cnx.rice.edu/cnxml">
<title>Module 2</title>
<metadata xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Module 2</md:title>
<md:content-id>m00002</md:content-id>
<md:uuid>6c26f00d-4997-448e-a9a5-0dbf78bf1ab4</md:uuid>
</metadata>
Expand Down
1 change: 0 additions & 1 deletion modules/m00003/index.cnxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<document xmlns="http://cnx.rice.edu/cnxml">
<title>Module 3</title>
<metadata xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Module 3</md:title>
<md:content-id>m00003</md:content-id>
<md:uuid>7681558a-1046-46eb-a595-a8e981adfe3b</md:uuid>
</metadata>
Expand Down
6 changes: 3 additions & 3 deletions server/src/__snapshots__/fix-document-ids.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports[`Element ID creation fixDocument check if ids are created 1`] = `
"<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata mdml-version="0.5" xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:uuid>00000000-0000-0000-0000-000000000000</md:uuid>
</metadata>
<content>
<para id="test">Test Introduction</para>
Expand All @@ -17,7 +17,7 @@ exports[`Element ID creation fixDocument check if ids are generated with right (
"<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata mdml-version="0.5" xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:uuid>00000000-0000-0000-0000-000000000000</md:uuid>
</metadata>
<content>
<para id="para-00001">no id here</para>
Expand Down Expand Up @@ -46,7 +46,7 @@ exports[`Element ID creation fixDocument check if term in defintion does not get
"<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata mdml-version="0.5" xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:uuid>00000000-0000-0000-0000-000000000000</md:uuid>
</metadata>
<content>
<para id="para-00001">
Expand Down
8 changes: 4 additions & 4 deletions server/src/fix-document-ids.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('Element ID creation', () => {
const simple = `<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata mdml-version="0.5" xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:uuid>00000000-0000-0000-0000-000000000000</md:uuid>
</metadata>
<content>
<para id="test">Test Introduction</para>
Expand All @@ -28,7 +28,7 @@ describe('Element ID creation', () => {
const paraPartialId = `<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata mdml-version="0.5" xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:uuid>00000000-0000-0000-0000-000000000000</md:uuid>
</metadata>
<content>
<section>
Expand Down Expand Up @@ -62,7 +62,7 @@ describe('Element ID creation', () => {
const xml = `<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata mdml-version="0.5" xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:uuid>00000000-0000-0000-0000-000000000000</md:uuid>
</metadata>
<content>
<para>no id here</para>
Expand Down Expand Up @@ -94,7 +94,7 @@ describe('Element ID creation', () => {
const xml = `<document id="new" cnxml-version="0.7" module-id="" xmlns="http://cnx.rice.edu/cnxml" class="introduction">
<title>Introduction</title>
<metadata mdml-version="0.5" xmlns:md="http://cnx.rice.edu/mdml">
<md:title>Introduction</md:title>
<md:uuid>00000000-0000-0000-0000-000000000000</md:uuid>
</metadata>
<content>
<para>
Expand Down
2 changes: 0 additions & 2 deletions server/src/model-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,6 @@ export class ModelManager {
<document xmlns="http://cnx.rice.edu/cnxml">
<title/>
<metadata xmlns:md="http://cnx.rice.edu/mdml">
<md:title/>
<md:content-id/>
<md:uuid/>
</metadata>
Expand All @@ -689,7 +688,6 @@ export class ModelManager {

const doc = new DOMParser().parseFromString(template(), 'text/xml')
selectOne('/cnxml:document/cnxml:title', doc).textContent = title
selectOne('/cnxml:document/cnxml:metadata/md:title', doc).textContent = title
selectOne('/cnxml:document/cnxml:metadata/md:content-id', doc).textContent = newModuleId
selectOne('/cnxml:document/cnxml:metadata/md:uuid', doc).textContent = uuid4()
const xmlStr = new XMLSerializer().serializeToString(doc)
Expand Down
5 changes: 5 additions & 0 deletions server/src/model/page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ describe('Page', () => {
expect(() => { page.load(pageMaker({ uuid: 'little bobby drop tables</md:uuid><md:uuid>injection is fun' })) })
.toThrow("Expected one but found 2 results that match '//md:uuid'")
})
it('loads title correctly', () => {
expect(page.isLoaded).toBe(false)
page.load(pageMaker({ title: 'Some <emphasis>text</emphasis>' }))
expect(page.title).toBe('Some text')
})
})

describe('Page validations', () => {
Expand Down

0 comments on commit 3a3f92d

Please sign in to comment.