@shopware-ag/acceptance-test-suite 2.3.9 → 2.3.11

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 CHANGED
@@ -15,6 +15,7 @@ This test suite is an extension to [Playwright](https://playwright.dev/) to easi
15
15
  * [Actor Pattern](#actor-pattern)
16
16
  * [Data Fixtures](#data-fixtures)
17
17
  * [Code Contribution](#code-contribution)
18
+ * [Best practices](#best-practices)
18
19
 
19
20
  ## Installation
20
21
  Start by creating your own [Playwright](https://playwright.dev/docs/intro) project.
@@ -374,4 +375,32 @@ If you create your own data fixtures make sure to import and merge them in your
374
375
  ## Code Contribution
375
376
  You can contribute to this project via its [official repository](https://github.com/shopware/acceptance-test-suite/) on GitHub.
376
377
 
377
- This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). Please make sure to form your commits accordingly to the spec.
378
+ This project uses [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/). Please make sure to form your commits accordingly to the spec.
379
+
380
+ ## Best practices
381
+
382
+ 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.
383
+
384
+ The most important part is [test isolation](https://playwright.dev/docs/best-practices#make-tests-as-isolated-as-possible) which helps to prevent flaky behavior and enables the test to be run in parallel and on systems with an unknown state.
385
+
386
+
387
+ ### Dos
388
+
389
+ - use fixtures or the [`TestDataService`](./src/services/TestDataService.ts)
390
+ - create all the data that is required for your test case. That includes sales channels, customers and users (the page fixtures handle most of the common use cases)
391
+ - if you need specific settings for your test, set it explicitly for the user/customer/sales channel
392
+ - directly jump to detail pages with the id of the entities you've created
393
+ - if that's no possible, use the search with a unique name to filter lists to just that single entity
394
+
395
+ ### Don'ts
396
+
397
+ - do not expect lists/tables to only contain one item, leverage unique ids/names to open or find your entity instead
398
+ - same with helper functions, do not except to only get item back from the API. Always a unique criteria to the API call
399
+ - avoid unused fixtures: if you request a fixture but don't use any data from the fixture, the test or fixture should be refactored
400
+ - do not depend on implicit configuration and existing data. Examples:
401
+ - rules
402
+ - flows
403
+ - categories
404
+ - do not expect the shop to have the defaults en_GB and EUR
405
+ - do not change global settings (sales channel is ok, because it's created by us)
406
+ - basically everything in Settings that is not specific to a sales channel (tax, search, etc.)
package/dist/index.d.mts CHANGED
@@ -460,7 +460,7 @@ declare class TestDataService {
460
460
  /**
461
461
  * Will delete all entities created by the data service via sync API.
462
462
  */
463
- cleanUp(): Promise<playwright_core.APIResponse>;
463
+ cleanUp(): Promise<playwright_core.APIResponse | null>;
464
464
  /**
465
465
  * Convert a JS date object into a date-time compatible string.
466
466
  *
package/dist/index.d.ts CHANGED
@@ -460,7 +460,7 @@ declare class TestDataService {
460
460
  /**
461
461
  * Will delete all entities created by the data service via sync API.
462
462
  */
463
- cleanUp(): Promise<playwright_core.APIResponse>;
463
+ cleanUp(): Promise<playwright_core.APIResponse | null>;
464
464
  /**
465
465
  * Convert a JS date object into a date-time compatible string.
466
466
  *
package/dist/index.mjs CHANGED
@@ -689,20 +689,19 @@ const test$9 = test$d.extend({
689
689
  }
690
690
  `.trim()
691
691
  });
692
+ await expect(page.url()).toContain("login");
692
693
  await page.getByLabel(/Username|Email address/).fill(adminUser.username);
693
694
  await page.getByLabel("Password").fill(adminUser.password);
694
- const configResponsePromise = page.waitForResponse("**/_info/config");
695
- await page.getByRole("button", { name: "Log in" }).click();
696
- const config = await (await configResponsePromise).json();
697
- let lastPlugin;
695
+ const config = await (await AdminApiContext.get("./_info/config")).json();
696
+ const jsLoadingPromises = [];
698
697
  for (const i in config.bundles) {
699
698
  if (config.bundles[i]?.js && config.bundles[i]?.js?.length) {
700
- lastPlugin = config.bundles[i];
699
+ const js = config?.bundles[i]?.js ?? [];
700
+ jsLoadingPromises.push(...js.map((url) => page.waitForResponse(url)));
701
701
  }
702
702
  }
703
- if (lastPlugin) {
704
- await Promise.all(lastPlugin.js.map((url) => page.waitForResponse(url)));
705
- }
703
+ await page.getByRole("button", { name: "Log in" }).click();
704
+ await Promise.all(jsLoadingPromises);
706
705
  await use(page);
707
706
  await page.close();
708
707
  await context.close();
@@ -1401,7 +1400,7 @@ class TestDataService {
1401
1400
  */
1402
1401
  async cleanUp() {
1403
1402
  if (!this.shouldCleanUp) {
1404
- return Promise.reject();
1403
+ return null;
1405
1404
  }
1406
1405
  const priorityDeleteOperations = {};
1407
1406
  const deleteOperations = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/acceptance-test-suite",
3
- "version": "2.3.9",
3
+ "version": "2.3.11",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",