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
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ it('retrieves list of all collections', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ it('has the expected output and writes the expected string', async () => {

const { get } = await setup(__dirname, config);
const result = await get({ query, variables: {} });
expect(format(result)).toMatchFileSnapshot('document-query-node.json');
await expect(format(result)).toMatchFileSnapshot('document-query-node.json');
});

it('retrieves document using node field with ID', async () => {
const nodeQuery = `query { node(id: "post/in.md") { ...on Document { _values, _sys { title } }} }`;
const { get } = await setup(__dirname, config);
const result = await get({ query: nodeQuery, variables: {} });
expect(format(result)).toMatchFileSnapshot('node-query-node.json');
await expect(format(result)).toMatchFileSnapshot('node-query-node.json');
});

it('retrieves document using post field', async () => {
const postQuery = `query { post(relativePath: "in.md") { _values, _sys { title } } }`;
const { get } = await setup(__dirname, config);
const result = await get({ query: postQuery, variables: {} });
expect(format(result)).toMatchFileSnapshot('post-query-node.json');
await expect(format(result)).toMatchFileSnapshot('post-query-node.json');
});

it('returns a graceful error when document does not exist', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ it('filters movies by boolean archived operations', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ it('retrieves collection document list', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});

it('returns empty edges and zero totalCount for an empty collection', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ it('retrieves collection metadata and schema information', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ it('filters movies by date using after, before, and between operations', async (
variables: {},
});

expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,15 @@ it('creates document with all field types and validates bridge writes', async ()
query: createMutation,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('createDocument-response.json');
await expect(format(result)).toMatchFileSnapshot(
'createDocument-response.json'
);

const newDocWrite = bridge.getWrite('posts/comprehensive-post.md');
expect(newDocWrite).toBeDefined();
expect(newDocWrite).toMatchFileSnapshot('comprehensive-post-content.md');
await expect(newDocWrite).toMatchFileSnapshot(
'comprehensive-post-content.md'
);
});

const createCollectionMutation = `
Expand Down Expand Up @@ -112,11 +116,15 @@ it('creates document using createCollection endpoint', async () => {
query: createCollectionMutation,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('createCollection-response.json');
await expect(format(result)).toMatchFileSnapshot(
'createCollection-response.json'
);

const newDocWrite = bridge.getWrite('posts/create-collection-post.md');
expect(newDocWrite).toBeDefined();
expect(newDocWrite).toMatchFileSnapshot('create-collection-post-content.md');
await expect(newDocWrite).toMatchFileSnapshot(
'create-collection-post-content.md'
);
});

it('validates immediate document availability after creation', async () => {
Expand Down Expand Up @@ -155,5 +163,7 @@ it('validates immediate document availability after creation', async () => {
variables: {},
});

expect(format(queryResult)).toMatchFileSnapshot('getDocument-response.json');
await expect(format(queryResult)).toMatchFileSnapshot(
'getDocument-response.json'
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ it('creates document with reference field without errors', async () => {
variables: {},
});

expect(format(result)).toMatchFileSnapshot('createDocument-response.json');
await expect(format(result)).toMatchFileSnapshot(
'createDocument-response.json'
);

const newDocWrite = bridge.getWrite('posts/post-with-reference.md');
expect(newDocWrite).toBeDefined();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ it('deletes document and removes it from queries', async () => {
variables: {},
});

expect(format(result)).toMatchFileSnapshot('deleteDocument-response.json');
await expect(format(result)).toMatchFileSnapshot(
'deleteDocument-response.json'
);
expect(result.errors).toBeUndefined();
expect(bridge.getDeletes()).toContain('posts/post-to-delete.md');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ it('updates document and validates bridge writes', async () => {
});

// Validate GraphQL response
expect(format(result)).toMatchFileSnapshot(
await expect(format(result)).toMatchFileSnapshot(
'expected-snapshots/update-document-node.json'
);

// Validate Bridge write operations
const writes = bridge.getWrites();
expect(writes.size).toBeGreaterThan(0);
expect(bridge.getWrite('posts/in.md')).toMatchFileSnapshot(
await expect(bridge.getWrite('posts/in.md')).toMatchFileSnapshot(
'expected-snapshots/update-document-content.md'
);
});
Expand Down Expand Up @@ -80,14 +80,14 @@ it('renames document using updateDocument mutation', async () => {
});

// Validate GraphQL response
expect(format(result)).toMatchFileSnapshot(
await expect(format(result)).toMatchFileSnapshot(
'expected-snapshots/rename-document-node.json'
);

// Validate Bridge write operations
const writes = bridge.getWrites();
expect(writes.size).toBeGreaterThan(0);
expect(bridge.getWrite('posts/renamed-by-bob.md')).toMatchFileSnapshot(
await expect(bridge.getWrite('posts/renamed-by-bob.md')).toMatchFileSnapshot(
'expected-snapshots/rename-document-content.md'
);

Expand Down Expand Up @@ -136,14 +136,14 @@ it('updates document using updatePost mutation', async () => {
});

// Validate GraphQL response
expect(format(result)).toMatchFileSnapshot(
await expect(format(result)).toMatchFileSnapshot(
'expected-snapshots/update-post-node.json'
);

// Validate Bridge write operations
const writes = bridge.getWrites();
expect(writes.size).toBeGreaterThan(0);
expect(bridge.getWrite('posts/in.md')).toMatchFileSnapshot(
await expect(bridge.getWrite('posts/in.md')).toMatchFileSnapshot(
'expected-snapshots/update-post-content.md'
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ it('executes mutation with reference and validates bridge writes', async () => {
variables,
});

expect(format(result)).toMatchFileSnapshot('updated-movie-node.json');
await expect(format(result)).toMatchFileSnapshot('updated-movie-node.json');

const writes = bridge.getWrites();
expect(writes.size).toBeGreaterThan(0);

const movieWrite = bridge.getWrite('movies/in.md');
expect(movieWrite).toBeDefined();
expect(movieWrite).toMatchFileSnapshot('updated-movie-content.md');
await expect(movieWrite).toMatchFileSnapshot('updated-movie-content.md');
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ it('creates folder and validates bridge writes', async () => {
variables: {},
});

expect(format(result)).toMatchFileSnapshot('folder-creation-response.json');
await expect(format(result)).toMatchFileSnapshot(
'folder-creation-response.json'
);

const folderWrite = bridge.getWrite(
'posts/northwind/company-updates/.gitkeep.md'
Expand Down
4 changes: 2 additions & 2 deletions packages/@tinacms/graphql/tests/is-body/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import input from './in.md?raw';
it('has the expected output and writes the expected string', async () => {
const { get, put } = await setup(__dirname, config);
const result = await get();
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
await put(assertDoc(result).data.document._values);
expect(input).toMatchFileSnapshot('out.md');
await expect(input).toMatchFileSnapshot('out.md');
});
4 changes: 2 additions & 2 deletions packages/@tinacms/graphql/tests/is-title/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import input from './in.md?raw';
it('has the expected output and writes the expected string', async () => {
const { get, put } = await setup(__dirname, config);
const result = await get();
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
expect(assertDoc(result).data.document._sys.title).toBe('Hello');
await put(assertDoc(result).data.document._values);
expect(input).toMatchFileSnapshot('out.md');
await expect(input).toMatchFileSnapshot('out.md');
});
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ it('handles multi-field sorting operations using index', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});

it('surfaces a GraphQL error when sort key matches no defined index or field', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ it('filters movies by numeric rating operations', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ it('creates pending document with valid parameters', async () => {
const { query, bridge } = await setupMutation(__dirname, config);

const result = await query({ query: validCreateMutation, variables: {} });
expect(format(result)).toMatchFileSnapshot(
await expect(format(result)).toMatchFileSnapshot(
'addPendingDocument-success-response.json'
);

const newDocWrite = bridge.getWrite('posts/valid-post.md');
expect(newDocWrite).toBeDefined();
expect(newDocWrite).toMatchFileSnapshot('valid-post-content.md');
await expect(newDocWrite).toMatchFileSnapshot('valid-post-content.md');
});

it('handles validation error for invalid collection', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ it('creates pending document with article template and validates bridge writes',
const { query, bridge } = await setupMutation(__dirname, config);

const result = await query({ query: createArticleMutation, variables: {} });
expect(format(result)).toMatchFileSnapshot(
await expect(format(result)).toMatchFileSnapshot(
'addPendingDocument-article-response.json'
);

const newDocWrite = bridge.getWrite('pages/new-article.md');
expect(newDocWrite).toBeDefined();
expect(newDocWrite).toMatchFileSnapshot('new-article-content.md');
await expect(newDocWrite).toMatchFileSnapshot('new-article-content.md');
});

it('creates pending document with product template and validates bridge writes', async () => {
const { query, bridge } = await setupMutation(__dirname, config);

const result = await query({ query: createProductMutation, variables: {} });
expect(format(result)).toMatchFileSnapshot(
await expect(format(result)).toMatchFileSnapshot(
'addPendingDocument-product-response.json'
);

const newDocWrite = bridge.getWrite('pages/new-product.md');
expect(newDocWrite).toBeDefined();
expect(newDocWrite).toMatchFileSnapshot('new-product-content.md');
await expect(newDocWrite).toMatchFileSnapshot('new-product-content.md');
});
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ it('filters crew by template-specific fields using union types', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ it('filters movies by director name using direct reference', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});

it('filters movies by nested reference traversal', async () => {
Expand All @@ -58,5 +58,7 @@ it('filters movies by nested reference traversal', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('nested-reference-node.json');
await expect(format(result)).toMatchFileSnapshot(
'nested-reference-node.json'
);
});
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ it('handles single and multi-field sorting operations', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});

it('combines sort with filter, returning sorted results from the filtered subset only', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@ it('filters movies by string title operations', async () => {
}`,
variables: {},
});
expect(format(result)).toMatchFileSnapshot('node.json');
await expect(format(result)).toMatchFileSnapshot('node.json');
});
Loading
Loading