Skip to content

Commit bb56232

Browse files
committed
Upgrade all deps; Fix tests; Fix native class compat
1 parent 95f274c commit bb56232

File tree

8 files changed

+684
-3349
lines changed

8 files changed

+684
-3349
lines changed

.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ module.exports = {
1818
},
1919
rules: {
2020
'ember/no-legacy-test-waiters': 'off',
21+
'ember/no-classic-classes': 'off',
22+
'ember/no-classic-components': 'off',
23+
'ember/require-tagless-components': 'off',
24+
'ember/no-computed-properties-in-native-classes': 'off',
25+
'ember/no-actions-hash': 'off',
2126
},
2227
overrides: [
2328
// node files

addon/services/apollo.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,8 @@ function newDataFunc(observable, resultKey, resolve, unsubscribeFn = null) {
116116
export default class ApolloService extends Service {
117117
client = null;
118118

119-
init() {
120-
super.init(...arguments);
119+
constructor(...args) {
120+
super(...args);
121121

122122
this.client = new ApolloClient(this.clientOptions());
123123
}

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@
3737
"test:ember": "ember test"
3838
},
3939
"dependencies": {
40-
"@apollo/client": "^3.2.1",
41-
"@ember/test-waiters": "~3.0.0",
40+
"@apollo/client": "^3.5.10",
41+
"@ember/test-waiters": "~3.0.1",
4242
"@embroider/macros": "^1.5.0",
4343
"@glimmer/tracking": "^1.0.4",
4444
"broccoli-graphql-filter": "^1.0.0",
4545
"ember-auto-import": "^2.4.0",
4646
"ember-cli-babel": "^7.26.11"
4747
},
4848
"devDependencies": {
49-
"@babel/core": "^7.11.6",
49+
"@babel/core": "^7.17.7",
5050
"@ember/optional-features": "^2.0.0",
5151
"@ember/test-helpers": "^2.6.0",
5252
"@embroider/test-setup": "^1.2.0",
@@ -58,9 +58,9 @@
5858
"ember-cli-htmlbars": "^6.0.1",
5959
"ember-cli-inject-live-reload": "^2.1.0",
6060
"ember-cli-terser": "^4.0.2",
61-
"ember-compatibility-helpers": "^1.2.1",
61+
"ember-compatibility-helpers": "^1.2.6",
6262
"ember-disable-prototype-extensions": "^1.1.3",
63-
"ember-fetch": "^8.0.2",
63+
"ember-fetch": "^8.1.1",
6464
"ember-load-initializers": "^2.1.2",
6565
"ember-page-title": "^7.0.0",
6666
"ember-qunit": "^5.1.5",
@@ -75,12 +75,12 @@
7575
"eslint-plugin-node": "^11.1.0",
7676
"eslint-plugin-prettier": "^4.0.0",
7777
"eslint-plugin-qunit": "^7.2.0",
78-
"graphql": "^15.3.0",
79-
"graphql-tag": "^2.11.0",
78+
"graphql": "^15.8.0",
79+
"graphql-tag": "^2.12.6",
8080
"graphql-tools": "^4.0.8",
8181
"loader.js": "^4.7.0",
8282
"npm-run-all": "^4.1.5",
83-
"pretender": "^3.4.3",
83+
"pretender": "^3.4.7",
8484
"prettier": "^2.5.1",
8585
"qunit": "^2.18.0",
8686
"qunit-dom": "^2.0.0",

tests/acceptance/query-and-unsubscribe-test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { module, test } from 'qunit';
22
import { setupApplicationTest } from 'dummy/tests/helpers/setup';
33
import { addResolveFunctionsToSchema } from 'graphql-tools';
44
import { click, currentURL, visit } from '@ember/test-helpers';
5-
import { run } from '@ember/runloop';
65

76
module('Acceptance | main', function (hooks) {
87
setupApplicationTest(hooks);
@@ -56,9 +55,7 @@ module('Acceptance | main', function (hooks) {
5655
let queries = getQueries();
5756
assert.ok(Object.keys(queries).length, 'there is an active watchQuery');
5857

59-
run(async function () {
60-
await click('.add-review');
61-
});
58+
await click('.add-review');
6259

6360
// Now that we've gone to a route with no queries, the RouteQueryManager
6461
// should have unsubscribed from the watchQuery and there should be no

tests/acceptance/watch-query-test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ module('Acceptance | watch query', function (hooks) {
5555
'Rambo: Last Blood',
5656
'correct mutation title is passed in'
5757
);
58+
movie.title = title;
5859
return Object.assign({}, movie, { title });
5960
},
6061
},
Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
11
<h2>Movie Detail</h2>
22

3-
<LinkTo @route="index">
3+
<LinkTo @route='index'>
44
Back
55
</LinkTo>
66

7-
<div class="actions-menu">
7+
<div class='actions-menu'>
88
<button
9-
{{action "changeTitle" this.model.movie.id "Rambo: Last Blood"}}
10-
class="button change-movie-title"
11-
type="button"
9+
{{action 'changeTitle' @model.movie.id 'Rambo: Last Blood'}}
10+
class='button change-movie-title'
11+
type='button'
1212
>
1313
Change Movie Title
1414
</button>
1515

1616
<button
17-
{{action "refetchUsingObservable" this.model}}
18-
class="button refetch-data-using-observable"
19-
type="button"
17+
{{action 'refetchUsingObservable' @model}}
18+
class='button refetch-data-using-observable'
19+
type='button'
2020
>
2121
Refetch (using observable)
2222
</button>
2323

2424
<button
25-
{{action "refreshUsingRoute"}}
26-
class="button refresh-data"
27-
type="button"
25+
{{action 'refreshUsingRoute'}}
26+
class='button refresh-data'
27+
type='button'
2828
>
2929
Refetch (using route refresh())
3030
</button>
3131

32-
<LinkTo
33-
@route="new-review"
34-
class="button add-review"
35-
>
32+
<LinkTo @route='new-review' class='button add-review'>
3633
Add Review
3734
</LinkTo>
3835
</div>
3936

40-
<MovieDetail @movie={{this.model.movie}} />
37+
<MovieDetail @movie={{@model.movie}} />
4138

42-
<div class="movie-reviews">
39+
<div class='movie-reviews'>
4340
{{#each this.reviews as |review|}}
4441
<p>{{review.stars}} stars</p>
4542
{{else}}
4643
<p>No reviews</p>
4744
{{/each}}
48-
</div>
45+
</div>

tests/unit/-private/query-manager-hooks-component-test.js

Lines changed: 74 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -31,77 +31,31 @@ let OverriddenApollo = class extends ApolloService {
3131
}
3232
};
3333

34-
module('Unit | queryManager | Setup Hooks in Ember Components', function (
35-
hooks
36-
) {
37-
setupTest(hooks);
38-
39-
hooks.beforeEach(function (assert) {
40-
assertDeepEqual = assert.deepEqual.bind(assert);
41-
unsubscribeCalled = 0;
42-
43-
this.subject = function () {
44-
this.owner.register('service:overridden-apollo', OverriddenApollo);
45-
this.owner.register('component:test-component', TestObject);
46-
return this.owner.lookup('component:test-component');
47-
};
48-
});
49-
50-
test('it unsubscribes from any watchQuery subscriptions', function (assert) {
51-
assert.expect(5);
52-
53-
TestObject = EmberComponent.extend({
54-
apollo: queryManager({ service: 'overridden-apollo' }),
55-
willDestroyElement() {
56-
assert.ok(true, 'Should have called the original willDestroyElement');
57-
},
58-
});
59-
60-
let subject = this.subject();
61-
assert.equal(unsubscribeCalled, 0, 'should have been initialized with 0');
62-
63-
subject.apollo.watchQuery({ query: 'fakeQuery' });
64-
subject.apollo.watchQuery({ query: 'fakeQuery' });
65-
66-
subject.willDestroyElement();
67-
68-
assert.equal(
69-
unsubscribeCalled,
70-
2,
71-
'_apolloUnsubscribe() was called once per watchQuery'
72-
);
73-
});
74-
75-
test('it unsubscribes from any subscriptions', async function (assert) {
76-
TestObject = EmberComponent.extend({
77-
apollo: queryManager({ service: 'overridden-apollo' }),
34+
module(
35+
'Unit | queryManager | Setup Hooks in Ember Components',
36+
function (hooks) {
37+
setupTest(hooks);
38+
39+
hooks.beforeEach(function (assert) {
40+
assertDeepEqual = assert.deepEqual.bind(assert);
41+
unsubscribeCalled = 0;
42+
43+
this.subject = function () {
44+
this.owner.register('service:overridden-apollo', OverriddenApollo);
45+
this.owner.register('component:test-component', TestObject);
46+
return this.owner.lookup('component:test-component');
47+
};
7848
});
7949

80-
let subject = this.subject();
81-
assert.equal(unsubscribeCalled, 0, 'should have been initialized with 0');
82-
83-
subject.apollo.subscribe({ query: 'fakeSubscription' });
84-
subject.apollo.subscribe({ query: 'fakeSubscription' });
85-
86-
subject.willDestroyElement();
87-
88-
assert.equal(
89-
unsubscribeCalled,
90-
2,
91-
'_apolloUnsubscribe() was called once per subscribe'
92-
);
93-
});
94-
95-
if (gte('3.10.0')) {
96-
test('it works using decorator syntax', function (assert) {
50+
test('it unsubscribes from any watchQuery subscriptions', function (assert) {
9751
assert.expect(5);
98-
TestObject = class MyTestClassOjbect extends EmberComponent {
99-
@queryManager({ service: 'overridden-apollo' }) apollo;
10052

53+
TestObject = EmberComponent.extend({
54+
apollo: queryManager({ service: 'overridden-apollo' }),
10155
willDestroyElement() {
10256
assert.ok(true, 'Should have called the original willDestroyElement');
103-
}
104-
};
57+
},
58+
});
10559

10660
let subject = this.subject();
10761
assert.equal(unsubscribeCalled, 0, 'should have been initialized with 0');
@@ -117,5 +71,59 @@ module('Unit | queryManager | Setup Hooks in Ember Components', function (
11771
'_apolloUnsubscribe() was called once per watchQuery'
11872
);
11973
});
74+
75+
test('it unsubscribes from any subscriptions', async function (assert) {
76+
TestObject = EmberComponent.extend({
77+
apollo: queryManager({ service: 'overridden-apollo' }),
78+
});
79+
80+
let subject = this.subject();
81+
assert.equal(unsubscribeCalled, 0, 'should have been initialized with 0');
82+
83+
subject.apollo.subscribe({ query: 'fakeSubscription' });
84+
subject.apollo.subscribe({ query: 'fakeSubscription' });
85+
86+
subject.willDestroyElement();
87+
88+
assert.equal(
89+
unsubscribeCalled,
90+
2,
91+
'_apolloUnsubscribe() was called once per subscribe'
92+
);
93+
});
94+
95+
if (gte('3.10.0')) {
96+
test('it works using decorator syntax', function (assert) {
97+
assert.expect(5);
98+
TestObject = class MyTestClassOjbect extends EmberComponent {
99+
@queryManager({ service: 'overridden-apollo' }) apollo;
100+
101+
willDestroyElement() {
102+
assert.ok(
103+
true,
104+
'Should have called the original willDestroyElement'
105+
);
106+
}
107+
};
108+
109+
let subject = this.subject();
110+
assert.equal(
111+
unsubscribeCalled,
112+
0,
113+
'should have been initialized with 0'
114+
);
115+
116+
subject.apollo.watchQuery({ query: 'fakeQuery' });
117+
subject.apollo.watchQuery({ query: 'fakeQuery' });
118+
119+
subject.willDestroyElement();
120+
121+
assert.equal(
122+
unsubscribeCalled,
123+
2,
124+
'_apolloUnsubscribe() was called once per watchQuery'
125+
);
126+
});
127+
}
120128
}
121-
});
129+
);

0 commit comments

Comments
 (0)