@shopware-ag/acceptance-test-suite 11.15.2 → 11.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +101 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +6 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,6 +16,7 @@ This test suite is an extension to [Playwright](https://playwright.dev/) to easi
|
|
|
16
16
|
* [Data Fixtures](#data-fixtures)
|
|
17
17
|
* [Test Data Service](#test-data-service)
|
|
18
18
|
* [Code Contribution](#code-contribution)
|
|
19
|
+
* [Local Development with ATS](#local-development-with-ats)
|
|
19
20
|
* [Best practices](#best-practices)
|
|
20
21
|
* [Running Tests in the Test Suite](#running-tests-in-the-test-suite)
|
|
21
22
|
|
|
@@ -72,6 +73,33 @@ export default defineConfig({
|
|
|
72
73
|
|
|
73
74
|
For more information about how to configure your Playwright project, have a look into the [official documentation](https://playwright.dev/docs/test-configuration).
|
|
74
75
|
|
|
76
|
+
### Mailpit Configuration
|
|
77
|
+
Set up your local Mailpit instance by following the instructions at [Mailpit GitHub repository](https://github.com/axllent/mailpit).
|
|
78
|
+
By default, Mailpit starts a web interface at `http://localhost:8025` and listens for SMTP on port `1025`.
|
|
79
|
+
Set the `MAILPIT_BASE_URL` environment variable in `playwright.config.ts` to `http://localhost:8025`. You can now run email tests, such as `tests/Mailpit.spec.ts`.
|
|
80
|
+
|
|
81
|
+
## Testing With ATS
|
|
82
|
+
The `tests` folder ensures the reliability of the testing framework by validating the functionality of tools and data used in tests. Add tests to verify any new features or changes you introduce:
|
|
83
|
+
|
|
84
|
+
- **Page Objects**: Ensure they are correctly implemented and interact with the application as expected, including navigation, element visibility, and user interactions.
|
|
85
|
+
- **TestDataService Methods**: Verify that methods for creating, getting, and cleaning up test data (e.g., products, customers, orders) work correctly and produce consistent results.
|
|
86
|
+
|
|
87
|
+
```TypeScript
|
|
88
|
+
//Example for page objects
|
|
89
|
+
|
|
90
|
+
await ShopAdmin.goesTo(AdminManufacturerCreate.url());
|
|
91
|
+
await ShopAdmin.expects(AdminManufacturerCreate.nameInput).toBeVisible();
|
|
92
|
+
await ShopAdmin.expects(AdminManufacturerCreate.saveButton).toBeVisible();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```TypeScript
|
|
96
|
+
//Example for TestDataService
|
|
97
|
+
|
|
98
|
+
const product = await TestDataService.createProductWithImage({ description: 'Test Description' });
|
|
99
|
+
expect(product.description).toEqual('Test Description');
|
|
100
|
+
expect(product.coverId).toBeDefined();
|
|
101
|
+
```
|
|
102
|
+
|
|
75
103
|
## Usage
|
|
76
104
|
The test suite uses the [extension system](https://playwright.dev/docs/extensibility) of Playwright and can be used as a full drop-in for Playwright. But, as you might also want to add your own extensions, the best way to use it is to create your own base test file and use it as the central reference for your test files. Add it to your project root or a specific fixture directory and name it whatever you like.
|
|
77
105
|
|
|
@@ -206,6 +234,9 @@ Note that this is just a very rough example. In most cases you won't use this pa
|
|
|
206
234
|
### StorefrontPage
|
|
207
235
|
This fixture provides a Playwright [page](https://playwright.dev/docs/api/class-page) context for the Shopware Storefront of the default sales channel.
|
|
208
236
|
|
|
237
|
+
### Add new fixtures
|
|
238
|
+
To add new general fixtures create them inside the `src/fixtures` folder. Keep in mind, that you need to merge your new fixture inside the `/src/index.ts` file.
|
|
239
|
+
|
|
209
240
|
## Page Objects
|
|
210
241
|
Page objects can be helpful to simplify the usage of element selectors and make them available in a reusable way. They help you to organize page specific locators and provide helpers for interacting with a given page. Within our test suite we try to keep the page objects very simple and not to add too much logic to them. So most of the page objects resemble just a collection of element locators and maybe some little helper methods.
|
|
211
242
|
|
|
@@ -224,6 +255,44 @@ test('Storefront cart test scenario', async ({ StorefrontPage, StorefrontCheckou
|
|
|
224
255
|
|
|
225
256
|
You can get an overview of all available page objects in the [repository](https://github.com/shopware/acceptance-test-suite/tree/trunk/src/page-objects) of this test suite.
|
|
226
257
|
|
|
258
|
+
## Page object module
|
|
259
|
+
The `modules` folder is designed to house reusable utility functions that operate on a `Page` object (from Playwright). These functions dynamically interact with different browser pages or contexts using the `page` parameter.
|
|
260
|
+
For example, utility functions like `getCustomFieldCardLocators` or `getSelectFieldListitem` are used across multiple page objects to handle specific functionality (e.g., managing custom fields or select field list items). Centralizing these utilities in the `modules` folder improves code organization, readability, and reduces duplication.
|
|
261
|
+
Create a new class inside module when it helps to streamline the codebase and avoid repetitive logic across page objects.
|
|
262
|
+
|
|
263
|
+
You can find how `getCustomFieldCardLocators` is defined in the [modules folder ](./src/page-objects/administration/modules/CustomFieldCard.ts) and used in other page object class [here](./src/page-objects/administration/ProductDetail.ts).
|
|
264
|
+
|
|
265
|
+
### Add new Page Objects
|
|
266
|
+
Page objects are organized mainly by their usage in the administration or storefront. To add a new page object just add it in the respective subfolder and reference it in the `AdministrationPages.ts` or `StorefrontPages.ts`.
|
|
267
|
+
|
|
268
|
+
**Usage**
|
|
269
|
+
```TypeScript
|
|
270
|
+
import { test as base } from '@playwright/test';
|
|
271
|
+
import type { FixtureTypes } from '../types/FixtureTypes';
|
|
272
|
+
|
|
273
|
+
import { ProductDetail } from './administration/ProductDetail';
|
|
274
|
+
import { OrderDetail } from './administration/OrderDetail';
|
|
275
|
+
import { CustomerListing } from './administration/CustomerListing';
|
|
276
|
+
// [...]
|
|
277
|
+
import { MyNewPage } from './administration/MyNewPage';
|
|
278
|
+
|
|
279
|
+
export interface AdministrationPageTypes {
|
|
280
|
+
AdminProductDetail: ProductDetail;
|
|
281
|
+
AdminOrderDetail: OrderDetail;
|
|
282
|
+
AdminCustomerListing: CustomerListing;
|
|
283
|
+
// [...]
|
|
284
|
+
AdminMyNewPage: MyNewPage;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export const AdminPageObjects = {
|
|
288
|
+
ProductDetail,
|
|
289
|
+
OrderDetail,
|
|
290
|
+
CustomerListing,
|
|
291
|
+
// [...]
|
|
292
|
+
MyNewPage,
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
227
296
|
## Actor Pattern
|
|
228
297
|
The actor pattern is a very simple concept that we added to our test suite. It is something that is not related to Playwright, but similar concepts exist in other testing frameworks. We implemented it, because we want to have reusable test logic that can be used in a human-readable form, without abstracting away Playwright as a framework. So you are totally free to use it or not. Any normal Playwright functionality will still be usable in your tests.
|
|
229
298
|
|
|
@@ -320,7 +389,7 @@ test('Customer login test scenario', async ({ ShopCustomer, Login }) => {
|
|
|
320
389
|
});
|
|
321
390
|
```
|
|
322
391
|
|
|
323
|
-
You can create your own tasks in the same way to make them available for the actor pattern. Every task is just a simple Playwright fixture containing a function call with the corresponding test logic. Make sure to merge your task fixtures with other fixtures you created in your base test file. You can use the `mergeTests` method of Playwright to combine several fixtures into one test extension.
|
|
392
|
+
You can create your own tasks in the same way to make them available for the actor pattern. Every task is just a simple Playwright fixture containing a function call with the corresponding test logic. Make sure to merge your task fixtures with other fixtures you created in your base test file. You can use the `mergeTests` method of Playwright to combine several fixtures into one test extension. Use `/src/tasks/shop-customer-tasks.ts` or `/src/tasks/shop-admin-tasks.ts` for that.
|
|
324
393
|
|
|
325
394
|
## Data Fixtures
|
|
326
395
|
|
|
@@ -439,6 +508,37 @@ You can contribute to this project via its [official repository](https://github.
|
|
|
439
508
|
|
|
440
509
|
This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). Please make sure to form your commits accordingly to the spec.
|
|
441
510
|
|
|
511
|
+
## Local Development with ATS
|
|
512
|
+
To work locally with the Acceptance Test Suite (ATS) and your development setup, follow these steps:
|
|
513
|
+
|
|
514
|
+
### Create Your Page Objects and TestDataService Methods
|
|
515
|
+
|
|
516
|
+
In the ATS repository (shopware/acceptance-test-suite), create or modify your custom page objects, TestDataService methods, or any related files.
|
|
517
|
+
|
|
518
|
+
After making your changes, build the project by running the following command in the ATS repository:
|
|
519
|
+
```bash
|
|
520
|
+
npm run build
|
|
521
|
+
```
|
|
522
|
+
This will generate the necessary artifacts in the dist folder.
|
|
523
|
+
|
|
524
|
+
Copy the generated artifacts (e.g., all files in the dist folder) from the ATS repository to your local Shopware instance's `node_modules` folder, specifically under the ATS package path:
|
|
525
|
+
```bash
|
|
526
|
+
cp -R dist/* <path-to-your-shopware-instance>/tests/acceptance/node_modules/@shopware-ag/acceptance-test-suite/dist
|
|
527
|
+
````
|
|
528
|
+
### Adjust Tests, Page Objects, and Methods
|
|
529
|
+
|
|
530
|
+
In your Shopware instance, adjust any tests, page objects, TestDataService methods, or other related files to align them with the changes made in the ATS repository.
|
|
531
|
+
|
|
532
|
+
### Run the Tests
|
|
533
|
+
|
|
534
|
+
Execute the tests to verify your changes. Use the following command from your Shopware project's acceptance test directory:
|
|
535
|
+
```bash
|
|
536
|
+
cd tests/acceptance
|
|
537
|
+
npx playwright test --ui
|
|
538
|
+
```
|
|
539
|
+
This will launch the Playwright Test Runner UI where you can select and run specific tests.
|
|
540
|
+
By following these steps, you can work locally with the ATS and test your changes in your Shopware instance.
|
|
541
|
+
|
|
442
542
|
## Best practices
|
|
443
543
|
|
|
444
544
|
A good first read about this is the official [playwright best practices page](https://playwright.dev/docs/best-practices). It describes the most important practices which should also be followed when writing acceptance tests for Shopware.
|
package/dist/index.d.mts
CHANGED
|
@@ -1875,6 +1875,7 @@ declare class OrderDetail implements PageObject {
|
|
|
1875
1875
|
readonly saveButton: Locator;
|
|
1876
1876
|
readonly dataGridContextButton: Locator;
|
|
1877
1877
|
readonly orderTag: Locator;
|
|
1878
|
+
readonly itemsCardHeader: Locator;
|
|
1878
1879
|
constructor(page: Page, instanceMeta: HelperFixtureTypes['InstanceMeta']);
|
|
1879
1880
|
url(orderId: string, tabName?: string): string;
|
|
1880
1881
|
getCustomFieldCardLocators(customFieldSetName: string, customFieldTextName: string): Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1875,6 +1875,7 @@ declare class OrderDetail implements PageObject {
|
|
|
1875
1875
|
readonly saveButton: Locator;
|
|
1876
1876
|
readonly dataGridContextButton: Locator;
|
|
1877
1877
|
readonly orderTag: Locator;
|
|
1878
|
+
readonly itemsCardHeader: Locator;
|
|
1878
1879
|
constructor(page: Page, instanceMeta: HelperFixtureTypes['InstanceMeta']);
|
|
1879
1880
|
url(orderId: string, tabName?: string): string;
|
|
1880
1881
|
getCustomFieldCardLocators(customFieldSetName: string, customFieldTextName: string): Promise<{
|
package/dist/index.mjs
CHANGED
|
@@ -4866,9 +4866,15 @@ class OrderDetail {
|
|
|
4866
4866
|
__publicField$v(this, "saveButton");
|
|
4867
4867
|
__publicField$v(this, "dataGridContextButton");
|
|
4868
4868
|
__publicField$v(this, "orderTag");
|
|
4869
|
+
__publicField$v(this, "itemsCardHeader");
|
|
4869
4870
|
this.saveButton = page.locator(".sw-order-detail__smart-bar-save-button");
|
|
4870
4871
|
this.dataGridContextButton = page.locator(".sw-data-grid__actions-menu").and(page.getByRole("button"));
|
|
4871
4872
|
this.orderTag = page.locator(".sw-select-selection-list__item");
|
|
4873
|
+
if (satisfies(instanceMeta.version, "<6.7")) {
|
|
4874
|
+
this.itemsCardHeader = page.locator(".sw-card__header").getByText("Items");
|
|
4875
|
+
} else {
|
|
4876
|
+
this.itemsCardHeader = page.locator(".mt-card__header").getByText("Items");
|
|
4877
|
+
}
|
|
4872
4878
|
}
|
|
4873
4879
|
url(orderId, tabName = "general") {
|
|
4874
4880
|
return `#/sw/order/detail/${orderId}/${tabName}`;
|