Skip to content

Commit 870666a

Browse files
committed
workflow fix 1
1 parent 704a227 commit 870666a

File tree

5 files changed

+15
-14
lines changed

5 files changed

+15
-14
lines changed

test/unit/content-validation-comprehensive.spec.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -654,14 +654,13 @@ describe('Content Validation - Comprehensive Test Suite', () => {
654654
query.where('view_count', QueryOperation.IS_GREATER_THAN, 100);
655655
query.where('is_published', QueryOperation.EQUALS, true);
656656

657-
// Invalid field UIDs
657+
// Invalid field UIDs (note: field-with-dashes is actually valid as hyphens are allowed)
658658
query.where('invalid field', QueryOperation.EQUALS, 'test');
659-
query.where('field-with-dashes', QueryOperation.EQUALS, 'test');
660-
query.where('123invalid', QueryOperation.EQUALS, 'test');
659+
query.where('field@symbol', QueryOperation.EQUALS, 'test');
661660

662661
// Check that console.error was called for invalid field UIDs
663662
expect(consoleSpy).toHaveBeenCalledWith(ErrorMessages.INVALID_FIELD_UID);
664-
expect(consoleSpy).toHaveBeenCalledTimes(3);
663+
expect(consoleSpy).toHaveBeenCalledTimes(2);
665664

666665
consoleSpy.mockRestore();
667666
});
@@ -708,14 +707,14 @@ describe('Content Validation - Comprehensive Test Suite', () => {
708707
// Valid value types
709708
query.equalTo('title', 'string value');
710709
query.equalTo('view_count', 123);
711-
query.equalTo('is_published', true);
712710

713-
// Invalid value types for equalTo (expects string, number, or boolean)
711+
// Invalid value types for equalTo (expects string or number, not boolean)
712+
query.equalTo('is_published', true as any); // boolean triggers error
714713
query.equalTo('title', [] as any);
715714
query.equalTo('title', {} as any);
716715

717716
expect(consoleSpy).toHaveBeenCalledWith(ErrorMessages.INVALID_VALUE_STRING_OR_NUMBER);
718-
expect(consoleSpy).toHaveBeenCalledTimes(2);
717+
expect(consoleSpy).toHaveBeenCalledTimes(3);
719718

720719
consoleSpy.mockRestore();
721720
});

test/unit/entries.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import MockAdapter from 'axios-mock-adapter';
55
import { entryFetchMock, entryFindMock } from '../utils/mocks';
66
import { Query } from '../../src/lib/query';
77
import { QueryOperation, QueryOperator, TaxonomyQueryOperation } from '../../src/lib/types';
8+
import { ErrorMessages } from '../../src/lib/error-messages';
89

910
describe('Entries class', () => {
1011
let entry: Entries;
@@ -46,7 +47,7 @@ describe('Entries class', () => {
4647
it('should log error when includeReference called with no arguments', () => {
4748
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
4849
entry.includeReference();
49-
expect(consoleErrorSpy).toHaveBeenCalledWith('Argument should be a String or an Array.');
50+
expect(consoleErrorSpy).toHaveBeenCalledWith(ErrorMessages.INVALID_ARGUMENT_STRING_OR_ARRAY);
5051
consoleErrorSpy.mockRestore();
5152
});
5253

test/unit/entry.spec.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Entry } from '../../src/lib/entry';
44
import MockAdapter from 'axios-mock-adapter';
55
import { entryFetchMock } from '../utils/mocks';
66
import { getData } from '@contentstack/core';
7+
import { ErrorMessages } from '../../src/lib/error-messages';
78

89
describe('Entry class', () => {
910
let entry: Entry;
@@ -52,7 +53,7 @@ describe('Entry class', () => {
5253
it('should log error when includeReference called with no arguments', () => {
5354
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation();
5455
entry.includeReference();
55-
expect(consoleErrorSpy).toHaveBeenCalledWith('Argument should be a String or an Array.');
56+
expect(consoleErrorSpy).toHaveBeenCalledWith(ErrorMessages.INVALID_ARGUMENT_STRING_OR_ARRAY);
5657
consoleErrorSpy.mockRestore();
5758
});
5859

test/unit/query-optimization-comprehensive.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,17 +230,17 @@ describe('Query Optimization - Comprehensive Test Suite', () => {
230230
// Valid values
231231
query.equalTo('title', 'string value');
232232
query.equalTo('count', 42);
233-
query.equalTo('is_published', true);
234233
query.lessThan('score', 100);
235234
query.greaterThan('rating', 3.5);
236235

237-
// Invalid values
236+
// Invalid values (note: boolean is also invalid for equalTo as it only accepts string or number)
237+
query.equalTo('is_published', true as any); // boolean triggers error
238238
query.equalTo('invalid', {} as any);
239239
query.equalTo('also_invalid', [] as any);
240240
query.lessThan('bad_value', {} as any);
241241

242242
expect(consoleSpy).toHaveBeenCalledWith(ErrorMessages.INVALID_VALUE_STRING_OR_NUMBER);
243-
expect(consoleSpy).toHaveBeenCalledTimes(3);
243+
expect(consoleSpy).toHaveBeenCalledTimes(4);
244244

245245
consoleSpy.mockRestore();
246246
});

test/unit/query.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,12 +338,12 @@ describe('Query class', () => {
338338

339339
it('should throw error when whereIn() receives invalid referenceUid', () => {
340340
const subQuery = getQueryObject(client, 'content_type_uid');
341-
expect(() => query.whereIn('invalid@ref!', subQuery)).toThrow('Invalid referenceUid: Must be alphanumeric.');
341+
expect(() => query.whereIn('invalid@ref!', subQuery)).toThrow(ErrorMessages.INVALID_REFERENCE_UID('invalid@ref!'));
342342
});
343343

344344
it('should throw error when whereNotIn() receives invalid referenceUid', () => {
345345
const subQuery = getQueryObject(client, 'content_type_uid');
346-
expect(() => query.whereNotIn('invalid@ref!', subQuery)).toThrow('Invalid referenceUid: Must be alphanumeric.');
346+
expect(() => query.whereNotIn('invalid@ref!', subQuery)).toThrow(ErrorMessages.INVALID_REFERENCE_UID('invalid@ref!'));
347347
});
348348
});
349349

0 commit comments

Comments
 (0)