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: add acceptance tests #97

Draft
wants to merge 2 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
pull_request:
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
6 changes: 3 additions & 3 deletions .github/workflows/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on:
push:
branches:
- trunk
pull_request:
paths:
- src/Resources/app/administration/**/*
# pull_request:
# paths:
# - src/Resources/app/administration/**/*
workflow_dispatch:

permissions:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- trunk
pull_request:
# pull_request:
workflow_dispatch:

permissions:
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ on:
push:
branches:
- trunk
pull_request:
paths:
- bin/*.php
- src/**/*.php
- tests/**/*.php
- rector.php
- composer.json
- .php-cs-fixer.dist.php
- phpstan.neon.dist
- phpstan-baseline.neon
# pull_request:
# paths:
# - bin/*.php
# - src/**/*.php
# - tests/**/*.php
# - rector.php
# - composer.json
# - .php-cs-fixer.dist.php
# - phpstan.neon.dist
# - phpstan-baseline.neon
workflow_dispatch:
workflow_call:

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/storefront.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ on:
push:
branches:
- trunk
pull_request:
paths:
- src/Resources/app/storefront/**/*
# pull_request:
# paths:
# - src/Resources/app/storefront/**/*
workflow_dispatch:

permissions:
Expand Down
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 PayPal 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 `[paypal-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
Loading