Skip to content

Commit ee87872

Browse files
author
Baylee Swenson
committed
Fix failing tests
1 parent b1511c5 commit ee87872

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

lib/handbook/addon/docs/components/form-controls/demo-default/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<DocsDemo as |demo|>
22
<demo.example @name='form-controls.demo-default.hbs'>
3-
<form {{action this.submit on='submit'}}>
3+
<form {{on 'submit' (prevent-default this.submit)}}>
44
<FormControls
55
@changeset={{this.changeset}}
66
as |form|

lib/handbook/addon/docs/components/form-controls/demo-disabled/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<DocsDemo as |demo|>
22
<demo.example @name='form-controls.demo-disabled.hbs'>
3-
<form {{action this.submit on='submit'}}>
3+
<form {{on 'submit' (prevent-default this.submit)}}>
44
<FormControls
55
@changeset={{this.changeset}}
66
@disabled={{this.disabled}}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
"ember-decorators": "^3.0.0",
131131
"ember-diff-attrs": "^0.2.1",
132132
"ember-engines": "https://github.com/cos-forks/ember-engines#v0.5.20+cos1",
133+
"ember-event-helpers": "^0.1.0",
133134
"ember-export-application-global": "^2.0.0",
134135
"ember-faker": "^1.2.1",
135136
"ember-feature-flags": "^5.0.0",

tests/integration/components/form-controls/component-test.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import { render } from '@ember/test-helpers';
1+
import { click, render } from '@ember/test-helpers';
22
import a11yAudit from 'ember-a11y-testing/test-support/audit';
33
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
44
import { setupRenderingTest } from 'ember-qunit';
55
import hbs from 'htmlbars-inline-precompile';
66
import { module, test } from 'qunit';
77

8-
import { click } from 'ember-osf-web/tests/helpers';
98
import buildChangeset from 'ember-osf-web/utils/build-changeset';
109

1110
import { nodeValidation } from './validation';
@@ -15,6 +14,7 @@ module('Integration | Component | form-controls', hooks => {
1514
setupMirage(hooks);
1615

1716
test('it renders', async function(assert) {
17+
assert.ok(true);
1818
const model = {
1919
title: '',
2020
description: '',
@@ -53,16 +53,15 @@ module('Integration | Component | form-controls', hooks => {
5353
const changeset = buildChangeset(model, nodeValidation);
5454
this.set('changeset', changeset);
5555

56-
function submit() {
57-
// @ts-ignore 'changeset-validations aren't set up correctly for this to typecheck'
58-
changeset.validate();
59-
}
60-
this.set('submit', submit);
6156
this.set('titleValue', '');
6257
this.set('descriptionValue', '');
58+
this.set('submit', () => {
59+
changeset.validate();
60+
assert.ok(true);
61+
});
6362

6463
await render(hbs`
65-
<form data-test-form {{on 'submit' this.submit}}>
64+
<form data-test-form {{on 'submit' (prevent-default this.submit)}}>
6665
<FormControls @changeset={{this.changeset}} as |form| >
6766
<form.text
6867
data-test-title-input
@@ -87,7 +86,7 @@ module('Integration | Component | form-controls', hooks => {
8786
</form>
8887
`);
8988
assert.dom('[data-test-form]').exists();
90-
await click('[data-analytics-name="submit"]');
89+
await click('[data-test-submit-button]');
9190
// Check that input has a validation message
9291
assert.dom('[data-test-title-input] .help-block').exists({ count: 1 });
9392
assert.dom('[data-test-description-input] .help-block').exists({ count: 1 });

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7634,6 +7634,13 @@ ember-diff-attrs@^0.2.1:
76347634
ember-cli-version-checker "^2.1.0"
76357635
lodash "^4.12.0"
76367636

7637+
ember-event-helpers@^0.1.0:
7638+
version "0.1.0"
7639+
resolved "https://registry.yarnpkg.com/ember-event-helpers/-/ember-event-helpers-0.1.0.tgz#4b7f49f136b660df21731a9e0329507c0816438e"
7640+
integrity sha512-JdsYPmW0g0LLKmdRGxS9lRIdtB1Swc7Asr0XmUwhkjbFY40bfB0wlQ8P2yA3YLqbP/ToShBitN62t9Cy4PTazQ==
7641+
dependencies:
7642+
ember-cli-babel "^7.7.3"
7643+
76377644
ember-export-application-global@^2.0.0:
76387645
version "2.0.0"
76397646
resolved "https://registry.yarnpkg.com/ember-export-application-global/-/ember-export-application-global-2.0.0.tgz#8d6d7619ac8a1a3f8c43003549eb21ebed685bd2"

0 commit comments

Comments
 (0)