Skip to content

Commit

Permalink
Merge pull request #102 from owncloud/setupPlaywrightTest1
Browse files Browse the repository at this point in the history
[test-only] setup playwright test
  • Loading branch information
ScharfViktor authored Nov 16, 2024
2 parents bd4d37e + 714a4de commit 2a7e16e
Show file tree
Hide file tree
Showing 24 changed files with 817 additions and 1,395 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@ dist
# dev setup
/dev/docker/traefik/certificates
docker-compose.override.yml
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
8 changes: 0 additions & 8 deletions cucumber.cjs

This file was deleted.

6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@
"check:types": "pnpm -r check:types",
"lint": "eslint 'packages/**/*.{js,ts,vue}' --color",
"test:unit": "pnpm -r test:unit --watch=false",
"test:e2e": "NODE_TLS_REJECT_UNAUTHORIZED=0 TS_NODE_PROJECT=./tests/e2e/tsconfig.json cucumber-js packages/"
"test:e2e": "pnpm playwright test"
},
"devDependencies": {
"@cucumber/cucumber": "^11.0.0",
"@cucumber/pretty-formatter": "^1.0.0",
"@ownclouders/eslint-config": "^11.0.0",
"@ownclouders/extension-sdk": "^11.0.0",
"@ownclouders/prettier-config": "0.0.1",
"@ownclouders/tsconfig": "0.0.6",
"@ownclouders/web-test-helpers": "^11.0.0",
"@playwright/test": "^1.41.2",
"@playwright/test": "^1.48.2",
"@types/node": "22.9.0",
"@vue/test-utils": "^2.4.6",
"eslint": "9.14.0",
Expand Down
27 changes: 27 additions & 0 deletions packages/web-app-draw-io/tests/e2e/createDrawIo.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { test, Page, expect } from '@playwright/test'
import { AppSwitcher } from '../../../../support/pages/appSwitcher'
import { DrawIoPage } from '../../../../support/pages/drawIoPage'
import { loginAsUser, logout } from '../../../../support/helpers/authHelper'

let adminPage: Page

test.beforeEach(async ({ browser }) => {
const admin = await loginAsUser(browser, 'admin', 'admin')
adminPage = admin.page
})

test.afterEach(async () => {
await logout(adminPage)
})

test('create drawio file', async () => {
const appSwitcher = new AppSwitcher(adminPage)
await appSwitcher.clickAppSwitcher()
await appSwitcher.createDrawIoFile()
await expect(adminPage).toHaveURL(/.*draw-io/)

const darwIo = new DrawIoPage(adminPage)
await darwIo.addContent()
await darwIo.save()
await darwIo.close()
})
6 changes: 0 additions & 6 deletions packages/web-app-draw-io/tests/e2e/progress-bars.feature

This file was deleted.

3 changes: 3 additions & 0 deletions packages/web-app-draw-io/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ export default defineConfig({
entryFileNames: 'draw-io.js'
}
}
},
test: {
exclude: ['**/e2e/**']
}
})
94 changes: 94 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { defineConfig, devices } from '@playwright/test';

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });

/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
// testDir: './tests/e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL: process.env.BASE_URL_OCIS ?? 'https://host.docker.internal:9200',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},

/* Configure projects for major browsers */
projects: [
{
name: 'draw-io-chromium',
testDir: './packages/web-app-draw-io/tests/e2e',
use: { ...devices['Desktop Chrome'], browserName: 'chromium', ignoreHTTPSErrors: true },
},
{
name: 'drawIO-firefox',
testDir: './packages/web-app-draw-io/tests/e2e',
use: { ...devices['Desktop Firefox'], browserName: 'firefox', ignoreHTTPSErrors: true },
},
{
name: 'drawIO-webkit',
testDir: './packages/web-app-draw-io/tests/e2e',
use: { ...devices['Desktop Safari'], browserName: 'webkit', ignoreHTTPSErrors: true },
},
// {
// name: 'unzip-chromium',
// testDir: './packages/web-app-unzip/tests/e2e',
// use: { ...devices['Desktop Chrome'], browserName: 'chromium', ignoreHTTPSErrors: true },
// },
// {
// name: 'unzip-firefox',
// testDir: './packages/web-app-unzip/tests/e2e',
// use: { ...devices['Desktop Firefox'], browserName: 'firefox', ignoreHTTPSErrors: true },
// },
// {
// name: 'unzip-webkit',
// testDir: './packages/web-app-unzip/tests/e2e',
// use: { ...devices['Desktop Safari'], browserName: 'webkit', ignoreHTTPSErrors: true },
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
Loading

0 comments on commit 2a7e16e

Please sign in to comment.