Skip to content

Commit

Permalink
test(e2e): add noSnapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
EdouardDem committed Apr 26, 2024
1 parent 0dd4206 commit 43030c8
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/e2e/spec/entrypoint.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from './hooks/index.js';
import {
excludeSomeCollections,
includeSomeCollections,
includeSomeCollections, noSnapshot,
} from './exclude-include/index.js';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 10000;
Expand Down Expand Up @@ -64,4 +64,5 @@ describe('Pull and check if ids are preserved for some collections', () => {

excludeSomeCollections(context);
includeSomeCollections(context);
noSnapshot(context);
});
1 change: 1 addition & 0 deletions packages/e2e/spec/exclude-include/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './exclude-some-collections.js';
export * from './include-some-collections.js';
export * from './no-snapshot.js';
59 changes: 59 additions & 0 deletions packages/e2e/spec/exclude-include/no-snapshot.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
Context,
debug,
} from '../helpers/index.js';
import Path from 'path';
import fs from 'fs-extra';

export const noSnapshot = (context: Context) => {
it('should not pull schema from Directus', async () => {
// Init sync client
const sync = await context.getSync('temp/no-snapshot');

// --------------------------------------------------------------------
// Pull the content from Directus
const output = await sync.pull(['--no-snapshot']);

// --------------------------------------------------------------------
// Check that the snapshot was ignored
expect(output).toContain(debug('Snapshot is disabled'));

// --------------------------------------------------------------------
// Check if the content was dumped correctly
const dumpPath = sync.getDumpPath();
const snapshotPath = Path.join(dumpPath, 'snapshot');
// Ensure folder is empty
const files = fs.readdirSync(snapshotPath);
expect(files).toEqual([]);
});

it('should not diff schema from Directus', async () => {
// Init sync client
const sync = await context.getSync('sources/one-item-per-collection', false);

// --------------------------------------------------------------------
// Pull the content from Directus
const output = await sync.diff(['--no-snapshot']);

// --------------------------------------------------------------------
// Check that the snapshot was ignored
expect(output).toContain(debug('Snapshot is disabled'));
expect(output).not.toContain(debug('[snapshot] No changes to apply'));

});

it('should not diff schema from Directus', async () => {
// Init sync client
const sync = await context.getSync('sources/one-item-per-collection', false);

// --------------------------------------------------------------------
// Pull the content from Directus
const output = await sync.push(['--no-snapshot']);

// --------------------------------------------------------------------
// Check that the snapshot was ignored
expect(output).toContain(debug('Snapshot is disabled'));
expect(output).not.toContain(debug('[snapshot] No changes to apply'));

});
};

0 comments on commit 43030c8

Please sign in to comment.