Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(e2e): twenty-e2e-testing with playwright #6539

Merged
merged 11 commits into from
Aug 14, 2024
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@
"packages/twenty-utils",
"packages/twenty-zapier",
"packages/twenty-website",
"packages/twenty-e2e-testing",
"tools/eslint-rules"
]
}
Expand Down
2 changes: 2 additions & 0 deletions packages/twenty-e2e-testing/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Note that provide always without trailing forward slash to have expected behaviour
FRONTEND_BASE_URL="http://localhost:3001"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Add a newline at the end of the file to follow best practices for text files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks doing lesss goo

5 changes: 5 additions & 0 deletions packages/twenty-e2e-testing/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
34 changes: 34 additions & 0 deletions packages/twenty-e2e-testing/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Twenty e2e Testing

### Run end-to-end tests

```
yarn playwright test
```

### Start the interactive UI mode

```
yarn playwright test --ui
```

### Run test only on Desktop Chrome

```
yarn playwright test --project=chromium
```

### Run test in specific file
```
yarn playwright test example
```

### Runs the tests in debug mode.
```
yarn playwright test --debug
```

### Auto generate tests with Codegen
```
yarn playwright codegen
```
14 changes: 14 additions & 0 deletions packages/twenty-e2e-testing/e2e/companies.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { expect, test } from '@playwright/test';

test.describe('visible table', () => {
test('table should be visible on navigation to /objects/companies', async ({
page,
}) => {
// Navigate to the page
await page.goto('/objects/companies');

// Check if the table is visible
const table = page.locator('table');
await expect(table).toBeVisible();
});
});
14 changes: 14 additions & 0 deletions packages/twenty-e2e-testing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "twenty-e2e-testing",
"devDependencies": {
"@playwright/test": "^1.45.3"
},
"scripts": {
"test:e2e:setup": "yarn playwright install",
"test:e2e": "yarn playwright test",
"test:e2e:ui": "yarn playwright test --ui",
"test:e2e:chrome": "yarn playwright test --project=chromium",
"test:e2e:debug": "yarn playwright test --debug",
"test:e2e:report": "yarn playwright show-report"
}
}
58 changes: 58 additions & 0 deletions packages/twenty-e2e-testing/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { defineConfig, devices } from '@playwright/test';

import { config } from 'dotenv';
config();

/**
* See https://playwright.dev/docs/test-configuration.
* See https://playwright.dev/docs/trace-viewer to Collect trace when retrying the failed test
*/
export default defineConfig({
testDir: 'e2e',
/* Run tests in files in parallel */
fullyParallel: true,
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.FRONTEND_BASE_URL ?? 'http://localhost:3001',
},

/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* 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' },
// },
],
});
43 changes: 43 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10903,6 +10903,17 @@ __metadata:
languageName: node
linkType: hard

"@playwright/test@npm:^1.45.3":
version: 1.45.3
resolution: "@playwright/test@npm:1.45.3"
dependencies:
playwright: "npm:1.45.3"
bin:
playwright: cli.js
checksum: 10c0/d6c2179601093ae0e4feaf6a73841c62045102739d6607e38ea6ab820301f4659ee767c629479b3ce929d72a5f448819a6ee96b0c501fb39b90fceee83fafcde
languageName: node
linkType: hard

"@pnpm/config.env-replace@npm:^1.1.0":
version: 1.1.0
resolution: "@pnpm/config.env-replace@npm:1.1.0"
Expand Down Expand Up @@ -42230,6 +42241,30 @@ __metadata:
languageName: node
linkType: hard

"playwright-core@npm:1.45.3":
version: 1.45.3
resolution: "playwright-core@npm:1.45.3"
bin:
playwright-core: cli.js
checksum: 10c0/39cc5920b27c42300e13a0646ca723578085d85940fc1f03e858fa348b5ac06f2eadf34cf15a0c0f4443e63ae188097d3ddbeb4389e7bbf5ae3438d8f6ed23e1
languageName: node
linkType: hard

"playwright@npm:1.45.3":
version: 1.45.3
resolution: "playwright@npm:1.45.3"
dependencies:
fsevents: "npm:2.3.2"
playwright-core: "npm:1.45.3"
dependenciesMeta:
fsevents:
optional: true
bin:
playwright: cli.js
checksum: 10c0/3516ca49deb589171ac6525c0367f2ff948514d791d197f3cc0a135154c2df08a4d7cd11a810e187f35ae9ca490b37ca3a92fb3eb51560f03aefcaca0613efdb
languageName: node
linkType: hard

"playwright@npm:^1.14.0, playwright@npm:^1.40.1":
version: 1.40.1
resolution: "playwright@npm:1.40.1"
Expand Down Expand Up @@ -49112,6 +49147,14 @@ __metadata:
languageName: unknown
linkType: soft

"twenty-e2e-testing@workspace:packages/twenty-e2e-testing":
version: 0.0.0-use.local
resolution: "twenty-e2e-testing@workspace:packages/twenty-e2e-testing"
dependencies:
"@playwright/test": "npm:^1.45.3"
languageName: unknown
linkType: soft

"twenty-emails@workspace:packages/twenty-emails":
version: 0.0.0-use.local
resolution: "twenty-emails@workspace:packages/twenty-emails"
Expand Down
Loading