question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

closure action getting nowhere?

See original GitHub issue

Hey,

for the past 2 days I have been trying to migrate to the new set of APIs but cannot figure this out.

A bit of context first:

  • just migrated from ember v2.18 to v3.12 with the major changes being:

    • closure actions (used sendAction everywhere)
    • making sure that computed properties don’t get overwritten
  • app uses pods structure

  • app uses jquery

  • node v12.7.0, ember-cli v3.10.1, ember-qunit v4.5.0

  • tests were passing fine with v2.18 and with v3.12 (also tried v3.8, v3.10 and v3.11) before I updated ember-qunit to latest.

Now, my issue is with acceptance tests. Not that the tests are not running at all, but fail.

Here’s my code:

login route:

export default Route.extend({
	session: service(),

	actions: {
		login() {
			// login logic here, but it doesn't reach the second time.
		}
	}
});

login template.hbs (simplified):

{{#m-form
	action=(action send "login")
}}
	{{m-input
		type="email"

		name="email"
		value=model.email
		placeholder="login.email"
		autofocus="autofocus"

		disabled=model.freezed
	}}
	<br />
	{{m-input
		type="password"

		name="password"
		value=model.password
		placeholder="login.password"

		disabled=model.freezed
	}}
	<br />
	{{m-button
		type="submit"

		value="login.log_in"
		asBlock=true
		size="superman"
		color="red"

		disabled=model.freezed
		loading=model.freezed
	}}
{{/m-form}}

m-input is using {{input}} under the hood.

m-form/component.js:

export default Component.extend({
	tagName: 'form',

	classNames: ['form'],
	attributeBindings: ['autocomplete'],

	autocomplete: 'off',

	action: null,

	submit(event) {
		event.stopPropagation();
		event.preventDefault();

		if(!this.action) {
			return;
		}
		this.action(); // this is being fired!
	}
});
const user = 'someone@some-address.io';
const password = 'someoneio';

module('Login', (hooks) => {
	setupApplicationAcceptanceTest(hooks); // clears up the `localStorage` afterEach on top of `setupApplicationTest`.

	test('User should not be able to login if email is missing', async (assert) => {
		await visit('/actions/login');

		await fillIn('input[name="email"]', '');
		await fillIn('input[name="password"]', password);
		await click('button[type="submit"]');

		await checkValidationErrorCount('[data-test="field-email"]', 1);

		assert.equal(currentRouteName(), 'login');
	});

	test('User should not be able to login is password is missing', async (assert) => {
		await visit('/actions/login');

		await fillIn('input[name="email"]', user);
		await fillIn('input[name="password"]', '');
		await click('button[type="submit"]');

		await checkValidationErrorCount('[data-test="field-password"]', 1);

		assert.equal(currentRouteName(), 'login');
	});

	test('User should not be able to login if email or password is invalid', async (assert) => {
		await visit('/actions/login');

		await fillIn('input[name="email"]', user)
		await fillIn('input[name="password"]', 'invalid')
		await click('button[type="submit"]');

		assert.equal(currentRouteName(), 'login');
	});

	test('User should be able to login into application', async (assert) => {
		await visit('/actions/login');

		await fillIn('input[name="email"]', user);
		await fillIn('input[name="password"]', password);
		await click('button[type="submit"]');

		assert.equal(currentRouteName(), 'dashboard.index');
	});
});

The tests run properly and as intended up to the firing of action from m-form’s submit event. It gets to this.action() and that is being fired for the first test but it never gets to the route’s login action for the following ones.

No error or warning.

I tried to reproduce this separately but seems to work fine on it’s own. I can put that up if it will help get this somewhere.

Any thoughts?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rwjbluecommented, Aug 6, 2019

Put a breakpoint on this line:

        return (0, _runloop.join)(self, fn, ...processArgs(args));

That fn will get invoked, and should be the action being ran. Is it what you expect? I would expect fn to basically be the controller’s send method…

0reactions
rwjbluecommented, Aug 7, 2019

Glad you figured it out!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Get Closure When You Have None In 5 Steps
Provide closure for yourself by listening to the other person's PATTERNS (which are made up of their actions) instead of listening to empty...
Read more >
How to Get Closure | Psychology Today
Closure isn't always what you think it is. · 1. Healthy boundaries. · 2. Get a life. · 3. Love back bigger. ·...
Read more >
If You Want Closure After a Breakup: 6 Things You Need to ...
Heartbroken people often believe that they will get the closure they so desperately desire, if only they could make sense of why.
Read more >
Closure is an illusion - Living with Limerence
The only reliable way to get closure is to accept that it is not a deal between you and LO; it is a...
Read more >
How to end a relationship properly and gain closure, so that ...
It isn't right to stay in a relationship that has no love and is going nowhere. Instead of trying to shy away from...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found