Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions server/doi/__tests__/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const models = modelize`
}
}
}
Community cmsCommunity {
cmsMode: true
canonicalBaseUrl: "https://cms.example.org"
Member {
permissions: "admin"
User cmsCommunityAdmin {}
}
Pub cmsPub {
Release {}
}
}
User guest {}
`;

Expand Down Expand Up @@ -179,4 +190,19 @@ it('lets community admins preview a DOI for collections in their community', asy
expect(previewDois.collection).toEqual(expectedCollectionDoi);
});

it('deposits the canonical url for a CMS-mode community', async () => {
const { cmsCommunityAdmin, cmsCommunity, cmsPub } = models;
const agent = await login(cmsCommunityAdmin);
const {
body: { depositJson },
} = await agent
.get('/api/doiPreview')
.query({ target: 'pub', pubId: cmsPub.id, communityId: cmsCommunity.id })
.expect(200);

const depositXml = JSON.stringify(depositJson.deposit);
expect(depositXml).toContain(`https://cms.example.org/pub/${cmsPub.slug}`);
expect(depositXml).not.toContain('pubpub.org');
});

teardown(afterAll);
3 changes: 3 additions & 0 deletions server/doi/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ const findCommunity = (communityId) =>
'subdomain',
'citeAs',
'publishAs',
// cmsMode gates canonicalCommunityUrl, so it must be selected here or
// deposits fall back to the pubpub.org URL for CMS-mode communities.
'cmsMode',
'canonicalBaseUrl',
'canonicalPubUrlTemplate',
],
Expand Down
Loading