Skip to content

Commit 3216502

Browse files
committed
fix coverage of *.vue files
1 parent 193a260 commit 3216502

26 files changed

+1243
-4204
lines changed

.github/workflows/test-unit.yml

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -292,22 +292,26 @@ jobs:
292292
restore-keys: |
293293
${{ runner.os }}-composer-
294294
295-
- name: Install JS dependencies (only for Slow)
296-
if: matrix.type == 'Chrome Slow'
297-
run: |
298-
mv public public.orig
299-
mkdir public public/css public/external
300-
cp public.orig/.gitattributes public
301-
cp public.orig/.gitignore public
302-
cp public.orig/logo.png public
303-
cp public.orig/css/agileui.less public/css
304-
cp public.orig/external/.gitignore public/external
305-
cp public.orig/external/package.json public/external
306-
cp public.orig/external/package-lock.json public/external
307-
cp public.orig/external/postinstall.js public/external
308-
npm install --loglevel=error -g pug-cli less less-plugin-clean-css uglify-js
309-
(cd js && npm ci --loglevel=error)
310-
(cd public/external && npm ci --loglevel=error && git clean -dxfq .)
295+
- name: Install JS dependencies (only for coverage or Slow)
296+
if: env.LOG_COVERAGE || matrix.type == 'Chrome Slow'
297+
run: |
298+
if [ -n "$LOG_COVERAGE" ]; then
299+
(cd js && npm install --package-lock-only --save-dev babel-plugin-istanbul && npm ci --loglevel=error)
300+
else
301+
mv public public.orig
302+
mkdir public public/css public/external
303+
cp public.orig/.gitattributes public
304+
cp public.orig/.gitignore public
305+
cp public.orig/logo.png public
306+
cp public.orig/css/agileui.less public/css
307+
cp public.orig/external/.gitignore public/external
308+
cp public.orig/external/package.json public/external
309+
cp public.orig/external/package-lock.json public/external
310+
cp public.orig/external/postinstall.js public/external
311+
npm install --loglevel=error -g pug-cli less less-plugin-clean-css uglify-js
312+
(cd js && npm ci --loglevel=error)
313+
(cd public/external && npm ci --loglevel=error && git clean -dxfq .)
314+
fi
311315
312316
- name: Lint JS files (only for Slow)
313317
if: matrix.type == 'Chrome Slow'
@@ -326,10 +330,20 @@ jobs:
326330
run: |
327331
lessc public/css/agileui.less public/css/agileui.min.css --clean-css="--s1 --advanced" --source-map
328332
329-
- name: Compile JS files (only for Slow)
330-
if: matrix.type == 'Chrome Slow'
331-
run: |
332-
(cd js && npm run build)
333+
- name: Compile JS files (only for coverage or Slow)
334+
if: env.LOG_COVERAGE || matrix.type == 'Chrome Slow'
335+
run: |
336+
if [ -n "$LOG_COVERAGE" ]; then
337+
rm -r public/js
338+
(cd js && ISTANBUL_COVERAGE=1 npm run build)
339+
else
340+
# fix webpack build repeatability
341+
# https://github.com/vuejs/vue-loader/blob/v17.0.1/src/index.ts#L284 should be fine,
342+
# the import itself is relativized, but the variable (generated by webpack) is not
343+
# TODO submit webpack GH issue
344+
sed -i -E 's~(import exportComponent from )\$\{exportHelperPath\}(`;)~\1'"'"'vue-loader/dist/exportHelper.js'"'"'\2~' js/node_modules/vue-loader/dist/index.js
345+
(cd js && npm run build)
346+
fi
333347
334348
- name: Diff compiled files (only for Slow)
335349
if: matrix.type == 'Chrome Slow'
@@ -338,13 +352,6 @@ jobs:
338352
diff -ru template.orig template
339353
rm -r public.orig template.orig
340354
341-
- name: Instrument & recompile JS files (only for coverage)
342-
if: env.LOG_COVERAGE
343-
run: |
344-
rm -r public/js
345-
(cd js && npm install --package-lock-only --save-dev nyc && npm ci --loglevel=error)
346-
(cd js && npx nyc instrument --in-place . && npx webpack --env production)
347-
348355
- name: Install PHP dependencies
349356
run: |
350357
composer remove --no-interaction --no-update phpunit/phpunit johnkary/phpunit-speedtrap --dev

js/babel.config.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
/**
2-
* Babel configuration file.
3-
* targets browser from Browserlist integration query.
4-
*
5-
* @type {Array.<Array.<*>>}
6-
*/
7-
const presets = [
8-
[
9-
'@babel/env',
10-
{
11-
targets: '> 1%, not dead',
12-
corejs: { version: '3.6', proposals: true },
13-
useBuiltIns: 'usage',
14-
},
15-
],
16-
{
17-
plugins: ['@babel/plugin-transform-runtime'],
18-
},
19-
];
1+
module.exports = (api) => {
2+
const isCoverage = !!process.env.ISTANBUL_COVERAGE;
3+
api.cache.using(() => isCoverage);
204

21-
module.exports = { presets: presets };
5+
return {
6+
presets: [
7+
[
8+
'@babel/env',
9+
{
10+
targets: '> 1%, not dead',
11+
corejs: { version: '3.9999', proposals: true },
12+
useBuiltIns: 'usage',
13+
},
14+
],
15+
],
16+
plugins: [
17+
...(isCoverage ? [[
18+
'babel-plugin-istanbul',
19+
{
20+
extension: ['.js', '.vue'],
21+
},
22+
]] : []),
23+
'@babel/plugin-transform-runtime',
24+
],
25+
};
26+
};

js/src/vue-components/query-builder/fomantic-ui-group.component.vue

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</select>
3131
</div>
3232
<div class="item">
33-
<div class="rule-actions ">
33+
<div class="rule-actions">
3434
<div>
3535
<SuiDropdown
3636
:text="labels.addRule"
@@ -76,11 +76,11 @@
7676
</template>
7777

7878
<script>
79-
import QueryBuilderGroup from 'vue-query-builder/src/components/QueryBuilderGroup.vue';
79+
import VueQueryBuilderGroup from 'vue-query-builder/src/components/QueryBuilderGroup.vue';
8080
8181
export default {
8282
name: 'QueryBuilderGroup',
83-
extends: QueryBuilderGroup,
83+
extends: VueQueryBuilderGroup,
8484
data: function () {
8585
return {
8686
selectedSuiRule: null,
@@ -113,6 +113,16 @@ export default {
113113
</script>
114114

115115
<style>
116+
.vue-query-builder .vqb-group .rule-actions {
117+
margin-bottom: 0px;
118+
}
119+
120+
.vue-query-builder .vqb-rule {
121+
margin-top: 0px;
122+
margin-bottom: 0px;
123+
padding: 0px;
124+
}
125+
116126
.atk-qb-select, .ui.form select.atk-qb-select {
117127
padding: 2px 6px 4px 4px;
118128
}

js/src/vue-components/query-builder/fomantic-ui-rule.component.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
</template>
121121

122122
<script>
123-
import QueryBuilderRule from 'vue-query-builder/src/components/QueryBuilderRule.vue';
123+
import VueQueryBuilderRule from 'vue-query-builder/src/components/QueryBuilderRule.vue';
124124
import AtkDatePicker from '../share/atk-date-picker';
125125
import AtkLookup from '../share/atk-lookup';
126126
@@ -129,7 +129,7 @@ export default {
129129
AtkDatePicker: AtkDatePicker,
130130
AtkLookup: AtkLookup,
131131
},
132-
extends: QueryBuilderRule,
132+
extends: VueQueryBuilderRule,
133133
inject: ['getRootData'],
134134
data: function () {
135135
return {};

js/src/vue-components/query-builder/query-builder.component.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</template>
3030

3131
<script>
32-
import VueQueryBuilder from 'vue-query-builder';
32+
import VueQueryBuilder from 'vue-query-builder/src/VueQueryBuilder.vue';
3333
import QueryBuilderGroup from './fomantic-ui-group.component.vue';
3434
import QueryBuilderRule from './fomantic-ui-rule.component.vue';
3535

js/webpack.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ module.exports = (env) => {
9898
'node_modules',
9999
],
100100
extensions: [
101-
'.json',
102101
'.js',
102+
'.vue',
103103
],
104104
},
105105
plugins: [

public/js/atk-vue-multiline.js

Lines changed: 31 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/atk-vue-multiline.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)