@universal-ember/test-support 0.0.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visit-all.d.ts","sourceRoot":"","sources":["../../src/routing/visit-all.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"visit-all.d.ts","sourceRoot":"","sources":["../../src/routing/visit-all.ts"],"names":[],"mappings":"AAsBA,wBAAsB,aAAa,kBAyElC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assert as assert$1 } from '@ember/debug';
|
|
2
|
-
import { visit, currentURL, find, click, findAll } from '@ember/test-helpers';
|
|
2
|
+
import { visit, getContext, currentURL, find, click, findAll } from '@ember/test-helpers';
|
|
3
3
|
import QUnit from 'qunit';
|
|
4
4
|
|
|
5
5
|
function findInAppLinks() {
|
|
@@ -15,6 +15,9 @@ async function visitAllLinks() {
|
|
|
15
15
|
await visit(returnTo);
|
|
16
16
|
const inAppLinks = findInAppLinks();
|
|
17
17
|
const queue = [...inAppLinks];
|
|
18
|
+
const ctx = getContext();
|
|
19
|
+
const router = ctx?.owner?.lookup('service:router');
|
|
20
|
+
assert$1(`Could not find the router service`, router);
|
|
18
21
|
while (queue.length > 0) {
|
|
19
22
|
const toVisit = queue.shift();
|
|
20
23
|
assert$1(`Queue entries cannot be falsey`, toVisit);
|
|
@@ -22,8 +25,26 @@ async function visitAllLinks() {
|
|
|
22
25
|
returnTo = toVisit.changeReturnTo;
|
|
23
26
|
continue;
|
|
24
27
|
}
|
|
25
|
-
|
|
28
|
+
|
|
29
|
+
// In-page links are on the page we're already on.
|
|
30
|
+
// As long as we haven't already encountered an error,
|
|
31
|
+
// this is silly to check.
|
|
32
|
+
if (toVisit.startsWith('#')) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const [nonHashPart] = toVisit.split('#');
|
|
36
|
+
|
|
37
|
+
// This was our first page, we've already been here
|
|
38
|
+
if (nonHashPart === '/') {
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
const key = `${currentURL()}::${nonHashPart}`;
|
|
26
42
|
if (visited.has(key)) continue;
|
|
43
|
+
const result = router.recognize(toVisit);
|
|
44
|
+
if (!result) {
|
|
45
|
+
assert.ok(true, `${toVisit} on page ${returnTo} is not recognized by this app and will be skipped`);
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
27
48
|
await visit(returnTo);
|
|
28
49
|
const link = find(`a[href="${toVisit}"]`);
|
|
29
50
|
assert$1(`link exists with ${toVisit}`, link);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"visit-all.js","sources":["../../src/routing/visit-all.ts"],"sourcesContent":["import { assert as debugAssert } from '@ember/debug';\nimport {
|
|
1
|
+
{"version":3,"file":"visit-all.js","sources":["../../src/routing/visit-all.ts"],"sourcesContent":["import { assert as debugAssert } from '@ember/debug';\nimport {\n visit,\n find,\n getContext,\n click,\n currentURL,\n findAll,\n} from '@ember/test-helpers';\nimport QUnit from 'qunit';\nimport type Owner from '@ember/owner';\nimport type RouterService from '@ember/routing/router-service';\n\nfunction findInAppLinks(): string[] {\n return (findAll('a')\n ?.map((link) => link.getAttribute('href'))\n ?.filter((href) => !href?.startsWith('http'))\n .filter(Boolean) || []) as string[];\n}\n\nconst assert = QUnit.assert;\n\nexport async function visitAllLinks() {\n /**\n * string of \"on::target\"\n */\n const visited = new Set();\n let returnTo = '/';\n\n await visit(returnTo);\n\n const inAppLinks = findInAppLinks();\n const queue: (string | { changeReturnTo: string })[] = [...inAppLinks];\n\n const ctx = getContext() as unknown as { owner: Owner };\n const router = ctx?.owner?.lookup('service:router') as RouterService;\n\n debugAssert(`Could not find the router service`, router);\n\n while (queue.length > 0) {\n const toVisit = queue.shift();\n\n debugAssert(`Queue entries cannot be falsey`, toVisit);\n\n if (typeof toVisit === 'object' && toVisit !== null) {\n returnTo = toVisit.changeReturnTo;\n continue;\n }\n\n // In-page links are on the page we're already on.\n // As long as we haven't already encountered an error,\n // this is silly to check.\n if (toVisit.startsWith('#')) {\n continue;\n }\n\n const [nonHashPart] = toVisit.split('#');\n\n // This was our first page, we've already been here\n if (nonHashPart === '/') {\n continue;\n }\n\n const key = `${currentURL()}::${nonHashPart}`;\n\n if (visited.has(key)) continue;\n\n const result = router.recognize(toVisit);\n\n if (!result) {\n assert.ok(\n true,\n `${toVisit} on page ${returnTo} is not recognized by this app and will be skipped`,\n );\n continue;\n }\n\n await visit(returnTo);\n\n const link = find(`a[href=\"${toVisit}\"]`);\n\n debugAssert(`link exists with ${toVisit}`, link);\n\n await click(link);\n assert.ok(\n currentURL().startsWith(toVisit),\n `Navigation was successful: to:${toVisit}, from:${returnTo}`,\n );\n visited.add(key);\n\n const links = findInAppLinks();\n\n queue.push({ changeReturnTo: currentURL() });\n queue.push(...links);\n }\n}\n"],"names":["findInAppLinks","findAll","map","link","getAttribute","filter","href","startsWith","Boolean","assert","QUnit","visitAllLinks","visited","Set","returnTo","visit","inAppLinks","queue","ctx","getContext","router","owner","lookup","debugAssert","length","toVisit","shift","changeReturnTo","nonHashPart","split","key","currentURL","has","result","recognize","ok","find","click","add","links","push"],"mappings":";;;;AAaA,SAASA,cAAcA,GAAa;AAClC,EAAA,OAAQC,OAAO,CAAC,GAAG,CAAC,EAChBC,GAAG,CAAEC,IAAI,IAAKA,IAAI,CAACC,YAAY,CAAC,MAAM,CAAC,CAAC,EACxCC,MAAM,CAAEC,IAAI,IAAK,CAACA,IAAI,EAAEC,UAAU,CAAC,MAAM,CAAC,CAAC,CAC5CF,MAAM,CAACG,OAAO,CAAC,IAAI,EAAE,CAAA;AAC1B,CAAA;AAEA,MAAMC,MAAM,GAAGC,KAAK,CAACD,MAAM,CAAA;AAEpB,eAAeE,aAAaA,GAAG;AACpC;AACF;AACA;AACE,EAAA,MAAMC,OAAO,GAAG,IAAIC,GAAG,EAAE,CAAA;EACzB,IAAIC,QAAQ,GAAG,GAAG,CA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MAAM,EAAE;MACXxB,MAAM,CAAC0B,EAAE,CACP,IAAI,EACH,GAAEV,OAAQ,CAAA,SAAA,EAAWX,QAAS,CAAA,kDAAA,CACjC,CAAC,CAAA;AACD,MAAA,SAAA;AACF,KAAA;IAEA,MAAMC,KAAK,CAACD,QAAQ,CAAC,CAAA;AAErB,IAAA,MAAMX,IAAI,GAAGiC,IAAI,CAAE,CAAUX,QAAAA,EAAAA,OAAQ,IAAG,CAAC,CAAA;AAEzCF,IAAAA,QAAW,CAAE,CAAmBE,iBAAAA,EAAAA,OAAQ,CAAC,CAAA,EAAEtB,IAAI,CAAC,CAAA;IAEhD,MAAMkC,KAAK,CAAClC,IAAI,CAAC,CAAA;AACjBM,IAAAA,MAAM,CAAC0B,EAAE,CACPJ,UAAU,EAAE,CAACxB,UAAU,CAACkB,OAAO,CAAC,EAC/B,CAAA,8BAAA,EAAgCA,OAAQ,CAASX,OAAAA,EAAAA,QAAS,EAC7D,CAAC,CAAA;AACDF,IAAAA,OAAO,CAAC0B,GAAG,CAACR,GAAG,CAAC,CAAA;AAEhB,IAAA,MAAMS,KAAK,GAAGvC,cAAc,EAAE,CAAA;IAE9BiB,KAAK,CAACuB,IAAI,CAAC;MAAEb,cAAc,EAAEI,UAAU,EAAC;AAAE,KAAC,CAAC,CAAA;AAC5Cd,IAAAA,KAAK,CAACuB,IAAI,CAAC,GAAGD,KAAK,CAAC,CAAA;AACtB,GAAA;AACF;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@universal-ember/test-support",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "The default blueprint for Embroider v2 addons.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -31,23 +31,6 @@
|
|
|
31
31
|
"declarations",
|
|
32
32
|
"dist"
|
|
33
33
|
],
|
|
34
|
-
"scripts": {
|
|
35
|
-
"build": "concurrently 'npm:build:*'",
|
|
36
|
-
"build:js": "rollup --config",
|
|
37
|
-
"build:types": "glint --declaration",
|
|
38
|
-
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
39
|
-
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
40
|
-
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
41
|
-
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
42
|
-
"lint:js": "eslint . --cache",
|
|
43
|
-
"lint:js:fix": "eslint . --fix",
|
|
44
|
-
"lint:types": "glint",
|
|
45
|
-
"prepack": "rollup --config",
|
|
46
|
-
"start": "concurrently 'npm:start:*'",
|
|
47
|
-
"start:js": "rollup --config --watch --no-watch.clearScreen",
|
|
48
|
-
"start:types": "glint --declaration --watch",
|
|
49
|
-
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
|
|
50
|
-
},
|
|
51
34
|
"dependencies": {
|
|
52
35
|
"@ember/test-helpers": "^3.2.1",
|
|
53
36
|
"@embroider/addon-shim": "^1.8.7",
|
|
@@ -117,5 +100,21 @@
|
|
|
117
100
|
},
|
|
118
101
|
"peerDependencies": {
|
|
119
102
|
"qunit": "^2.20.1"
|
|
103
|
+
},
|
|
104
|
+
"scripts": {
|
|
105
|
+
"build": "concurrently 'npm:build:*'",
|
|
106
|
+
"build:js": "rollup --config",
|
|
107
|
+
"build:types": "glint --declaration",
|
|
108
|
+
"lint": "concurrently 'npm:lint:*(!fix)' --names 'lint:'",
|
|
109
|
+
"lint:fix": "concurrently 'npm:lint:*:fix' --names 'fix:'",
|
|
110
|
+
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
|
|
111
|
+
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
|
|
112
|
+
"lint:js": "eslint . --cache",
|
|
113
|
+
"lint:js:fix": "eslint . --fix",
|
|
114
|
+
"lint:types": "glint",
|
|
115
|
+
"start": "concurrently 'npm:start:*'",
|
|
116
|
+
"start:js": "rollup --config --watch --no-watch.clearScreen",
|
|
117
|
+
"start:types": "glint --declaration --watch",
|
|
118
|
+
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
|
|
120
119
|
}
|
|
121
|
-
}
|
|
120
|
+
}
|