Skip to content

Commit ed947dc

Browse files
committed
wip
1 parent 3bb5915 commit ed947dc

File tree

5 files changed

+88
-86
lines changed

5 files changed

+88
-86
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
"name": "form-js",
33
"scripts": {
44
"all": "run-s lint build lint:types test test:distro",
5-
"build": "lerna run build --stream",
5+
"build": "lerna run build",
66
"build:watch": "npm run build:watch:scope -- @bpmn-io/form-js",
77
"build-distro": "lerna run prepublishOnly",
8-
"build:watch:scope": "lerna run bundle:watch --stream --scope",
8+
"build:watch:scope": "lerna run bundle:watch --scope",
99
"clean": "del-cli \"{node_modules,dist}\" \"packages/*/{node_modules,dist}\" \"e2e/dist\"",
1010
"distro": "run-s clean reinstall build-distro",
11-
"dev": "lerna run dev --stream --scope",
11+
"dev": "lerna run dev --scope",
1212
"lerna-publish": "lerna publish -m \"chore(project): publish %s\"",
1313
"lint": "eslint packages",
1414
"lint:types": "tsc --pretty",

packages/form-js-editor/test/spec/FormEditor.spec.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -807,15 +807,12 @@ describe('FormEditor', function() {
807807

808808
await expectSelected('Form_1');
809809

810-
const text1 = formEditor.get('formFieldRegistry').get('Text_1');
811-
812810
// when
811+
const text1 = formEditor.get('formFieldRegistry').get('Text_1');
813812
formEditor.get('selection').set(text1);
814813

815-
await expectSelected('Text_1');
816-
817814
// then
818-
expectSelected('Text_1');
815+
await expectSelected('Text_1');
819816
});
820817

821818
});
@@ -857,16 +854,18 @@ describe('FormEditor', function() {
857854
await expectSelected('Textfield_1');
858855

859856
// open group to make entry focusable
860-
const group = await screen.getByText('General');
861-
fireEvent.click(group);
857+
const group = screen.getByText('General');
858+
await act(() => fireEvent.click(group));
862859

863-
const input = await screen.getByLabelText('Field label');
860+
const input = screen.getByLabelText('Field label');
864861

865862
// when
866-
input.focus();
863+
await act(() => input.focus());
867864

868865
// then
869-
expect(focusinSpy).to.have.been.called;
866+
await waitFor(() => {
867+
expect(focusinSpy).to.have.been.called;
868+
});
870869
});
871870

872871

@@ -891,18 +890,19 @@ describe('FormEditor', function() {
891890
await expectSelected('Textfield_1');
892891

893892
// open group to make entry focusable
894-
const group = await screen.getByText('General');
895-
fireEvent.click(group);
893+
const group = screen.getByText('General');
894+
await act(() => fireEvent.click(group));
896895

897-
const input = await screen.getByLabelText('Field label');
898-
899-
input.focus();
896+
const input = screen.getByLabelText('Field label');
897+
await act(() => input.focus());
900898

901899
// when
902-
input.blur();
900+
await act(() => input.blur());
903901

904902
// then
905-
expect(focusoutSpy).to.have.been.called;
903+
await waitFor(() => {
904+
expect(focusoutSpy).to.have.been.called;
905+
});
906906
});
907907

908908
});
@@ -952,7 +952,7 @@ describe('FormEditor', function() {
952952
expect(dragulaDestroyedSpy).not.to.have.been.called;
953953

954954
// when
955-
act(() => formEditor.attachTo(container));
955+
await act(() => formEditor.attachTo(container));
956956

957957
// then
958958
// todo (@skaiir): investigate why this is called twice

packages/form-js-playground/test/spec/JSONEditor.spec.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ describe('JSONEditor', function() {
112112

113113
const cm = editor.getView();
114114

115-
// move cursor to the end
115+
// move cursor to the end of foo
116116
select(cm, 5);
117117

118118
// assume
@@ -139,31 +139,32 @@ describe('JSONEditor', function() {
139139

140140
describe('autocompletion', function() {
141141

142-
it('should suggest applicable variables', function(done) {
142+
it('should suggest applicable variables', async function() {
143143

144144
// given
145145
const initalValue = 'fooba';
146146
const variables = [ 'foobar', 'baz' ];
147147

148148
const editor = new JSONEditor();
149+
const div = document.createElement('div');
150+
editor.attachTo(div);
151+
149152
editor.setValue(initalValue),
150153
editor.setVariables(variables);
151154

152155
const cm = editor.getView();
153156

154-
// move cursor to the end
157+
// move cursor to the end of fooba
155158
select(cm, 5);
156159

157160
// when
158161
startCompletion(cm);
159162

160163
// then
161-
// update done async
162-
expectEventually(() => {
164+
await expectEventually(() => {
163165
const completions = currentCompletions(cm.state);
164166
expect(completions).to.have.length(1);
165167
expect(completions[0].label).to.have.eql('foobar');
166-
done();
167168
});
168169

169170
});

packages/form-js-viewer/test/spec/render/components/form-fields/ExpressionField.spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ describe('ExpressionField', function() {
2626
});
2727

2828

29-
it('should evaluate its expression on initialization when set to onChange', function() {
29+
it('should evaluate its expression on initialization when set to onChange', async function() {
3030

3131
// given
3232
const field = {
@@ -46,7 +46,7 @@ describe('ExpressionField', function() {
4646
const onChangeSpy = sinon.spy();
4747

4848
// when
49-
act(() => {
49+
await act(() => {
5050
createExpressionField({ field, onChange: onChangeSpy, services });
5151
});
5252

@@ -56,7 +56,7 @@ describe('ExpressionField', function() {
5656
});
5757

5858

59-
it('should re-evaluate when the expression result changes', function() {
59+
it('should re-evaluate when the expression result changes', async function() {
6060

6161
// given
6262
const field = {
@@ -82,7 +82,7 @@ describe('ExpressionField', function() {
8282
const { rerender } = createExpressionField({ field, onChange: onChangeSpy, services });
8383

8484
// when
85-
act(() => {
85+
await act(() => {
8686
rerender(
8787
<MockFormContext
8888
services={ services }
@@ -106,7 +106,7 @@ describe('ExpressionField', function() {
106106
});
107107

108108

109-
it('should not evaluate on intialization if computeOn presubmit', function() {
109+
it('should not evaluate on intialization if computeOn presubmit', async function() {
110110

111111
// given
112112
const field = {
@@ -128,7 +128,7 @@ describe('ExpressionField', function() {
128128
const onChangeSpy = sinon.spy();
129129

130130
// when
131-
act(() => {
131+
await act(() => {
132132
createExpressionField({ field, onChange: onChangeSpy, services });
133133
});
134134

@@ -138,7 +138,7 @@ describe('ExpressionField', function() {
138138
});
139139

140140

141-
it('should evaluate on presubmit', function() {
141+
it('should evaluate on presubmit', async function() {
142142

143143
// given
144144
const field = {
@@ -162,7 +162,7 @@ describe('ExpressionField', function() {
162162
createExpressionField({ field, onChange: onChangeSpy, services });
163163

164164
// when
165-
act(() => {
165+
await act(() => {
166166
services.eventBus.fire('presubmit');
167167
});
168168

0 commit comments

Comments
 (0)