Skip to content

Commit

Permalink
[Tech] Simplify our E2E tests (#3213)
Browse files Browse the repository at this point in the history
  • Loading branch information
CommandMC authored Dec 18, 2023
1 parent 8be4727 commit 9897a39
Show file tree
Hide file tree
Showing 18 changed files with 156 additions and 295 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
sign/**
flatpak-build/**
playwright-report/**
22 changes: 0 additions & 22 deletions .github/workflows/test-e2e-dev.yml

This file was deleted.

25 changes: 0 additions & 25 deletions .github/workflows/test-e2e-packaged.yml

This file was deleted.

12 changes: 10 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,19 @@ on:
workflow_dispatch:

jobs:
test:
ci:
runs-on: ubuntu-latest
steps:
- name: Checkout repository.
uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- name: Test
- name: Test CI
run: yarn test:ci
e2e:
runs-on: ubuntu-latest
steps:
- name: Checkout repository.
uses: actions/checkout@v3
- uses: ./.github/actions/install-deps
- name: Test E2E
run: yarn test:e2e
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ vite-plugin-electron.log
#flatpak
flatpak-build
.env

playwright-report
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ flatpak-build
sign/
.github/workflows/build-base.yml
signatures/version1/cla.json
playwright-report
29 changes: 0 additions & 29 deletions e2e/Dockerfile.test

This file was deleted.

54 changes: 0 additions & 54 deletions e2e/__specs__/api.spec.ts

This file was deleted.

65 changes: 0 additions & 65 deletions e2e/__specs__/common-setup.ts

This file was deleted.

49 changes: 49 additions & 0 deletions e2e/api.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { expect, test } from '@playwright/test'
import { compareVersions } from 'compare-versions'
import { electronTest } from './helpers'

declare const window: { api: typeof import('../src/backend/api').default }

electronTest('renders the first page', async (app) => {
const page = await app.firstWindow()
await expect(page).toHaveTitle('Heroic Games Launcher')
})

electronTest('gets heroic, legendary, and gog versions', async (app) => {
const page = await app.firstWindow()

await test.step('get heroic version', async () => {
const heroicVersion = await page.evaluate(async () =>
window.api.getHeroicVersion()
)
console.log('Heroic Version: ', heroicVersion)
// check that heroic version is newer or equal to 2.6.3
expect(compareVersions(heroicVersion, '2.6.3')).toBeGreaterThanOrEqual(0)
})

await test.step('get legendary version', async () => {
let legendaryVersion = await page.evaluate(async () =>
window.api.getLegendaryVersion()
)
legendaryVersion = legendaryVersion.trim().split(' ')[0]
console.log('Legendary Version: ', legendaryVersion)
expect(compareVersions(legendaryVersion, '0.20.32')).toBeGreaterThanOrEqual(
0
)
})

await test.step('get gogdl version', async () => {
const gogdlVersion = await page.evaluate(async () =>
window.api.getGogdlVersion()
)
console.log('Gogdl Version: ', gogdlVersion)
expect(compareVersions(gogdlVersion, '0.7.1')).toBeGreaterThanOrEqual(0)
})
})

electronTest('test ipcMainInvokeHandler', async (app) => {
const page = await app.firstWindow()
const platform = await page.evaluate(async () => window.api.getPlatform())
console.log('Platform: ', platform)
expect(platform).toEqual(process.platform)
})
10 changes: 0 additions & 10 deletions e2e/docker-compose.yml

This file was deleted.

53 changes: 0 additions & 53 deletions e2e/entrypoint.sh

This file was deleted.

28 changes: 28 additions & 0 deletions e2e/helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { join } from 'path'
import {
test,
_electron as electron,
type ElectronApplication
} from '@playwright/test'

const main_js = join(__dirname, '../build/electron/main.js')

/**
* Helper function to define a test requiring Heroic to be running
* @param name The name of the test
* @param func The test callback
*/
function electronTest(
name: string,
func: (app: ElectronApplication) => void | Promise<void>
) {
test(name, async () => {
const app = await electron.launch({
args: [main_js]
})
await func(app)
await app.close()
})
}

export { electronTest }
Loading

0 comments on commit 9897a39

Please sign in to comment.