-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(editor): Add missing extension methods for expressions (#8845)
- Loading branch information
Showing
28 changed files
with
809 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -545,16 +545,16 @@ describe('Resolution-based completions', () => { | |
}); | ||
|
||
describe('recommended completions', () => { | ||
test('should recommended toDate() for {{ "1-Feb-2024".| }}', () => { | ||
test('should recommend toDateTime() for {{ "1-Feb-2024".| }}', () => { | ||
// @ts-expect-error Spied function is mistyped | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce('1-Feb-2024'); | ||
|
||
expect(completions('{{ "1-Feb-2024".| }}')?.[0]).toEqual( | ||
expect.objectContaining({ label: 'toDate()', section: RECOMMENDED_SECTION }), | ||
expect.objectContaining({ label: 'toDateTime()', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
|
||
test('should recommended toInt(),toFloat() for: {{ "5.3".| }}', () => { | ||
test('should recommend toInt(),toFloat() for: {{ "5.3".| }}', () => { | ||
// @ts-expect-error Spied function is mistyped | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce('5.3'); | ||
const options = completions('{{ "5.3".| }}'); | ||
|
@@ -566,7 +566,7 @@ describe('Resolution-based completions', () => { | |
); | ||
}); | ||
|
||
test('should recommended extractEmail() for: {{ "string with [email protected] in it".| }}', () => { | ||
test('should recommend extractEmail() for: {{ "string with [email protected] in it".| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
'string with [email protected] in it', | ||
|
@@ -577,7 +577,7 @@ describe('Resolution-based completions', () => { | |
); | ||
}); | ||
|
||
test('should recommended extractDomain() for: {{ "[email protected]".| }}', () => { | ||
test('should recommend extractDomain(), isEmail() for: {{ "[email protected]".| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
'[email protected]', | ||
|
@@ -586,9 +586,26 @@ describe('Resolution-based completions', () => { | |
expect(options?.[0]).toEqual( | ||
expect.objectContaining({ label: 'extractDomain()', section: RECOMMENDED_SECTION }), | ||
); | ||
expect(options?.[1]).toEqual( | ||
expect.objectContaining({ label: 'isEmail()', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
|
||
test('should recommend extractDomain(), extractUrlPath() for: {{ "https://n8n.io/pricing".| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
'https://n8n.io/pricing', | ||
); | ||
const options = completions('{{ "https://n8n.io/pricing".| }}'); | ||
expect(options?.[0]).toEqual( | ||
expect.objectContaining({ label: 'extractDomain()', section: RECOMMENDED_SECTION }), | ||
); | ||
expect(options?.[1]).toEqual( | ||
expect.objectContaining({ label: 'extractUrlPath()', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
|
||
test('should recommended round(),floor(),ceil() for: {{ (5.46).| }}', () => { | ||
test('should recommend round(),floor(),ceil() for: {{ (5.46).| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
5.46, | ||
|
@@ -604,6 +621,50 @@ describe('Resolution-based completions', () => { | |
expect.objectContaining({ label: 'ceil()', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
|
||
test('should recommend toDateTime("s") for: {{ (1900062210).| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
1900062210, | ||
); | ||
const options = completions('{{ (1900062210).| }}'); | ||
expect(options?.[0]).toEqual( | ||
expect.objectContaining({ label: 'toDateTime("s")', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
|
||
test('should recommend toDateTime("ms") for: {{ (1900062210000).| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
1900062210000, | ||
); | ||
const options = completions('{{ (1900062210000).| }}'); | ||
expect(options?.[0]).toEqual( | ||
expect.objectContaining({ label: 'toDateTime("ms")', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
|
||
test('should recommend toBoolean() for: {{ (0).| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
0, | ||
); | ||
const options = completions('{{ (0).| }}'); | ||
expect(options?.[0]).toEqual( | ||
expect.objectContaining({ label: 'toBoolean()', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
|
||
test('should recommend toBoolean() for: {{ "true".| }}', () => { | ||
vi.spyOn(workflowHelpers, 'resolveParameter').mockReturnValueOnce( | ||
// @ts-expect-error Spied function is mistyped | ||
'true', | ||
); | ||
const options = completions('{{ "true".| }}'); | ||
expect(options?.[0]).toEqual( | ||
expect.objectContaining({ label: 'toBoolean()', section: RECOMMENDED_SECTION }), | ||
); | ||
}); | ||
}); | ||
|
||
describe('explicit completions (opened by Ctrl+Space or programatically)', () => { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.