first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
export const profileResponse = {
|
||||
id: 'some-id',
|
||||
age: 30,
|
||||
weight: 168,
|
||||
height: 80,
|
||||
biological_sex: 'male',
|
||||
email: 'nathan@n8n.io',
|
||||
};
|
||||
@@ -0,0 +1,63 @@
|
||||
import { NodeTestHarness } from '@nodes-testing/node-test-harness';
|
||||
import type {
|
||||
IExecuteFunctions,
|
||||
IHookFunctions,
|
||||
ILoadOptionsFunctions,
|
||||
IHttpRequestMethods,
|
||||
INode,
|
||||
} from 'n8n-workflow';
|
||||
import nock from 'nock';
|
||||
|
||||
import { profileResponse } from './apiResponses';
|
||||
import { ouraApiRequest } from '../GenericFunctions';
|
||||
|
||||
const node: INode = {
|
||||
id: '2cdb46cf-b561-4537-a982-b8d26dd7718b',
|
||||
name: 'Oura',
|
||||
type: 'n8n-nodes-base.oura',
|
||||
typeVersion: 1,
|
||||
position: [0, 0],
|
||||
parameters: {
|
||||
resource: 'profile',
|
||||
operation: 'get',
|
||||
},
|
||||
};
|
||||
|
||||
const mockThis = {
|
||||
helpers: {
|
||||
httpRequestWithAuthentication: jest
|
||||
.fn()
|
||||
.mockResolvedValue({ statusCode: 200, data: profileResponse }),
|
||||
},
|
||||
getNode() {
|
||||
return node;
|
||||
},
|
||||
getNodeParameter: jest.fn(),
|
||||
} as unknown as IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions;
|
||||
|
||||
describe('Oura', () => {
|
||||
describe('ouraApiRequest', () => {
|
||||
it('should make an authenticated API request to Oura', async () => {
|
||||
const method: IHttpRequestMethods = 'GET';
|
||||
const resource = '/usercollection/personal_info';
|
||||
|
||||
await ouraApiRequest.call(mockThis, method, resource);
|
||||
|
||||
expect(mockThis.helpers.httpRequestWithAuthentication).toHaveBeenCalledWith('ouraApi', {
|
||||
method: 'GET',
|
||||
url: 'https://api.ouraring.com/v2/usercollection/personal_info',
|
||||
json: true,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Run Oura workflow', () => {
|
||||
beforeAll(() => {
|
||||
nock('https://api.ouraring.com/v2')
|
||||
.get('/usercollection/personal_info')
|
||||
.reply(200, profileResponse);
|
||||
});
|
||||
|
||||
new NodeTestHarness().setupTests();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,86 @@
|
||||
{
|
||||
"name": "Oura Test Workflow",
|
||||
"nodes": [
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "c1e3b825-a9a8-4def-986b-9108d9441992",
|
||||
"name": "When clicking ‘Execute workflow’",
|
||||
"type": "n8n-nodes-base.manualTrigger",
|
||||
"position": [720, 400],
|
||||
"typeVersion": 1
|
||||
},
|
||||
{
|
||||
"parameters": {
|
||||
"resource": "profile"
|
||||
},
|
||||
"id": "7969bf78-9343-4f81-8f79-dc415a60e168",
|
||||
"name": "Oura",
|
||||
"type": "n8n-nodes-base.oura",
|
||||
"typeVersion": 1,
|
||||
"position": [940, 400],
|
||||
"credentials": {
|
||||
"ouraApi": {
|
||||
"id": "r083EOdhFatkVvFy",
|
||||
"name": "Oura account"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"parameters": {},
|
||||
"id": "9b97fa0e-51a6-41d3-8a7d-cff0531e5527",
|
||||
"name": "No Operation, do nothing",
|
||||
"type": "n8n-nodes-base.noOp",
|
||||
"typeVersion": 1,
|
||||
"position": [1140, 400]
|
||||
}
|
||||
],
|
||||
"pinData": {
|
||||
"No Operation, do nothing": [
|
||||
{
|
||||
"json": {
|
||||
"id": "some-id",
|
||||
"age": 30,
|
||||
"weight": 168,
|
||||
"height": 80,
|
||||
"biological_sex": "male",
|
||||
"email": "nathan@n8n.io"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"connections": {
|
||||
"When clicking ‘Execute workflow’": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "Oura",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
},
|
||||
"Oura": {
|
||||
"main": [
|
||||
[
|
||||
{
|
||||
"node": "No Operation, do nothing",
|
||||
"type": "main",
|
||||
"index": 0
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
},
|
||||
"active": false,
|
||||
"settings": {
|
||||
"executionOrder": "v1"
|
||||
},
|
||||
"versionId": "bd108f46-f6fc-4c22-8655-ade2f51c4b33",
|
||||
"meta": {
|
||||
"templateCredsSetupCompleted": true,
|
||||
"instanceId": "0fa937d34dcabeff4bd6480d3b42cc95edf3bc20e6810819086ef1ce2623639d"
|
||||
},
|
||||
"id": "SrUileWU90mQeo02",
|
||||
"tags": []
|
||||
}
|
||||
Reference in New Issue
Block a user