@shopware-ag/acceptance-test-suite 2.3.1 → 2.3.2

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/dist/index.d.mts CHANGED
@@ -2,7 +2,6 @@ import * as _playwright_test from '@playwright/test';
2
2
  import { APIRequestContext, APIResponse, Page, Locator } from '@playwright/test';
3
3
  export * from '@playwright/test';
4
4
  import * as playwright_core from 'playwright-core';
5
- import { Page as Page$1 } from 'playwright-core';
6
5
  import { components } from '@shopware/api-client/admin-api-types';
7
6
  import { Image } from 'image-js';
8
7
 
@@ -529,7 +528,7 @@ interface TestDataFixtureTypes {
529
528
 
530
529
  interface HelperFixtureTypes {
531
530
  IdProvider: IdProvider;
532
- SaaSInstanceSetup: () => Promise<void>;
531
+ SaaSInstanceSetup: (page: Page) => Promise<void>;
533
532
  }
534
533
 
535
534
  interface StoreBaseConfig {
@@ -1020,7 +1019,7 @@ type OrderStatus = 'cancel' | 'complete' | 'reopen' | 'process';
1020
1019
  declare const setOrderStatus: (orderId: string, orderStatus: OrderStatus, adminApiContext: AdminApiContext) => Promise<APIResponse>;
1021
1020
 
1022
1021
  declare const isSaaSInstance: (adminApiContext: AdminApiContext) => Promise<boolean>;
1023
- declare const isThemeCompiled: (page: Page$1) => Promise<boolean>;
1022
+ declare const isThemeCompiled: (context: AdminApiContext, storefrontUrl: string) => Promise<boolean>;
1024
1023
 
1025
1024
  declare function createRandomImage(width?: number, height?: number): Image;
1026
1025
 
package/dist/index.d.ts CHANGED
@@ -2,7 +2,6 @@ import * as _playwright_test from '@playwright/test';
2
2
  import { APIRequestContext, APIResponse, Page, Locator } from '@playwright/test';
3
3
  export * from '@playwright/test';
4
4
  import * as playwright_core from 'playwright-core';
5
- import { Page as Page$1 } from 'playwright-core';
6
5
  import { components } from '@shopware/api-client/admin-api-types';
7
6
  import { Image } from 'image-js';
8
7
 
@@ -529,7 +528,7 @@ interface TestDataFixtureTypes {
529
528
 
530
529
  interface HelperFixtureTypes {
531
530
  IdProvider: IdProvider;
532
- SaaSInstanceSetup: () => Promise<void>;
531
+ SaaSInstanceSetup: (page: Page) => Promise<void>;
533
532
  }
534
533
 
535
534
  interface StoreBaseConfig {
@@ -1020,7 +1019,7 @@ type OrderStatus = 'cancel' | 'complete' | 'reopen' | 'process';
1020
1019
  declare const setOrderStatus: (orderId: string, orderStatus: OrderStatus, adminApiContext: AdminApiContext) => Promise<APIResponse>;
1021
1020
 
1022
1021
  declare const isSaaSInstance: (adminApiContext: AdminApiContext) => Promise<boolean>;
1023
- declare const isThemeCompiled: (page: Page$1) => Promise<boolean>;
1022
+ declare const isThemeCompiled: (context: AdminApiContext, storefrontUrl: string) => Promise<boolean>;
1024
1023
 
1025
1024
  declare function createRandomImage(width?: number, height?: number): Image;
1026
1025
 
package/dist/index.mjs CHANGED
@@ -200,23 +200,6 @@ const setOrderStatus = async (orderId, orderStatus, adminApiContext) => {
200
200
  return await adminApiContext.post(`./_action/order/${orderId}/state/${orderStatus}`);
201
201
  };
202
202
 
203
- const isSaaSInstance = async (adminApiContext) => {
204
- const instanceFeatures = await adminApiContext.get("./instance/features");
205
- return instanceFeatures.ok();
206
- };
207
- const isThemeCompiled = async (page) => {
208
- let allCSSFound = false;
209
- const listener = (request) => {
210
- if (request.url().includes("all.css")) {
211
- allCSSFound = true;
212
- }
213
- };
214
- page.on("request", listener);
215
- await page.goto("./", { waitUntil: "load" });
216
- page.off("request", listener);
217
- return allCSSFound;
218
- };
219
-
220
203
  const test$b = test$d.extend({
221
204
  SalesChannelBaseConfig: [
222
205
  async ({ AdminApiContext }, use) => {
@@ -403,31 +386,6 @@ const test$b = test$d.extend({
403
386
  });
404
387
  },
405
388
  { scope: "worker" }
406
- ],
407
- DefaultStorefront: [
408
- async ({ browser, AdminApiContext, DefaultSalesChannel, SalesChannelBaseConfig }, use) => {
409
- const { id: uuid } = DefaultSalesChannel.salesChannel;
410
- const isSaasInstance = await isSaaSInstance(AdminApiContext);
411
- const tmpContext = await browser.newContext({
412
- baseURL: DefaultSalesChannel.url
413
- });
414
- const tmpPage = await tmpContext.newPage();
415
- if (!await isThemeCompiled(tmpPage)) {
416
- test$d.slow();
417
- await AdminApiContext.post(
418
- `./_action/theme/${SalesChannelBaseConfig.defaultThemeId}/assign/${uuid}`
419
- );
420
- if (isSaasInstance) {
421
- while (!await isThemeCompiled(tmpPage)) {
422
- await tmpPage.waitForTimeout(2e3);
423
- }
424
- }
425
- }
426
- await use({
427
- ...DefaultSalesChannel
428
- });
429
- },
430
- { scope: "worker" }
431
389
  ]
432
390
  });
433
391
 
@@ -671,6 +629,22 @@ async function mockApiCalls(page) {
671
629
  }));
672
630
  }
673
631
 
632
+ const isSaaSInstance = async (adminApiContext) => {
633
+ const instanceFeatures = await adminApiContext.get("./instance/features");
634
+ return instanceFeatures.ok();
635
+ };
636
+ const isThemeCompiled = async (context, storefrontUrl) => {
637
+ const response = await context.get(storefrontUrl);
638
+ const body = (await response.body()).toString();
639
+ const matches = body.match(/.*"(https:\/\/.*all\.css[^"]*)".*/);
640
+ if (matches && matches?.length > 1) {
641
+ const allCssUrl = matches[1];
642
+ const allCssResponse = await context.get(allCssUrl);
643
+ return allCssResponse.status() < 400;
644
+ }
645
+ return false;
646
+ };
647
+
674
648
  const test$9 = test$d.extend({
675
649
  AdminPage: async ({ IdProvider, AdminApiContext, SalesChannelBaseConfig, browser }, use) => {
676
650
  const context = await browser.newContext({
@@ -721,15 +695,26 @@ const test$9 = test$d.extend({
721
695
  await use(page);
722
696
  await page.close();
723
697
  await context.close();
724
- const cleanupResponse = await AdminApiContext.delete(`user/${uuid}`);
725
- expect(cleanupResponse.ok()).toBeTruthy();
698
+ await AdminApiContext.delete(`user/${uuid}`);
726
699
  },
727
- StorefrontPage: async ({ DefaultStorefront, browser }, use) => {
728
- const { url } = DefaultStorefront;
700
+ StorefrontPage: async ({ DefaultSalesChannel, SalesChannelBaseConfig, browser, AdminApiContext }, use) => {
701
+ const { url, salesChannel } = DefaultSalesChannel;
729
702
  const context = await browser.newContext({
730
703
  baseURL: url
731
704
  });
732
705
  const page = await context.newPage();
706
+ const isSaasInstance = await isSaaSInstance(AdminApiContext);
707
+ if (!await isThemeCompiled(AdminApiContext, DefaultSalesChannel.url)) {
708
+ test$d.slow();
709
+ await AdminApiContext.post(
710
+ `./_action/theme/${SalesChannelBaseConfig.defaultThemeId}/assign/${salesChannel.id}`
711
+ );
712
+ if (isSaasInstance) {
713
+ while (!await isThemeCompiled(AdminApiContext, DefaultSalesChannel.url)) {
714
+ await page.waitForTimeout(4e3);
715
+ }
716
+ }
717
+ }
733
718
  await page.goto("./", { waitUntil: "load" });
734
719
  await use(page);
735
720
  await page.close();
@@ -1856,15 +1841,14 @@ const test$6 = test$d.extend({
1856
1841
  { scope: "worker" }
1857
1842
  ],
1858
1843
  SaaSInstanceSetup: [
1859
- async ({ AdminApiContext, browser }, use) => {
1860
- const SetupInstance = async function SetupInstance2() {
1844
+ async ({ AdminApiContext }, use) => {
1845
+ const SetupInstance = async function SetupInstance2(page) {
1861
1846
  await test$6.skip(!await isSaaSInstance(AdminApiContext), "Skipping SaaS setup, could not detect SaaS instance");
1862
1847
  const instanceStatusResponse = await AdminApiContext.get("./instance/status");
1863
1848
  const instanceStatus = await instanceStatusResponse.json();
1864
1849
  await expect(instanceStatus.tags, 'expect instance to have "ci" tag').toContain("ci");
1865
1850
  await test$6.skip((await AdminApiContext.get(`${process.env.APP_URL}constructionmode`, { maxRedirects: 0 })).status() > 204, "Instance already setup");
1866
- const page = await browser.newPage({ baseURL: process.env.ADMIN_URL });
1867
- await page.goto("./set-up-shop");
1851
+ await page.goto(`${process.env.ADMIN_URL}set-up-shop`);
1868
1852
  await page.getByRole("button", { name: "Next" }).click();
1869
1853
  await expect(page.getByRole("heading", { name: "Everything finished!" })).toBeVisible();
1870
1854
  await page.getByRole("button", { name: "Open your shop" }).click();
@@ -1873,6 +1857,7 @@ const test$6 = test$d.extend({
1873
1857
  await page.getByLabel("Password").fill(AdminApiContext.options.admin_password ?? "shopware");
1874
1858
  await page.getByRole("button", { name: "Log in" }).click();
1875
1859
  await page.getByRole("button", { name: "Launch your business" }).click();
1860
+ await expect(page.getByRole("button", { name: "Launch your business" })).toBeHidden();
1876
1861
  };
1877
1862
  await use(SetupInstance);
1878
1863
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopware-ag/acceptance-test-suite",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Shopware Acceptance Test Suite",
5
5
  "author": "shopware AG",
6
6
  "license": "MIT",