diff --git a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts
index 4360ee6bd..1ad6d7cac 100644
--- a/apps/metadata-editor-e2e/src/e2e/edit.cy.ts
+++ b/apps/metadata-editor-e2e/src/e2e/edit.cy.ts
@@ -18,7 +18,7 @@ describe('editor form', () => {
return
}
// there is a copy: delete it
- cy.get('[data-test="record-menu-button"]').eq(1).click()
+ cy.get('[data-test="record-menu-button"]').eq(0).click()
cy.get('[data-test="record-menu-delete-button"]').click()
cy.get('[data-cy="confirm-button"]').click()
cy.log('An existing copy of the test record was found and deleted.')
@@ -675,6 +675,9 @@ describe('editor form', () => {
})
})
describe('Access and constraints', () => {
+ beforeEach(() => {
+ cy.get('@accessContactPageBtn').click()
+ })
// TEMPORARY - to be removed when the open data switch is back
// describe('Open data switch', () => {
// beforeEach(() => {
@@ -699,9 +702,6 @@ describe('editor form', () => {
// })
// })
describe('licenses', () => {
- beforeEach(() => {
- cy.get('@accessContactPageBtn').click()
- })
it('should select a new license and show it on reload', () => {
cy.get('gn-ui-form-field-license')
.find('button')
@@ -727,6 +727,120 @@ describe('editor form', () => {
.should('eq', ' Creative Commons CC-0 ')
})
})
+ describe('constraints', () => {
+ it('should add a few constraints and show it on reload', () => {
+ cy.editor_wrapPreviousDraft()
+ cy.get('[data-cy=legalConstraints]')
+ .find('gn-ui-button[data-cy=add-constraint-btn] button')
+ .click()
+ cy.get('[data-cy=legalConstraints]')
+ .find('textarea')
+ .last()
+ .type('new legal constraint')
+
+ // add from shortcuts
+ cy.get('[data-cy=constraints-shortcut-btns]')
+ .find('gn-ui-button')
+ .eq(1)
+ .click()
+ cy.get('[data-cy=securityConstraints]')
+ .find('textarea')
+ .last()
+ .type('new security constraint')
+
+ // add from shortcuts
+ cy.get('[data-cy=constraints-shortcut-btns]')
+ .find('gn-ui-button')
+ .eq(2)
+ .click()
+ cy.get('[data-cy=otherConstraints]')
+ .find('textarea')
+ .last()
+ .type('new other constraint')
+ cy.get('[data-cy=otherConstraints]')
+ .find('gn-ui-button[data-cy=add-url-btn] button')
+ .click()
+ cy.get('[data-cy=otherConstraints]')
+ .find('gn-ui-url-input')
+ .last()
+ .find('input')
+ .type('http://www.example.com/abcd/1234')
+
+ cy.screenshot({ capture: 'fullPage' })
+ cy.editor_publishAndReload()
+ cy.get('@saveStatus').should('eq', 'record_up_to_date')
+ cy.get('@accessContactPageBtn').click()
+
+ cy.get('[data-cy=legalConstraints]')
+ .find('gn-ui-constraint-card')
+ .should('have.length', 5)
+ cy.get('[data-cy=legalConstraints]')
+ .find('textarea')
+ .last()
+ .invoke('val')
+ .should('eq', 'new legal constraint')
+
+ cy.get('[data-cy=securityConstraints]')
+ .find('gn-ui-constraint-card')
+ .should('have.length', 1)
+ cy.get('[data-cy=securityConstraints]')
+ .find('textarea')
+ .last()
+ .invoke('val')
+ .should('eq', 'new security constraint')
+
+ cy.get('[data-cy=otherConstraints]')
+ .find('gn-ui-constraint-card')
+ .should('have.length', 1)
+ cy.get('[data-cy=otherConstraints]')
+ .find('textarea')
+ .last()
+ .invoke('val')
+ .should('eq', 'new other constraint')
+ cy.get('[data-cy=otherConstraints]')
+ .find('gn-ui-url-input input')
+ .invoke('val')
+ .should('eq', 'http://www.example.com/abcd/1234/')
+ })
+
+ it('should enable "no applicable constraints" and stay enabled', () => {
+ cy.editor_wrapPreviousDraft()
+ cy.get('[data-cy=constraints-shortcut-toggles]')
+ .find('gn-ui-check-toggle label')
+ .eq(0)
+ .click()
+
+ cy.editor_publishAndReload()
+ cy.get('@saveStatus').should('eq', 'record_up_to_date')
+ cy.get('@accessContactPageBtn').click()
+
+ cy.get('[data-cy=constraints-shortcut-toggles]')
+ .find('gn-ui-check-toggle input[type=checkbox]')
+ .eq(0)
+ .invoke('val')
+ .should('eq', 'on')
+
+ // constraints are hidden
+ cy.get('[data-cy=legalConstraints]').should('not.exist')
+ cy.get('[data-cy=securityConstraints]').should('not.exist')
+ cy.get('[data-cy=otherConstraints]').should('not.exist')
+
+ // uncheck toggle
+ cy.get('[data-cy=constraints-shortcut-toggles]')
+ .find('gn-ui-check-toggle label')
+ .eq(0)
+ .click()
+
+ // remaining constraints are shown
+ cy.get('[data-cy=legalConstraints]').should('not.exist')
+ cy.get('[data-cy=securityConstraints]')
+ .find('gn-ui-constraint-card')
+ .should('have.length', 1)
+ cy.get('[data-cy=otherConstraints]')
+ .find('gn-ui-constraint-card')
+ .should('have.length', 1)
+ })
+ })
})
})
})
diff --git a/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts b/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts
index 2e27b4bb6..db356b32a 100644
--- a/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts
+++ b/libs/api/metadata-converter/src/lib/iso19139/write-parts.spec.ts
@@ -12,10 +12,13 @@ import {
writeContacts,
writeContactsForResource,
writeKeywords,
+ writeLegalConstraints,
writeOnlineResources,
+ writeOtherConstraints,
writeResourceCreated,
writeResourcePublished,
writeResourceUpdated,
+ writeSecurityConstraints,
writeSpatialExtents,
writeSpatialRepresentation,
writeTemporalExtents,
@@ -973,6 +976,57 @@ describe('write parts', () => {