Skip to content

Commit 15574f4

Browse files
test: add title assertions to getText and getSuggestions tests
Add mock title data and explicit assertions verifying the document title is present in responses, not just the tab/suggestion content.
1 parent 50333b6 commit 15574f4

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

workspace-server/src/__tests__/services/DocsService.comments.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ describe('DocsService Comments and Suggestions', () => {
5858
it('should return suggestions as type text with JSON-stringified array', async () => {
5959
mockDocsAPI.documents.get.mockResolvedValue({
6060
data: {
61+
title: 'Test Document',
6162
body: {
6263
content: [
6364
{
@@ -84,7 +85,9 @@ describe('DocsService Comments and Suggestions', () => {
8485
});
8586

8687
expect(result.content[0].type).toBe('text');
87-
const { suggestions } = JSON.parse(result.content[0].text);
88+
const parsed = JSON.parse(result.content[0].text);
89+
expect(parsed.title).toBe('Test Document');
90+
const { suggestions } = parsed;
8891
expect(suggestions).toHaveLength(1);
8992
expect(suggestions[0]).toEqual({
9093
type: 'insertion',

workspace-server/src/__tests__/services/DocsService.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,7 @@ describe('DocsService', () => {
513513
it('should return all tabs if no tabId provided and tabs exist', async () => {
514514
const mockDoc = {
515515
data: {
516+
title: 'Multi-Tab Document',
516517
tabs: [
517518
{
518519
tabProperties: { tabId: 'tab-1', title: 'Tab 1' },
@@ -550,6 +551,7 @@ describe('DocsService', () => {
550551
const result = await docsService.getText({ documentId: 'test-doc-id' });
551552
const parsed = JSON.parse(result.content[0].text);
552553

554+
expect(parsed.title).toBe('Multi-Tab Document');
553555
expect(parsed.tabs).toHaveLength(2);
554556
expect(parsed.tabs[0]).toEqual({
555557
tabId: 'tab-1',
@@ -695,6 +697,7 @@ describe('DocsService', () => {
695697
it('should include text from nested child tabs', async () => {
696698
const mockDoc = {
697699
data: {
700+
title: 'Nested Tabs Doc',
698701
tabs: [
699702
{
700703
tabProperties: { tabId: 'parent-tab', title: 'Parent' },
@@ -736,6 +739,7 @@ describe('DocsService', () => {
736739
const result = await docsService.getText({ documentId: 'test-doc-id' });
737740
const parsed = JSON.parse(result.content[0].text);
738741

742+
expect(parsed.title).toBe('Nested Tabs Doc');
739743
expect(parsed.tabs).toHaveLength(2);
740744
expect(parsed.tabs[0]).toEqual({
741745
tabId: 'parent-tab',

0 commit comments

Comments
 (0)