EC-CUBE / EC-CUBE/coupon-plugin

受注ステータス遷移(キャンセル)を検証できる E2E (Playwright) を導入する

Open
#202 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
10
Forks
39
PR merge metrics
No merged PRs in 30d

Description

## 概要

受注ステータスを「注文取消し」へ遷移させる検証が PHPUnit の Web テストでは書けないため、本リポジトリに E2E (Playwright) を導入し、キャンセル遷移を含むクーポンの挙動を検証できるようにする。

## 背景

- #197 (EC-CUBE 4.4 対応) で `Tests/Web/Admin/OrderControllerTest::testOrderEditWithCouponCancel` をスキップした。
- 原因: キャンセル遷移では本体の `StockReduceProcessor` が在庫を戻すために `EntityManager::lock(PESSIMISTIC_WRITE)` を行うが、`APP_ENV=test` では dama/doctrine-test-bundle のトランザクションが DBAL `Connection` 上では開いていないため `TransactionRequiredException` になる。加えて `services_test.yaml` が `TransactionListener` を無効化しているため、リクエスト単位のトランザクションも開かない。
- 本体側 issue EC-CUBE/ec-cube#7016 にて「代案として e2e で実行するのが良い」と方針が示された。
- 実測でも `debug:event-dispatcher kernel.request` で `TransactionListener` が有効なのは dev / prod / e2e、無効なのは test のみであることを確認済み。E2E (実リクエスト) であればこの制約を受けない。

## やること

- Playwright を導入する (`package.json` / `playwright.config.ts` / `e2e/`)。4.4 ブランチで既に E2E 資産を持つ [sample-payment-plugin](https://github.com/EC-CUBE/sample-payment-plugin) の構成に倣う。
- 本リポジトリの `docker-compose.yml` + `docker-compose.dev.yml` で起動した EC-CUBE (プラグイン有効化済み) に対して実行する。
- spec:
- 受注編集画面で受注ステータスを「注文取消し」へ変更 → 500 にならずクーポン未適用の案内が表示され、クーポンの残発行枚数が戻ること (= 本 issue の本題)
- 購入フローでクーポンコードを適用 → お支払い合計が値引きされ、購入後に残発行枚数が 1 枚減ること
- CI: `.github/workflows/playwright.yml` を追加する。既存の PHPUnit の `ci.yml` (`APP_ENV=test`) とは別ワークフローなので併存できる。
- PHPUnit 側のスキップは維持したまま、コメントから E2E を参照する。

## やらないこと

- 本体側の対応 (テスト環境で DBAL トランザクションを開く / 悲観ロックを設定で切り替える) は本体 issue EC-CUBE/ec-cube#7016 の判断に従う。

## 参考

- EC-CUBE/ec-cube#7016
- #197

Contributor guide

No contributing guide indexed for this repository

Research direction

Compare the sample-payment-plugin E2E setup, then inspect package.json, playwright.config.ts, e2e/, docker-compose.yml, docker-compose.dev.yml, and .github/workflows/ci.yml. Start by running EC-CUBE with the plugin enabled and exercise the order-cancellation and purchase coupon flows. Done means both coupon scenarios pass in Playwright and .github/workflows/playwright.yml runs them separately from PHPUnit.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker-compose, github-actions, php, playwright, typescript
Domain
backend, ci-cd, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
56/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.