@@ -13,20 +13,41 @@ describe('Test the config-sync CLI', () => {
1313 } ) ;
1414
1515 test ( 'Export' , async ( ) => {
16- const { stdout } = await exec ( 'yarn cs export -y' ) ;
17- expect ( stdout ) . toContain ( 'Finished export' ) ;
16+ const { stdout : exportOutput } = await exec ( 'yarn cs export -y' ) ;
17+ expect ( exportOutput ) . toContain ( 'Finished export' ) ;
18+ const { stdout : diffOutput } = await exec ( 'yarn cs diff' ) ;
19+ expect ( diffOutput ) . toContain ( 'No differences between DB and sync directory' ) ;
1820 } ) ;
19- test ( 'Import' , async ( ) => {
20- await exec ( 'rm -rf config/sync/admin-role.strapi-editor.json' ) ;
21- const { stdout } = await exec ( 'yarn cs import -y' ) ;
22- expect ( stdout ) . toContain ( 'Finished import' ) ;
21+
22+ test ( 'Import (delete)' , async ( ) => {
23+ // Remove a file to trigger a delete.
24+ await exec ( 'mv config/sync/admin-role.strapi-editor.json .tmp' ) ;
25+ const { stdout : importOutput } = await exec ( 'yarn cs import -y' ) ;
26+ expect ( importOutput ) . toContain ( 'Finished import' ) ;
27+ const { stdout : diffOutput } = await exec ( 'yarn cs diff' ) ;
28+ expect ( diffOutput ) . toContain ( 'No differences between DB and sync directory' ) ;
29+ } ) ;
30+ test ( 'Import (update)' , async ( ) => {
31+ // Update a core-store file.
32+ await exec ( 'sed -i \'s/"description":"",/"description":"test",/g\' config/sync/core-store.plugin_content_manager_configuration_content_types##plugin##users-permissions.user.json' ) ;
33+ // Update a file that has relations.
34+ await exec ( 'sed -i \'s/{"action":"plugin::users-permissions.auth.register"},//g\' config/sync/user-role.public.json' ) ;
35+ const { stdout : importOutput } = await exec ( 'yarn cs import -y' ) ;
36+ expect ( importOutput ) . toContain ( 'Finished import' ) ;
37+ const { stdout : diffOutput } = await exec ( 'yarn cs diff' ) ;
38+ expect ( diffOutput ) . toContain ( 'No differences between DB and sync directory' ) ;
2339 } ) ;
24- test ( 'Diff' , async ( ) => {
25- const { stdout } = await exec ( 'yarn cs diff' ) ;
26- expect ( stdout ) . toContain ( 'No differences between DB and sync directory' ) ;
40+ test ( 'Import (create)' , async ( ) => {
41+ // Add a file to trigger a creation.
42+ await exec ( 'mv .tmp/admin-role.strapi-editor.json config/sync/' ) ;
43+ const { stdout : importOutput } = await exec ( 'yarn cs import -y' ) ;
44+ expect ( importOutput ) . toContain ( 'Finished import' ) ;
45+ const { stdout : diffOutput } = await exec ( 'yarn cs diff' ) ;
46+ expect ( diffOutput ) . toContain ( 'No differences between DB and sync directory' ) ;
2747 } ) ;
48+
2849 test ( 'Non-empty diff returns 1' , async ( ) => {
29- await exec ( 'rm -rf config/sync/admin-role.strapi-author .json' ) ;
50+ await exec ( 'rm -rf config/sync/admin-role.strapi-editor .json' ) ;
3051 // Work around Jest not supporting custom error matching.
3152 // https://github.com/facebook/jest/issues/8140
3253 let error ;
0 commit comments