Skip to content

Commit 32a6087

Browse files
committed
test: Fix test and add CI job
Signed-off-by: Louis Chemineau <louis@chmn.me>
1 parent 0cb0984 commit 32a6087

File tree

2 files changed

+144
-30
lines changed

2 files changed

+144
-30
lines changed

.github/workflows/node-test.yml

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# This workflow is provided via the organization template repository
2+
#
3+
# https://github.com/nextcloud/.github
4+
# https://docs.github.com/en/actions/learn-github-actions/sharing-workflows-with-your-organization
5+
#
6+
# SPDX-FileCopyrightText: 2023-2024 Nextcloud GmbH and Nextcloud contributors
7+
# SPDX-License-Identifier: MIT
8+
9+
name: Node tests
10+
11+
on:
12+
pull_request:
13+
push:
14+
branches:
15+
- main
16+
- master
17+
- stable*
18+
19+
permissions:
20+
contents: read
21+
22+
concurrency:
23+
group: node-tests-${{ github.head_ref || github.run_id }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
changes:
28+
runs-on: ubuntu-latest-low
29+
permissions:
30+
contents: read
31+
pull-requests: read
32+
33+
outputs:
34+
src: ${{ steps.changes.outputs.src}}
35+
36+
steps:
37+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
38+
id: changes
39+
continue-on-error: true
40+
with:
41+
filters: |
42+
src:
43+
- '.github/workflows/**'
44+
- '__tests__/**'
45+
- '__mocks__/**'
46+
- 'src/**'
47+
- 'appinfo/info.xml'
48+
- 'package.json'
49+
- 'package-lock.json'
50+
- 'tsconfig.json'
51+
- '**.js'
52+
- '**.ts'
53+
- '**.vue'
54+
55+
test:
56+
runs-on: ubuntu-latest
57+
58+
needs: changes
59+
if: needs.changes.outputs.src != 'false'
60+
61+
steps:
62+
- name: Checkout
63+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
64+
with:
65+
persist-credentials: false
66+
67+
- name: Read package.json node and npm engines version
68+
uses: skjnldsv/read-package-engines-version-actions@06d6baf7d8f41934ab630e97d9e6c0bc9c9ac5e4 # v3
69+
id: versions
70+
with:
71+
fallbackNode: '^20'
72+
fallbackNpm: '^10'
73+
74+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
75+
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
76+
with:
77+
node-version: ${{ steps.versions.outputs.nodeVersion }}
78+
79+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
80+
run: npm i -g 'npm@${{ steps.versions.outputs.npmVersion }}'
81+
82+
- name: Install dependencies & build
83+
env:
84+
CYPRESS_INSTALL_BINARY: 0
85+
run: |
86+
npm ci
87+
npm run build --if-present
88+
89+
- name: Test
90+
run: npm run test --if-present
91+
92+
- name: Test and process coverage
93+
run: npm run test:coverage --if-present
94+
95+
- name: Collect coverage
96+
uses: codecov/codecov-action@0565863a31f2c772f9f0395002a31e3f06189574 # v5.4.0
97+
with:
98+
files: ./coverage/lcov.info
99+
100+
summary:
101+
permissions:
102+
contents: none
103+
runs-on: ubuntu-latest-low
104+
needs: [changes, test]
105+
106+
if: always()
107+
108+
name: test-summary
109+
110+
steps:
111+
- name: Summary status
112+
run: if ${{ needs.changes.outputs.src != 'false' && needs.test.result != 'success' }}; then exit 1; fi

src/services/TiledLayout.spec.js

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55

66
import { splitItemsInRows } from './TiledLayout.js'
77

8-
/** @type {import('./TiledLayout.js').TiledItem} */
9-
const sectionHeader1 = {
10-
id: '202204',
11-
sectionHeader: true,
12-
height: 75,
13-
}
14-
158
/** @type {import('./TiledLayout.js').TiledItem} */
169
const squareImage1 = {
1710
id: 'squareImage1',
@@ -20,13 +13,6 @@ const squareImage1 = {
2013
ratio: 200 / 250,
2114
}
2215

23-
/** @type {import('./TiledLayout.js').TiledItem} */
24-
const sectionHeader2 = {
25-
id: '202205',
26-
sectionHeader: true,
27-
height: 75,
28-
}
29-
3016
/** @type {import('./TiledLayout.js').TiledItem} */
3117
const squareImage2 = {
3218
id: 'squareImage2',
@@ -59,33 +45,49 @@ const wideImage1 = {
5945
ratio: 10000 / 250,
6046
}
6147

62-
const items = [sectionHeader1, squareImage1, sectionHeader2, wideImage1, squareImage2, squareImage3, tallImage1]
48+
const items = [squareImage1, wideImage1, squareImage2, squareImage3, tallImage1]
6349

6450
/** @type {import('./TiledLayout.js').TiledRow[]} */
6551
const expectedLayout = [
6652

6753
{
68-
items: [sectionHeader1],
69-
height: 75,
70-
key: '202204',
71-
},
72-
{
73-
items: [squareImage1],
74-
height: 220,
54+
items: [{
55+
...squareImage1,
56+
// "* 10" to fit the width
57+
width: squareImage1.width * 10, // 2000
58+
height: squareImage1.height * 10, // 2500
59+
}],
60+
height: squareImage1.height * 10, // 2500
7561
key: 'squareImage1',
7662
},
7763
{
78-
items: [sectionHeader2],
79-
height: 75,
80-
key: '202205',
81-
},
82-
{
83-
items: [wideImage1],
84-
height: 50,
64+
items: [{
65+
...wideImage1,
66+
// "/ 5" to fit the width
67+
width: wideImage1.width / 5, // 2000
68+
height: wideImage1.height / 5, // 50
69+
}],
70+
height: wideImage1.height / 5, // 50
8571
key: 'wideImage1',
8672
},
8773
{
88-
items: [squareImage2, squareImage3, tallImage1],
74+
items: [
75+
{
76+
...squareImage2,
77+
width: 176,
78+
height: 220,
79+
},
80+
{
81+
...squareImage3,
82+
width: 176,
83+
height: 220,
84+
},
85+
{
86+
...tallImage1,
87+
width: 4.4,
88+
height: 220,
89+
},
90+
],
8991
height: 220,
9092
key: 'squareImage2-squareImage3-tallImage1',
9193
},

0 commit comments

Comments
 (0)