Skip to content

Commit 13464e0

Browse files
committed
fix more typings
1 parent 031d6d3 commit 13464e0

16 files changed

Lines changed: 68 additions & 43 deletions

packages/project/test/canonical.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ workflows:
170170
type: webhook
171171
enabled: true
172172
webhook_reply: before_start
173-
webhook_response:
173+
webhook_response_config:
174174
success_code: 202
175175
error_code: 500
176176
next: fetch

packages/project/test/fixtures/sample-v2-project.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export const json: SerializedProject = {
2727
name: 'b',
2828
id: 'b',
2929
configuration: 'admin@openfn.org|My Credential',
30+
// TODO it's unclear why we have a type error here??
31+
// @ts-ignore
3032
openfn: { uuid: 3 },
3133
expression: 'fn()',
3234
adaptor: 'common',
@@ -35,6 +37,8 @@ export const json: SerializedProject = {
3537
id: 'trigger',
3638
openfn: { uuid: 2 },
3739
type: 'webhook',
40+
// TODO it's unclear why we have a type error here??
41+
// @ts-ignore
3842
next: { b: { openfn: { uuid: 4 } } },
3943
},
4044
],

packages/project/test/gen/generator.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,6 @@ test('it should generate a simple workflow with trailing space', (t) => {
176176
});
177177

178178
test("it should fail if there's a space on an edge", (t) => {
179-
const result = gen('a -b');
180179
t.throws(() => gen('a-'), {
181180
message: /parsing failed!/i,
182181
});
@@ -495,7 +494,7 @@ test('it should generate a node with two props', (t) => {
495494

496495
test('it should treat quotes specially', (t) => {
497496
const result = gen('a(expression="fn()")-b', t);
498-
const expected = _.cloneDeep(fixtures.ab);
497+
const expected: any = _.cloneDeep(fixtures.ab);
499498
expected.steps[0].expression = 'fn()';
500499

501500
t.deepEqual(result, expected);

packages/project/test/merge/merge-project.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,9 @@ test('options: onlyUpdated with 1 changed, 1 unchanged workflow', (t) => {
855855
]);
856856

857857
// Scribble on both workflows
858+
// @ts-ignore
858859
target.workflows[0].jam = 'jar';
860+
// @ts-ignore
859861
target.workflows[1].jam = 'jar';
860862

861863
// change the source

packages/project/test/parse/from-app-state.test.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ test('should create a Project from prov state with sandbox stuff', (t) => {
6363
};
6464
const project = fromAppState(stateWithSandbox, meta, { format: 'json' });
6565

66-
t.is(project.sandbox.parentId, 'abc');
66+
t.is(project.sandbox!.parentId, 'abc');
6767
t.is(project.options.env, 'dev');
6868
t.is(project.options.color, 'red');
6969
});
@@ -81,14 +81,18 @@ test('should create a Project from prov state with positions', (t) => {
8181
// the provisioner right now doesn't include positions
8282
// - but one day it will, and Project needs to be able to sync it
8383
newState.workflows['my-workflow'].positions = {
84-
x: 1,
85-
y: 1,
84+
step1: {
85+
x: 1,
86+
y: 1,
87+
},
8688
};
8789
const project = fromAppState(newState, meta);
8890

89-
t.deepEqual(project.workflows[0].openfn.positions, {
90-
x: 1,
91-
y: 1,
91+
t.deepEqual(project.workflows[0].openfn!.positions, {
92+
step1: {
93+
x: 1,
94+
y: 1,
95+
},
9296
});
9397
});
9498

@@ -408,7 +412,7 @@ test('mapEdge: map conditions', (t) => {
408412
// TODO the workflow yaml is not a project yaml
409413
// so this test doesn't work
410414
// I'll need to pull the project yaml, with uuids, to get this to work
411-
test.skip('mapWorkflow: map edge conditions', (t) => {
415+
test.skip('mapWorkflow: map edge conditions', () => {
412416
// TODO for yaml like this:
413417
const yaml = `
414418
workflows:
@@ -460,12 +464,10 @@ workflows:
460464
condition_expression: state.ok == 22
461465
462466
`;
463-
const project = fromAppState(yaml, meta, {
467+
fromAppState(yaml, meta, {
464468
format: 'yaml',
465469
});
466-
console.log(project.workflows['my-workflow'].steps);
467-
const { next } = project.workflows['my-workflow'].steps[1];
468-
console.log({ next });
470+
// const { next } = project.workflows['my-workflow'].steps[1];
469471
// make sure that the condition_types get mapped to condition
470472
// also make sure that custom conditions work (both ways)
471473
});

packages/project/test/parse/from-fs.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ function mockFile(path: string, content: string | object) {
1818
content = JSON.stringify(content);
1919
}
2020

21+
// @ts-ignore
2122
files[path] = content;
2223
mock(files);
2324
}
@@ -55,12 +56,12 @@ test.serial('should include multiple workflows (legacy format)', async (t) => {
5556

5657
t.is(project.workflows.length, 2);
5758

58-
const wf1 = project.getWorkflow('workflow-1');
59+
const wf1 = project.getWorkflow('workflow-1')!;
5960
t.truthy(wf1);
6061
t.is(wf1.id, 'workflow-1');
6162
t.is(wf1.name, 'Workflow 1');
6263

63-
const wf2 = project.getWorkflow('workflow-2');
64+
const wf2 = project.getWorkflow('workflow-2')!;
6465
t.truthy(wf2);
6566
t.is(wf2.id, 'workflow-2');
6667
t.is(wf2.name, 'Workflow 2');
@@ -85,7 +86,7 @@ test.serial('should load a workflow expression (legacy format)', async (t) => {
8586
const project = await parseProject({ root: '/ws' });
8687
t.is(project.workflows.length, 1);
8788

88-
const wf = project.getWorkflow('my-workflow');
89+
const wf = project.getWorkflow('my-workflow')!;
8990

9091
t.truthy(wf);
9192

@@ -136,6 +137,7 @@ test.serial(
136137
t.is(project.workflows.length, 1);
137138
const [wf] = project.workflows;
138139

140+
// @ts-ignore
139141
t.is(typeof wf.steps[1].next.c, 'object');
140142
}
141143
);

packages/project/test/parse/from-project.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ test('import from a v1 state as JSON', async (t) => {
6161
// make a few basic assertions about the project
6262
t.is(proj.id, 'my-workflow');
6363
t.is(proj.name, 'My Workflow');
64-
t.is(proj.openfn.uuid, 'e16c5f09-f0cb-4ba7-a4c2-73fcb2f29d00');
64+
t.is(proj.openfn!.uuid, 'e16c5f09-f0cb-4ba7-a4c2-73fcb2f29d00');
6565
t.is(proj.options.retention_policy, 'retain_all');
6666

6767
t.is(proj.workflows.length, 1);
@@ -73,7 +73,7 @@ test('import from a v1 state as YAML', async (t) => {
7373
// make a few basic assertions about the project
7474
t.is(proj.id, 'aaa');
7575
t.is(proj.name, 'aaa');
76-
t.is(proj.openfn.uuid, '1234');
76+
t.is(proj.openfn!.uuid, '1234');
7777
t.is(proj.options.retention_policy, 'retain_all');
7878

7979
t.is(proj.workflows.length, 1);
@@ -94,12 +94,13 @@ test('import a legacy v2 project (cli.version === 2) as JSON', async (t) => {
9494
});
9595

9696
test('import from a v2 project as JSON', async (t) => {
97+
// @ts-ignore
9798
const proj = await Project.from('project', v2.json, { alias: 'main' });
9899

99100
t.is(proj.id, 'my-project');
100101
t.is(proj.name, 'My Project');
101102
t.is(proj.cli.alias, 'main');
102-
t.is(proj.sandbox.parentId, 'abcd');
103+
t.is(proj.sandbox!.parentId, 'abcd');
103104
t.is(proj.options.env, 'dev');
104105
t.is(proj.options.color, 'red');
105106
t.is(proj.openfn!.uuid, '1234');
@@ -153,6 +154,7 @@ test('import from a v2 project as JSON', async (t) => {
153154
});
154155

155156
test('import from a v2 project with alias', async (t) => {
157+
// @ts-ignore
156158
const proj = await Project.from('project', v2.json, { alias: 'staging' });
157159

158160
t.is(proj.id, 'my-project');
@@ -167,7 +169,7 @@ test('import from a v2 project as YAML', async (t) => {
167169
t.is(proj.cli.alias, 'main');
168170
t.is(proj.openfn!.uuid, '1234');
169171
t.is(proj.openfn!.endpoint, 'https://app.openfn.org');
170-
t.is(proj.sandbox.parentId, 'abcd');
172+
t.is(proj.sandbox!.parentId, 'abcd');
171173
t.is(proj.options.env, 'dev');
172174
t.is(proj.options.color, 'red');
173175

packages/project/test/project.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,10 @@ test('should merge two projects', (t) => {
216216
const result = Project.merge(staging, main);
217217

218218
t.is(result.name, 'a');
219-
const mergedStep = result.workflows[0].get('a');
219+
const mergedStep: any = result.workflows[0].get('a');
220220

221221
t.is(mergedStep.expression, 'b()');
222-
t.is(mergedStep.openfn.uuid, wf_a.get('a').openfn.uuid);
222+
t.is(mergedStep.openfn.uuid, wf_a.get('a').openfn!.uuid);
223223
});
224224

225225
test('should return UUIDs for everything', async (t) => {

packages/project/test/serialize/to-fs.test.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ test('extractWorkflow: single simple workflow with an edge', (t) => {
5858
id: 'step1',
5959
next: {
6060
step2: {
61+
// @ts-ignore
6162
condition: true,
6263
openfn: {
6364
// should be excluded!
@@ -121,6 +122,7 @@ test('extractWorkflow: single simple workflow with random edge property', (t) =>
121122
steps: [
122123
{
123124
...step,
125+
// @ts-ignore
124126
foo: 'bar',
125127
},
126128
],
@@ -268,10 +270,11 @@ test('extractWorkflow: single simple workflow with custom root', (t) => {
268270
},
269271
],
270272
},
273+
// @ts-ignore
271274
config
272275
);
273276

274-
const { path, content } = extractWorkflow(project, 'my-workflow');
277+
const { path } = extractWorkflow(project, 'my-workflow');
275278

276279
t.is(path, 'openfn/wfs/my-workflow/my-workflow.json');
277280
});

packages/project/test/serialize/to-project.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import * as l from '@openfn/lexicon';
22
import test from 'ava';
33
import { Project } from '../../src/Project';
4-
import generateWorkflow, { generateProject } from '../../src/gen/generator';
4+
import generateWorkflow from '../../src/gen/generator';
55

66
import * as v2 from '../fixtures/sample-v2-project';
77

8-
const createProject = (props: Partial<l.Project> = {}) => {
8+
const createProject = (props: Partial<l.ProjectState> = {}) => {
99
const proj = new Project({
1010
id: 'my-project',
1111
name: 'My Project',
@@ -86,7 +86,7 @@ test('should exclude null values in yaml', (t) => {
8686
});
8787

8888
// force some null values into the workflow structure
89-
proj.workflows[0].steps[1].openfn.keychain_credential_id = null;
89+
proj.workflows[0].steps[1].openfn!.keychain_credential_id = null;
9090

9191
const yaml = proj.serialize('project', { format: 'yaml' });
9292
t.deepEqual(yaml, v2.yaml);
@@ -95,7 +95,7 @@ test('should exclude null values in yaml', (t) => {
9595
test('should include sandboxy metadata', (t) => {
9696
const proj = createProject({});
9797

98-
const json = proj.serialize('project', { format: 'json' });
98+
const json: any = proj.serialize('project', { format: 'json' });
9999

100100
t.is(json.sandbox.parentId, 'abcd');
101101
t.is(json.options.env, 'dev');

0 commit comments

Comments
 (0)