Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Commit 11f1aaf

Browse files
committed
Add E2E test displayig the extension
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
1 parent 228180b commit 11f1aaf

File tree

13 files changed

+8447
-0
lines changed

13 files changed

+8447
-0
lines changed

.github/workflows/e2e.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Copyright 2024 Docker Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: E2E tests
16+
17+
on:
18+
push:
19+
branches:
20+
- main
21+
pull_request:
22+
23+
jobs:
24+
e2e:
25+
name: Run E2E tests
26+
runs-on: ubuntu-latest
27+
28+
steps:
29+
- uses: actions/checkout@v3
30+
31+
- name: Install and start Docker Desktop
32+
uses: docker/desktop-action/start@v0.3.6
33+
34+
- name: Change Desktop settings and allow installing non marketplace extensions
35+
run: |
36+
jq '.onlyMarketplaceExtensions|=false' ~/.docker/desktop/settings.json >./new-settings.json
37+
mv -f ./new-settings.json ~/.docker/desktop/settings.json
38+
39+
- name: Build extension
40+
run: |
41+
make build-extension
42+
43+
- name: Kill Mono process running on port 8084 to unblock it # https://github.com/actions/runner-images/issues/2821
44+
shell: bash
45+
run: |
46+
sudo fuser -k -n tcp 8084
47+
- name: Enable corepack
48+
run: corepack enable
49+
- uses: actions/setup-node@v4
50+
with:
51+
node-version: "20"
52+
- name: Run E2E tests
53+
env:
54+
SKIP_EXTENSION_IMAGE_BUILD: true
55+
run: |
56+
cd e2e/electron
57+
yarn install
58+
xvfb-run --auto-servernum --server-args="-screen 0 1920x1080x24" -- yarn test:e2e

e2e/electron/.babelrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"presets": [
3+
[
4+
"@babel/preset-env",
5+
{
6+
"targets": {
7+
"node": "14.17"
8+
}
9+
}
10+
],
11+
"@babel/preset-typescript"
12+
],
13+
"plugins": []
14+
}

e2e/electron/.eslintrc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"extends": [
3+
"eslint:recommended",
4+
"prettier"
5+
],
6+
"parser": "babel-eslint",
7+
"env": {
8+
"es6": true,
9+
"node": true,
10+
"jest": true,
11+
"browser": true
12+
},
13+
"plugins": [
14+
"prettier"
15+
],
16+
"rules": {
17+
"prettier/prettier": [
18+
"error"
19+
]
20+
},
21+
"globals": {
22+
"page": true
23+
}
24+
}

e2e/electron/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
screenshots
2+
.yarn
3+
node_modules

e2e/electron/.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"tabWidth": 2
5+
}

e2e/electron/.yarnrc.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 Docker Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
nodeLinker: node-modules

e2e/electron/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Docker Desktop electron e2e tests
2+
3+
## Steps
4+
5+
- Ensure Docker Desktop is running (e.g. launch it in your OS)
6+
- Run `make e2e` or cd to `e2e/electron` and run: `yarn test:e2e`

e2e/electron/globals.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
* Copyright 2024 Docker Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import type { Page } from 'puppeteer-core';
18+
19+
declare global {
20+
var page: Page | null;
21+
}

e2e/electron/jest.config.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* Copyright 2024 Docker Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
module.exports = {
18+
verbose: true,
19+
testPathIgnorePatterns: ['/node_modules/'],
20+
testEnvironment: 'node',
21+
preset: 'ts-jest',
22+
testTimeout: 360000,
23+
};

e2e/electron/package.json

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"name": "electron-e2e",
3+
"version": "1.0.0",
4+
"description": "Testcafe setup to run docker desktop e2e tests",
5+
"author": "docker",
6+
"packageManager": "yarn@3.2.2",
7+
"license": "ISC",
8+
"devDependencies": {
9+
"@babel/preset-env": "^7.24.7",
10+
"@babel/preset-typescript": "^7.24.7",
11+
"@docker/extension-test-helper": "^0.1.2",
12+
"@jest/test-sequencer": "^27.0.5",
13+
"@tsconfig/node16": "^1.0.2",
14+
"@types/dockerode": "^3.3.29",
15+
"@types/jest": "^27.0.2",
16+
"@types/mkdirp": "^1.0.2",
17+
"axios": "^1.7.2",
18+
"babel-eslint": "^10.1.0",
19+
"cross-env": "^7.0.3",
20+
"dockerode": "^4.0.2",
21+
"electron": "31.1.0",
22+
"eslint": "^9.6.0",
23+
"eslint-config-prettier": "^8.3.0",
24+
"eslint-plugin-prettier": "^3.4.0",
25+
"jest": "^27.0.5",
26+
"prettier": "^2.3.1",
27+
"ts-jest": "^27.0.5",
28+
"typescript": "^4.5.5"
29+
},
30+
"dependencies": {
31+
"@rumpl/node-eventsource": "^1.0.0",
32+
"@types/bytes": "^3.1.4",
33+
"bytes": "^3.1.2",
34+
"find-process": "^1.4.4",
35+
"fkill": "^7.1.1",
36+
"get-port": "^7.1.0",
37+
"got": "^14.4.1",
38+
"mkdirp": "^1.0.4",
39+
"puppeteer": "^22.12.1",
40+
"puppeteer-core": "^13.1.3"
41+
},
42+
"scripts": {
43+
"test:e2e": "yarn run test:e2e:packaged",
44+
"test:e2e:packaged": "cross-env NODE_ENV=test WHICH_INSTANCE=packaged jest --colors --bail --runInBand --forceExit",
45+
"pretest:e2e:dev": "(cd ../../client/desktop && yarn build:development)",
46+
"test:e2e:dev": "cross-env NODE_ENV=test WHICH_INSTANCE=dev jest --colors --bail --runInBand --forceExit",
47+
"test:puppeteer:debug": "cross-env NODE_ENV=test npx ndb jest --colors --bail --runInBand --forceExit",
48+
"test:puppeteer:verbose": "cross-env NODE_ENV=test DEBUG=puppeteer:* jest --colors --bail --runInBand --forceExit",
49+
"lint": "yarn run lint:js && yarn run check:ts",
50+
"lint:js": "eslint .",
51+
"check:ts": "tsc --noEmit",
52+
"prettier:check": "prettier --check \"**/*.js\" \"**/*.ts\"",
53+
"prettier": "prettier --write \"**/*.js\" \"**/*.ts\""
54+
}
55+
}

0 commit comments

Comments
 (0)