Skip to content

Commit 378247b

Browse files
committed
Cypress: added missing mocks
Also fixed some unit tests that needed to be updated
1 parent 8784b23 commit 378247b

File tree

9 files changed

+46
-57
lines changed

9 files changed

+46
-57
lines changed

.github/workflows/github-actions-tests.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ jobs:
55
strategy:
66
fail-fast: false
77
matrix:
8-
node-version: [14.x]
8+
node-version: [16.x]
99
os: [ubuntu-latest]
1010
experimental: [false]
1111
# include:
@@ -26,9 +26,15 @@ jobs:
2626
with:
2727
node-version: ${{ matrix.node-version }}
2828
cache: 'npm'
29+
- name: Install
30+
run: |
31+
if [ "$RUNNER_OS" == "Linux" ]; then
32+
sudo apt-get install -y libsdl-pango-dev libgif-dev
33+
fi
34+
shell: bash
2935
- name: Install node_modules
3036
working-directory: ./
31-
run: npm ci
37+
run: npm ci && npm rebuild canvas --update-binary
3238
- name: Install e2e node_modules
3339
run: npm ci
3440
- name: Build E2E version

e2e/cypress/mocks/electron.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,10 @@ module.exports = {
4242
writeText: function(text) {
4343
//
4444
}
45+
},
46+
webFrame: {
47+
setVisualZoomLevelLimits: function (minimumLevel, maximumLevel) {
48+
//
49+
}
4550
}
4651
};

jest.config.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ module.exports = {
66
preset: 'ts-jest',
77
setupFilesAfterEnv: [
88
"<rootDir>/setupTests.ts",
9-
'jest-canvas-mock'
109
],
1110
moduleDirectories: [
1211
'node_modules',

package-lock.json

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

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
"husky": "^3.0.9",
9898
"identity-obj-proxy": "^3.0.0",
9999
"jest": "^29.3.1",
100-
"jest-canvas-mock": "^2.4.0",
101100
"jest-cli": "^29.3.1",
102101
"jest-environment-jsdom": "^29.3.1",
103102
"lint-staged": "^10.4.2",

setupTests.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,21 @@ import '@testing-library/jest-dom'
22
import '@testing-library/jest-dom/extend-expect'
33

44
global.console.error = jest.fn()
5+
6+
interface KeyboardIterator extends Iterator<[string, string]> {
7+
length: number
8+
[key: number]: [string, string]
9+
}
10+
11+
interface KeyboardMap {
12+
entries: () => KeyboardIterator
13+
}
14+
15+
// some tests are not executed with dom so won't have navigator property defined
16+
if (global.navigator)
17+
global.navigator.keyboard = {
18+
getLayoutMap: () =>
19+
Promise.resolve(<KeyboardMap>({
20+
entries: () => [] as unknown as [string, string],
21+
} as unknown as KeyboardMap)),
22+
}

src/components/dialogs/__tests__/shortcutsDialog.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ describe('ShortcutsDialog', () => {
1515
beforeEach(() => jest.resetAllMocks())
1616

1717
describe('shortcuts list', () => {
18-
it('should render shortcuts', () => {
18+
it('should render shortcuts', async () => {
1919
render(<ShortcutsDialog {...DEFAULT_PROPS} />)
20-
expect(screen.getByText(exitLabel)).toBeInTheDocument()
20+
expect(await screen.findByText(exitLabel)).toBeInTheDocument()
2121
expect(screen.getByText(reloadViewLabel)).toBeInTheDocument()
2222
})
2323

src/services/__tests__/FsSort.test.ts

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ const files: Array<FileDescriptor> = [
1717
mode: 16877,
1818
isDir: true,
1919
readonly: false,
20-
id: {
21-
ino: 0n,
22-
dev: 1n,
23-
},
20+
id: '0-1',
2421
isSym: false,
2522
target: '',
2623
type: '',
@@ -37,10 +34,7 @@ const files: Array<FileDescriptor> = [
3734
mode: 33188,
3835
isDir: false,
3936
readonly: false,
40-
id: {
41-
ino: 1n,
42-
dev: 1n,
43-
},
37+
id: '1-1',
4438
isSym: false,
4539
target: '',
4640
type: '',
@@ -57,10 +51,7 @@ const files: Array<FileDescriptor> = [
5751
mode: 33188,
5852
isDir: false,
5953
readonly: false,
60-
id: {
61-
ino: 2n,
62-
dev: 1n,
63-
},
54+
id: '2-1',
6455
isSym: false,
6556
target: '',
6657
type: '',
@@ -77,10 +68,7 @@ const files: Array<FileDescriptor> = [
7768
mode: 33188,
7869
isDir: false,
7970
readonly: false,
80-
id: {
81-
ino: 3n,
82-
dev: 1n,
83-
},
71+
id: '3-1',
8472
isSym: false,
8573
target: '',
8674
type: '',
@@ -90,25 +78,25 @@ const files: Array<FileDescriptor> = [
9078
describe('sorting methods', () => {
9179
it('sort by Name/Asc', () => {
9280
const sortMethod = getSortMethod('name', 'asc')
93-
const sorted_ids = files.sort(sortMethod).map((file) => file.id.ino)
94-
expect(sorted_ids).toEqual([2n, 0n, 1n, 3n])
81+
const sorted_ids = files.sort(sortMethod).map((file) => file.id)
82+
expect(sorted_ids).toEqual(['2-1', '0-1', '1-1', '3-1'])
9583
})
9684

9785
it('sort by Name/Desc', () => {
9886
const sortMethod = getSortMethod('name', 'desc')
99-
const sorted_ids = files.sort(sortMethod).map((file) => file.id.ino)
100-
expect(sorted_ids).toEqual([3n, 1n, 0n, 2n])
87+
const sorted_ids = files.sort(sortMethod).map((file) => file.id)
88+
expect(sorted_ids).toEqual(['3-1', '1-1', '0-1', '2-1'])
10189
})
10290

10391
it('sort by Size/Asc', () => {
10492
const sortMethod = getSortMethod('size', 'asc')
105-
const sorted_ids = files.sort(sortMethod).map((file) => file.id.ino)
106-
expect(sorted_ids).toEqual([1n, 0n, 3n, 2n])
93+
const sorted_ids = files.sort(sortMethod).map((file) => file.id)
94+
expect(sorted_ids).toEqual(['1-1', '0-1', '3-1', '2-1'])
10795
})
10896

10997
it('sort by Size/Asc', () => {
11098
const sortMethod = getSortMethod('size', 'desc')
111-
const sorted_ids = files.sort(sortMethod).map((file) => file.id.ino)
112-
expect(sorted_ids).toEqual([2n, 3n, 0n, 1n])
99+
const sorted_ids = files.sort(sortMethod).map((file) => file.id)
100+
expect(sorted_ids).toEqual(['2-1', '3-1', '0-1', '1-1'])
113101
})
114102
})

src/services/plugins/__tests__/FsLocal.test.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,7 @@ describe('FsLocal', () => {
409409
length: fsStat.size,
410410
isDir: false,
411411
isSym: false,
412-
id: {
413-
dev: fsStat.dev,
414-
ino: fsStat.ino,
415-
},
412+
id: `${fsStat.ino}-${fsStat.dev}`,
416413
mode: fsStat.mode,
417414
readonly: false,
418415
target: null,

0 commit comments

Comments
 (0)