Skip to content

Commit

Permalink
test: setup playwright (#48)
Browse files Browse the repository at this point in the history
## Summary

This PR establishes the foundation for end-to-end (E2E) testing in our
project by integrating Playwright. It's a crucial step towards building
a tested and stable application, focusing on simplifying our setup to
kickstart the testing process effectively.

## Changes

- **Integrated Playwright:** Sets up Playwright for E2E testing,
enabling us to begin automating tests for our application.
- **Codebase Cleanup:** Removed unused files and dependencies to
facilitate a smoother build process and ensure the testing environment
is focused only on active features.
- **Preparation for Feature Reintegration:** This cleanup paves the way
for a structured reintroduction of features, ensuring each is thoroughly
tested before becoming part of the main codebase again.

## Rationale

Following a significant refactor and restructuring of our source code,
this move is aimed at ensuring the new structure not only supports
development mode but is also testable and buildable. By starting with a
lean codebase, we aim to methodically reintroduce features, ensuring
each is compatible with our new structure and passes E2E tests.

## Next Steps

With the testing framework in place, we will gradually reintroduce
features, testing each thoroughly to maintain the integrity and
stability of our application.

### Issues Closed

- closes #22
  • Loading branch information
pixelass authored Feb 21, 2024
1 parent 694d518 commit 76737cf
Show file tree
Hide file tree
Showing 26 changed files with 177 additions and 3,850 deletions.
60 changes: 60 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "nextron build",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"dev": "nextron",
"eslint": "eslint \"{renderer,main}/{**/*,*}{.,.config.,.test.,.e2e.}{js,mjs,ts,tsx}\"",
"eslint": "eslint \"src/{**/*,*}.{ts,tsx}\"",
"postinstall": "electron-builder install-app-deps",
"ncu": "npx npm-check-updates@latest -u",
"ncu:check": "npx npm-check-updates@latest",
Expand All @@ -21,7 +21,9 @@
"toc": "npx markdown-toc README.md -i",
"tsc:noEmit": "tsc --noEmit",
"caption:test": "ts-node-esm main/captions/misc.ts",
"test:unit": "jest --runInBand --config jest.config.unit.mjs --verbose"
"test:unit": "jest --runInBand --config jest.config.unit.mjs --verbose",
"pretest:e2e": "nextron build --no-pack",
"test:e2e": "npx playwright test"
},
"dependencies": {
"electron-context-menu": "3.6.1",
Expand All @@ -43,6 +45,7 @@
"@mui/joy": "5.0.0-beta.24",
"@mui/material": "5.15.6",
"@next/mdx": "14.1.0",
"@playwright/test": "^1.41.2",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/exec": "^6.0.3",
"@semantic-release/git": "^10.0.1",
Expand Down
69 changes: 69 additions & 0 deletions playwright-report/index.html

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import type { PlaywrightTestConfig } from "@playwright/test";

/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: "./playwright",
};

export default config;
33 changes: 33 additions & 0 deletions playwright/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import type { ElectronApplication, Page } from "@playwright/test";
import { test, expect } from "@playwright/test";
import { _electron as electron } from "playwright";

let electronApp: ElectronApplication;
let page: Page;

test.beforeAll(async () => {
// Use package.main
electronApp = await electron.launch({ args: ["."] });
const isPackaged = await electronApp.evaluate(async ({ app }) => app.isPackaged);

expect(isPackaged).toBe(false);
});

test.afterAll(async () => {
await electronApp.close();
});

test("Renders the first page", async () => {
page = await electronApp.firstWindow();
const title = await page.title();
expect(title).toBe("Blibla");
});

test("Allows switching the language", async () => {
page = await electronApp.firstWindow();

await expect(page.getByTestId("language-selector-list")).toBeVisible();
await expect(page.getByText("Deutsch")).toBeVisible();
await page.getByText("Deutsch").click();
await expect(page.getByText("Sprache")).toBeVisible();
});
68 changes: 0 additions & 68 deletions src/client/organisms/delete-confirm/index.tsx

This file was deleted.

52 changes: 0 additions & 52 deletions src/client/organisms/folder-drop/index.tsx

This file was deleted.

55 changes: 0 additions & 55 deletions src/client/organisms/folder-field/index.tsx

This file was deleted.

Loading

0 comments on commit 76737cf

Please sign in to comment.