Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Skaiir committed Apr 7, 2024
1 parent 3bb5915 commit ed947dc
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 86 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"name": "form-js",
"scripts": {
"all": "run-s lint build lint:types test test:distro",
"build": "lerna run build --stream",
"build": "lerna run build",
"build:watch": "npm run build:watch:scope -- @bpmn-io/form-js",
"build-distro": "lerna run prepublishOnly",
"build:watch:scope": "lerna run bundle:watch --stream --scope",
"build:watch:scope": "lerna run bundle:watch --scope",
"clean": "del-cli \"{node_modules,dist}\" \"packages/*/{node_modules,dist}\" \"e2e/dist\"",
"distro": "run-s clean reinstall build-distro",
"dev": "lerna run dev --stream --scope",
"dev": "lerna run dev --scope",
"lerna-publish": "lerna publish -m \"chore(project): publish %s\"",
"lint": "eslint packages",
"lint:types": "tsc --pretty",
Expand Down
36 changes: 18 additions & 18 deletions packages/form-js-editor/test/spec/FormEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -807,15 +807,12 @@ describe('FormEditor', function() {

await expectSelected('Form_1');

const text1 = formEditor.get('formFieldRegistry').get('Text_1');

// when
const text1 = formEditor.get('formFieldRegistry').get('Text_1');
formEditor.get('selection').set(text1);

await expectSelected('Text_1');

// then
expectSelected('Text_1');
await expectSelected('Text_1');
});

});
Expand Down Expand Up @@ -857,16 +854,18 @@ describe('FormEditor', function() {
await expectSelected('Textfield_1');

// open group to make entry focusable
const group = await screen.getByText('General');
fireEvent.click(group);
const group = screen.getByText('General');
await act(() => fireEvent.click(group));

const input = await screen.getByLabelText('Field label');
const input = screen.getByLabelText('Field label');

// when
input.focus();
await act(() => input.focus());

// then
expect(focusinSpy).to.have.been.called;
await waitFor(() => {
expect(focusinSpy).to.have.been.called;
});
});


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

// open group to make entry focusable
const group = await screen.getByText('General');
fireEvent.click(group);
const group = screen.getByText('General');
await act(() => fireEvent.click(group));

const input = await screen.getByLabelText('Field label');

input.focus();
const input = screen.getByLabelText('Field label');
await act(() => input.focus());

// when
input.blur();
await act(() => input.blur());

// then
expect(focusoutSpy).to.have.been.called;
await waitFor(() => {
expect(focusoutSpy).to.have.been.called;
});
});

});
Expand Down Expand Up @@ -952,7 +952,7 @@ describe('FormEditor', function() {
expect(dragulaDestroyedSpy).not.to.have.been.called;

// when
act(() => formEditor.attachTo(container));
await act(() => formEditor.attachTo(container));

// then
// todo (@skaiir): investigate why this is called twice
Expand Down
13 changes: 7 additions & 6 deletions packages/form-js-playground/test/spec/JSONEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe('JSONEditor', function() {

const cm = editor.getView();

// move cursor to the end
// move cursor to the end of foo
select(cm, 5);

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

describe('autocompletion', function() {

it('should suggest applicable variables', function(done) {
it('should suggest applicable variables', async function() {

// given
const initalValue = 'fooba';
const variables = [ 'foobar', 'baz' ];

const editor = new JSONEditor();
const div = document.createElement('div');
editor.attachTo(div);

editor.setValue(initalValue),
editor.setVariables(variables);

const cm = editor.getView();

// move cursor to the end
// move cursor to the end of fooba
select(cm, 5);

// when
startCompletion(cm);

// then
// update done async
expectEventually(() => {
await expectEventually(() => {
const completions = currentCompletions(cm.state);
expect(completions).to.have.length(1);
expect(completions[0].label).to.have.eql('foobar');
done();
});

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('ExpressionField', function() {
});


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

// given
const field = {
Expand All @@ -46,7 +46,7 @@ describe('ExpressionField', function() {
const onChangeSpy = sinon.spy();

// when
act(() => {
await act(() => {
createExpressionField({ field, onChange: onChangeSpy, services });
});

Expand All @@ -56,7 +56,7 @@ describe('ExpressionField', function() {
});


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

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

// when
act(() => {
await act(() => {
rerender(
<MockFormContext
services={ services }
Expand All @@ -106,7 +106,7 @@ describe('ExpressionField', function() {
});


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

// given
const field = {
Expand All @@ -128,7 +128,7 @@ describe('ExpressionField', function() {
const onChangeSpy = sinon.spy();

// when
act(() => {
await act(() => {
createExpressionField({ field, onChange: onChangeSpy, services });
});

Expand All @@ -138,7 +138,7 @@ describe('ExpressionField', function() {
});


it('should evaluate on presubmit', function() {
it('should evaluate on presubmit', async function() {

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

// when
act(() => {
await act(() => {
services.eventBus.fire('presubmit');
});

Expand Down
Loading

0 comments on commit ed947dc

Please sign in to comment.