Skip to content

Commit dd6e2f6

Browse files
committed
chore: Add more integration tests for create/update/delete in CLI
1 parent a4b767f commit dd6e2f6

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

playground/__tests__/cli.test.js

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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;

playground/config/plugins.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = {
33
enabled: true,
44
config: {
55
importOnBootstrap: false,
6+
minify: true,
67
},
78
},
89
};

0 commit comments

Comments
 (0)