Skip to content

Commit

Permalink
Merge pull request #1351 from TryQuiet/feature/1334
Browse files Browse the repository at this point in the history
Feature/Automated approach for E2E tests
  • Loading branch information
Kacper-RF committed Mar 24, 2023
2 parents 5878099 + cc50c3e commit 07e08ae
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 23 deletions.
93 changes: 75 additions & 18 deletions .github/workflows/e2e-crossplatform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
timeout-minutes: 180
env:
ELECTRON_CUSTOM_VERSION: 23.0.0
TEST_MODE: true
IS_E2E: true

steps:
- uses: actions/checkout@v2
Expand All @@ -20,20 +22,33 @@ jobs:
cachePrefix: "e2e-crossplatform-mac"
bootstrap-packages: "@quiet/logger,@quiet/state-manager,@quiet/backend,@quiet/identity,quiet,backend-bundle,e2e-tests"

- name: Download DMG
working-directory: ./packages/e2e-tests/Quiet
run: curl -LO https://github.com/TryQuiet/quiet/releases/download/quiet%401.0.0/Quiet-1.0.0.dmg
- name: Before build
uses: ./.github/actions/before-build
with:
source-path: darwin

- name: Build App Image
working-directory: ./packages/desktop
run: node_modules/.bin/electron-builder --mac

- name: VERSION env
working-directory: ./packages/desktop
run: echo "VERSION=$(jq -r ".version" package.json)" >> $GITHUB_ENV

- name: FILE_NAME env
working-directory: ./packages/desktop/dist
run: echo "FILE_NAME="Quiet-$VERSION.dmg"" >> $GITHUB_ENV

- name: Chmod
working-directory: ./packages/e2e-tests/Quiet
run: chmod +x Quiet-1.0.0.dmg
working-directory: ./packages/desktop/dist
run: chmod +x $FILE_NAME

- name: Mount installer file in volume on system
working-directory: ./packages/e2e-tests/Quiet
run: hdiutil mount Quiet-1.0.0.dmg
working-directory: ./packages/desktop/dist
run: hdiutil mount $FILE_NAME

- name: Add App file to applications
run: cd ~ && cp -R "/Volumes/Quiet 1.0.0/Quiet.app" /Applications
run: cd ~ && cp -R "/Volumes/Quiet $VERSION/Quiet.app" /Applications

- name: Run smoke test
uses: nick-fields/retry@v2
Expand All @@ -49,8 +64,6 @@ jobs:
max_attempts: 3
command: cd packages/e2e-tests && npm run test newUser.crossplatform.test.ts



linux:
runs-on: ${{ matrix.os }}

Expand All @@ -63,6 +76,7 @@ jobs:
env:
ELECTRON_CUSTOM_VERSION: 23.0.0
DISPLAY: ":99.0"
TEST_MODE: true

steps:
- uses: actions/checkout@v2
Expand All @@ -85,13 +99,13 @@ jobs:
sleep 3
fluxbox &
- name: Download App Image
working-directory: ./packages/e2e-tests/Quiet
run: curl -LO https://github.com/TryQuiet/quiet/releases/download/quiet%401.0.0/Quiet-1.0.0.AppImage
- name: Build App Image
working-directory: ./packages/desktop
run: npm run distUbuntu && VERSION=$(jq -r ".version" package.json) && cd dist && FILE_NAME=$(ls | grep $VERSION) && echo "FILE_NAME=$(ls | grep $VERSION)" >> $GITHUB_ENV && cp $FILE_NAME ../../e2e-tests/Quiet && export FILE_NAME=$FILE_NAME

- name: Chmod
working-directory: ./packages/e2e-tests/Quiet
run: chmod +x Quiet-1.0.0.AppImage
run: chmod +x $FILE_NAME

- name: Run smoke test
uses: nick-fields/retry@v2
Expand All @@ -112,6 +126,7 @@ jobs:
timeout-minutes: 180
env:
ELECTRON_CUSTOM_VERSION: 23.0.0
TEST_MODE: true

steps:
- uses: actions/checkout@v2
Expand All @@ -122,20 +137,59 @@ jobs:
cachePrefix: "e2e-crossplatform-windows"
bootstrap-packages: "@quiet/logger,@quiet/state-manager,@quiet/backend,@quiet/identity,quiet,backend-bundle,e2e-tests"

- name: Download EXE
run: curl -LO https://github.com/TryQuiet/quiet/releases/download/quiet%401.0.0/Quiet.Setup.1.0.0.exe
- name: "Fetch jsign"
shell: bash
run: cd packages/desktop && curl https://zbay-binaries.s3.us-east-2.amazonaws.com/jsign/jsign-2.1.jar --output ./jsign-2.1.jar

- name: "Add Windows certificate"
id: write_file
uses: TryQuiet/base64-to-file@main
with:
fileName: 'win-certificate.pfx'
encodedString: ${{ secrets.WIN_CSC_LINK }}

- name: "Remove test files workaround (jest types conflicting with cypress types)"
run: find packages/desktop/src -name '*.test.*' -delete
shell: bash

- name: Before build
uses: ./.github/actions/before-build
with:
source-path: win32

- name: electron-builder
env:
CERTIFICATE_PATH: ${{ steps.write_file.outputs.filePath }}
WIN_CSC_KEY_PASSWORD: ${{ secrets.WIN_CSC_KEY_PASSWORD }}
WINDOWS_ALIAS: ${{ secrets.WIN_ALIAS }}
working-directory: ./packages/desktop
run: node_modules/.bin/electron-builder --win
shell: bash

- name: Extract version
id: extract_version
uses: Saionaro/extract-package-version@v1.1.1
with:
path: packages/desktop

- name: FILE_NAME env
working-directory: ./packages/desktop/dist
run: echo "FILE_NAME=Quiet Setup ${{ steps.extract_version.outputs.version }}.exe" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf8 -Append
shell: powershell

- name: Chmod
run: chmod +x Quiet.Setup.1.0.0.exe
working-directory: ./packages/desktop/dist
run: chmod +x "$FILE_NAME"
shell: bash

- name: Install exe
run: Start-Process Quiet.Setup.1.0.0.exe -Wait
run: Start-Process "Quiet Setup ${{ steps.extract_version.outputs.version }}.exe" -Wait
working-directory: ./packages/desktop/dist
shell: powershell

- name: Kill exe
run: Stop-Process -Name "Quiet" -Force
working-directory: ./packages/desktop/dist
shell: powershell

- name: Run smoke test
Expand All @@ -145,6 +199,9 @@ jobs:
max_attempts: 3
shell: bash
command: cd packages/e2e-tests && npm run test smoke.crossplatform.test.ts



# Will be fixed in next tasks
# - name: Run newUser test - Includes 2 separate application clients
# uses: nick-fields/retry@v2
Expand Down
3 changes: 2 additions & 1 deletion packages/desktop/scripts/notarize.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
/* eslint-disable no-unreachable */
const { notarize } = require('electron-notarize')

exports.default = async function notarizing (context) {
const { electronPlatformName, appOutDir } = context
if (electronPlatformName !== 'darwin') {
if (electronPlatformName !== 'darwin' || process.env.IS_E2E) {
console.log('skipping notarization')
return
}
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/crossplatform.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class BuildSetup {
private getBinaryLocation() {
switch (process.platform) {
case 'linux':
return `${__dirname}/Quiet/Quiet-1.0.0.AppImage`
return `${__dirname}/Quiet/${process.env.FILE_NAME}`
case 'win32':
return `${process.env.LOCALAPPDATA}\\Programs\\quiet\\Quiet.exe`
case 'darwin':
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/newUser.crossplatform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('New User', () => {
await buildSetup2.killChromeDriver()
})
describe('Stages:', () => {
it.skip('Close debug modal', async () => {
it('Close debug modal', async () => {
console.log('Debug modal')
const debugModal = new DebugModeModal(driver)
await debugModal.element.isDisplayed()
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('New User', () => {
await new Promise<void>(resolve => setTimeout(() => resolve(), 10000))
})

it.skip('Close debug modal', async () => {
it('Close debug modal', async () => {
console.log('Debug modal')
const debugModal = new DebugModeModal(driver2)
await debugModal.element.isDisplayed()
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/smoke.crossplatform.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('Smoke', () => {
await buildSetup.killChromeDriver()
})
describe('Stages:', () => {
it.skip('Close debug modal', async () => {
it('Close debug modal', async () => {
console.log('Debug modal')
const debugModal = new DebugModeModal(driver)
await debugModal.element.isDisplayed()
Expand Down

0 comments on commit 07e08ae

Please sign in to comment.