Skip to content

Commit

Permalink
feat: add acceptance tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cyl3x committed Jan 31, 2025
1 parent d0cb467 commit 805aa74
Show file tree
Hide file tree
Showing 30 changed files with 4,742 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/actions/setup-paypal/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ inputs:
default: "trunk"
required: false
description: "Which version/branch of shopware should be used"
env:
description: "Environment for Shopware"
required: true
default: "test"

runs:
using: composite
Expand Down Expand Up @@ -93,6 +97,7 @@ runs:
install: true
install-admin: ${{ inputs.install-admin }}
install-storefront: ${{ inputs.install-storefront }}
env: ${{ inputs.env }}
dependencies: ${{ steps.dependency-list.outputs.deps }}
extraRepositories: ${{ steps.dependency-list.outputs.repos }}
- name: Prepare Administration
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/acceptance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Acceptance
on:
push:
branches:
- trunk
- feat/add-acceptance-tests
workflow_dispatch:

permissions:
contents: read
id-token: write

jobs:
acceptance:
name: Acceptance Test Suite
runs-on: ubuntu-latest
services:
redis:
image: redis:7.0
ports:
- '9200:9200'
mailpit:
image: axllent/mailpit:latest
ports:
- '1025:1025'
- '8025:8025'
env:
APP_ENV: prod
APP_DEBUG: '1'
MAILER_DSN: smtp://localhost:1025
MAILPIT_BASE_URL: http://localhost:8025
PLUGIN_PATH: './custom/plugins/${{ github.event.repository.name }}'
steps:
- name: Checkout SwagPayPal
uses: actions/checkout@v4
with:
path: ${{ env.PLUGIN_PATH }}

- name: Setup SwagPayPal
uses: ./custom/plugins/SwagPayPal/.github/actions/setup-paypal
with:
install-admin: true
install-storefront: true
env: prod

- name: Prepare environment variables
run: |
symfony console cache:clear --env="${APP_ENV}" || true
echo "APP_URL=${APP_URL}" >> "${PLUGIN_PATH}/tests/acceptance/.env"
symfony console integration:create AcceptanceTest --admin >> "${PLUGIN_PATH}/tests/acceptance/.env"
cat "${PLUGIN_PATH}/tests/acceptance/.env"
- name: Install playwright
working-directory: ${{ env.PLUGIN_PATH }}/tests/acceptance
run: |
npm ci
npx playwright install --with-deps
- name: Run Playwright
working-directory: ${{ env.PLUGIN_PATH }}/tests/acceptance
run: npx playwright test --reporter=${{ github.event.act && 'line' || 'github' }} --trace=on-first-retry

- uses: actions/upload-artifact@v4
if: always()
with:
name: acceptance-${{ github.event.repository.name }}-${{ github.sha }}
path: ${{ env.PLUGIN_PATH }}/tests/acceptance/test-results/
retention-days: 3
8 changes: 8 additions & 0 deletions tests/acceptance/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
node_modules/
.vscode
/test-results/
/playwright-report/
/playwright/.cache/
/playwright/.auth/
.env
tmp
50 changes: 50 additions & 0 deletions tests/acceptance/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
## Setup

Navigate to this directory if you haven't yet.

```
cd tests/acceptance
```

Install the project dependencies.

```
npm install
```

Install Playwright.

```
npx playwright install
npx playwright install-deps
```

Make sure to add the required environment variables to your `.env` file in the acceptance test directory of the Commercial plugin (not the shopware root).

```
APP_URL="<shop base url>"
# optional with default dev setup
SHOPWARE_ACCESS_KEY_ID="<your-api-client-id>"
SHOPWARE_SECRET_ACCESS_KEY="<your-api-secret>"
```

To generate the access key you can use the following Symfony command:

```
bin/console integration:create AcceptanceTest --admin
```

## Running Tests

Navigate to `[commercial-repo]/tests/acceptance` and run:

```
npx playwright test
```

## Running Tests (Nix)

```
nix run nixpkgs#playwright-test -- test
```
8 changes: 8 additions & 0 deletions tests/acceptance/data-fixtures/DataFixtures.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { mergeTests } from '@shopware-ag/acceptance-test-suite';

export interface DataFixtureTypes {
}

export const test = mergeTests(

);
54 changes: 54 additions & 0 deletions tests/acceptance/eslint.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import tseslint from 'typescript-eslint';
import eslint from '@eslint/js';
import playwright from 'eslint-plugin-playwright';
import stylistic from '@stylistic/eslint-plugin';
import globals from 'globals';

export default tseslint.config(
eslint.configs.recommended,
tseslint.configs.recommendedTypeChecked,
playwright.configs['flat/recommended'],
stylistic.configs['recommended-flat'],
{
languageOptions: {
ecmaVersion: 'latest',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
globals: globals.node,
},

plugins: { '@stylistic': stylistic },

rules: {
/* stylistic rules */
'@stylistic/semi': ['error', 'always'],
'@stylistic/indent': ['error', 4, { SwitchCase: 1 }],
'@stylistic/member-delimiter-style': ['error'],
'@stylistic/no-multi-spaces': ['error'],
'@stylistic/object-curly-spacing': ['error', 'always'],
'@stylistic/space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always',
}],
'@stylistic/spaced-comment': ['error', 'always'],
'@stylistic/no-tabs': ['error'],
'@stylistic/no-mixed-spaces-and-tabs': ['error'],
'@stylistic/max-len': 'off',
'@stylistic/quote-props': ['error', 'as-needed'],
'@stylistic/no-extra-semi': ['error'],
'@stylistic/comma-dangle': ['error', 'always-multiline'],
/* stylistic rules */

/* typescript rules */
'@typescript-eslint/no-unused-vars': 'warn',
/* typescript rules */

/* playwright rules */
'playwright/expect-expect': 'off',
/* playwright rules */
}
},
);
13 changes: 13 additions & 0 deletions tests/acceptance/fixtures/AcceptanceTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { test as ShopwareTestSuite, mergeTests } from '@shopware-ag/acceptance-test-suite';
import { test as shopCustomerTasks } from '@tasks/ShopCustomerTasks';
import { test as shopAdminTasks } from '@tasks/ShopAdminTasks';
import { test as adminPages } from '@page-objects/AdministrationPages';
import { test as storefrontPages } from '@page-objects/StorefrontPages';

export const test = mergeTests(
ShopwareTestSuite,
shopCustomerTasks,
shopAdminTasks,
adminPages,
storefrontPages,
);
8 changes: 8 additions & 0 deletions tests/acceptance/global.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { FixtureTypes as BaseTypes } from '@shopware-ag/acceptance-test-suite';
import type { AdminPageTypes } from '@page-objects/AdministrationPages';
import type { StorefrontPageTypes } from '@page-objects/StorefrontPages';
import type { DataFixtureTypes } from './data-fixtures/DataFixtures';

declare global {
type FixtureTypes = BaseTypes & AdminPageTypes & StorefrontPageTypes & DataFixtureTypes;
};
Loading

0 comments on commit 805aa74

Please sign in to comment.