-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from VirtusLab/feat/configurable-title-fields
feat: configurable title fields for content types
- Loading branch information
Showing
15 changed files
with
221 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"kind": "collectionType", | ||
"collectionName": "blog_posts", | ||
"info": { | ||
"name": "Blog posts" | ||
}, | ||
"options": { | ||
"increments": true, | ||
"timestamps": true, | ||
"searchable": true, | ||
"previewable": true | ||
}, | ||
"attributes": { | ||
"title": { | ||
"type": "string", | ||
"required": true | ||
}, | ||
"altTitle": { | ||
"type": "string" | ||
}, | ||
"navigation": { | ||
"model": "navigationitem", | ||
"plugin": "navigation", | ||
"via": "related", | ||
"configurable": false, | ||
"hidden": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"kind": "collectionType", | ||
"collectionName": "pages", | ||
"info": { | ||
"name": "page" | ||
}, | ||
"options": { | ||
"increments": true, | ||
"timestamps": true, | ||
"searchable": true, | ||
"previewable": true | ||
}, | ||
"attributes": { | ||
"title": { | ||
"type": "string", | ||
"required": true | ||
}, | ||
"navigation": { | ||
"model": "navigationitem", | ||
"plugin": "navigation", | ||
"via": "related", | ||
"configurable": false, | ||
"hidden": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
function setupStrapi() { | ||
Object.defineProperty(global, 'strapi', { | ||
value: { | ||
config: { | ||
custom: { | ||
plugins: { | ||
navigation: { | ||
contentTypesNameFields: { | ||
'blog_posts': ['altTitle'], | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
contentTypes: { | ||
'page': { | ||
...require('./page.settings.json'), | ||
apiName: 'pages', | ||
}, | ||
'blog-post': { | ||
...require('./blog-post.settings.json'), | ||
apiName: 'blog-posts', | ||
}, | ||
}, | ||
plugins: { | ||
navigation: { | ||
services: { | ||
navigation: jest.fn().mockImplementation(), | ||
}, | ||
models: { | ||
'page': require('./page.settings.json'), | ||
'blog-post': require('./blog-post.settings.json'), | ||
} | ||
} | ||
}, | ||
}, | ||
writable: true, | ||
}) | ||
} | ||
module.exports = { setupStrapi }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,34 @@ | ||
|
||
describe('Dummy test', () => { | ||
test('Dummy', () => { }); | ||
const { setupStrapi } = require("../../__mocks__/helpers/strapi"); | ||
|
||
beforeAll(setupStrapi); | ||
|
||
describe('Navigation service', () => { | ||
it('Strapi is defined', () => { | ||
expect(strapi).toBeDefined(); | ||
expect(strapi.contentTypes).toBeDefined(); | ||
expect(Object.keys(strapi.contentTypes).length).toBe(2); | ||
}); | ||
it('Config Content Types', () => { | ||
const { configContentTypes } = require("../navigation"); | ||
const result = [{ | ||
collectionName: "pages", | ||
contentTypeName: "Page", | ||
endpoint: "pages", | ||
label: "Pages", | ||
labelSingular: "Page", | ||
name: "page", | ||
visible: true, | ||
}, { | ||
collectionName: "blog_posts", | ||
contentTypeName: "BlogPost", | ||
endpoint: "blog-posts", | ||
label: "Blog posts", | ||
labelSingular: "Blog post", | ||
name: "blog-post", | ||
visible: true, | ||
}]; | ||
expect(configContentTypes()[0]).toMatchObject(result[0]); | ||
expect(configContentTypes()[1]).toMatchObject(result[1]); | ||
}); | ||
}); |
Oops, something went wrong.