Skip to content

Commit

Permalink
Fix ats suite for different Shopware versions
Browse files Browse the repository at this point in the history
  • Loading branch information
seggewiss committed Oct 7, 2024
1 parent 9fdf69a commit 4d5693a
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 19 deletions.
14 changes: 14 additions & 0 deletions examples/TestPlugin/tests/acceptance/fixtures/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ export async function getSDKiFrame(

return frame;
}

/**
* Mocks the check updates call to return null.
*
* This method is called before each test case to prevent the "Updates available"
* notification from interfering with tests on older Shopware versions.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export async function mockUpdateApi(page: Page): Promise<any> {
return page.route('*/**/_action/update/check', async (route) => {
const json = null;
await route.fulfill({ json });
});
}
7 changes: 0 additions & 7 deletions examples/TestPlugin/tests/acceptance/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,6 @@ const config: PlaywrightTestConfig = {
...devices['Desktop Chrome'],
},
},

{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
},
},
],

/* Folder for test artifacts such as screenshots, videos, traces, etc. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, TestDataService, AdminProductDetail }) => {
await mockUpdateApi(ShopAdmin.page);

const product = await TestDataService.createBasicProduct();
ShopAdmin.goesTo(AdminProductDetail.url(product.id));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, TestDataService, AdminProductDetail }) => {
await mockUpdateApi(ShopAdmin.page);

const product = await TestDataService.createBasicProduct();
ShopAdmin.goesTo(AdminProductDetail.url(product.id));

Expand Down
4 changes: 3 additions & 1 deletion examples/TestPlugin/tests/acceptance/tests/context.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

// Defaults
const DEFAULT_LANGUAGE_ID = '2fbb5fe2e29a4d70aa5854ce7ce3e20b';
Expand All @@ -10,6 +10,8 @@ const FALLBACK_LOCALE = 'en-GB';
let productId = '';

test.beforeEach(async ({ ShopAdmin, TestDataService, AdminDashboard }) => {
await mockUpdateApi(ShopAdmin.page);

// Create product and assign id
const product = await TestDataService.createBasicProduct();
productId = product.id;
Expand Down
4 changes: 3 additions & 1 deletion examples/TestPlugin/tests/acceptance/tests/dataset.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin }) => {
await mockUpdateApi(ShopAdmin.page);

// Go to settings
await ShopAdmin.goesTo('/admin/#sw/settings/index/shop');

Expand Down
4 changes: 3 additions & 1 deletion examples/TestPlugin/tests/acceptance/tests/location.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, TestDataService, AdminProductDetail }) => {
await mockUpdateApi(ShopAdmin.page);

// Create product and open detail page
const product = await TestDataService.createBasicProduct();
await ShopAdmin.goesTo(AdminProductDetail.url(product.id));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin }) => {
await mockUpdateApi(ShopAdmin.page);

await ShopAdmin.goesTo('/admin/#/sw/extension/my-extensions/listing/');

const mainHidden = await getSDKiFrame(ShopAdmin.page, 'sw-main-hidden');
Expand Down
4 changes: 3 additions & 1 deletion examples/TestPlugin/tests/acceptance/tests/menu-item.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, AdminDashboard }) => {
await mockUpdateApi(ShopAdmin.page);

await ShopAdmin.goesTo(AdminDashboard.url());

const mainHidden = await getSDKiFrame(ShopAdmin.page, 'sw-main-hidden');
Expand Down
4 changes: 3 additions & 1 deletion examples/TestPlugin/tests/acceptance/tests/modals.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, TestDataService, AdminProductDetail }) => {
await mockUpdateApi(ShopAdmin.page);

const product = await TestDataService.createBasicProduct();
await ShopAdmin.goesTo(AdminProductDetail.url(product.id));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, AdminDashboard }) => {
await mockUpdateApi(ShopAdmin.page);

await ShopAdmin.goesTo(AdminDashboard.url());

// The main hidden iFrame should exist
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin }) => {
await mockUpdateApi(ShopAdmin.page);

await ShopAdmin.goesTo('/admin/#sw/settings/index/shop');

const mainHidden = await getSDKiFrame(ShopAdmin.page, 'sw-main-hidden');
Expand Down
4 changes: 3 additions & 1 deletion examples/TestPlugin/tests/acceptance/tests/tabs.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, TestDataService, AdminProductDetail }) => {
await mockUpdateApi(ShopAdmin.page);

const product = await TestDataService.createBasicProduct();
await ShopAdmin.goesTo(AdminProductDetail.url(product.id));

Expand Down
4 changes: 3 additions & 1 deletion examples/TestPlugin/tests/acceptance/tests/window.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { test, expect } from '../fixtures/AcceptanceTest';
import { getSDKiFrame } from '../fixtures/Helper';
import { getSDKiFrame, mockUpdateApi } from '../fixtures/Helper';

test.beforeEach(async ({ ShopAdmin, AdminDashboard }) => {
await mockUpdateApi(ShopAdmin.page);

await ShopAdmin.goesTo(AdminDashboard.url());

// The main hidden iFrame should exist
Expand Down

0 comments on commit 4d5693a

Please sign in to comment.