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 8, 2024
1 parent bb26207 commit cfbcdfa
Show file tree
Hide file tree
Showing 42 changed files with 267 additions and 82 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ jobs:

- name: Symlink plugin
working-directory: shopware/custom/plugins/
run: ln -s ../../../meteor/examples/TestPlugin
run: ln -s ../../../meteor/examples/admin-sdk-plugin TestPlugin

- name: Activate TestPlugin
working-directory: shopware/
Expand Down Expand Up @@ -246,23 +246,23 @@ jobs:
run: symfony server:start --allow-http --no-tls --port=8000 -d

- name: Install playwright
working-directory: meteor/examples/TestPlugin/tests/acceptance/
working-directory: meteor/examples/admin-sdk-plugin/tests/acceptance/
run: |
pnpm install --frozen-lockfile --prefer-offline
npx playwright install --with-deps
- name: Run Playwrigth
working-directory: meteor/examples/TestPlugin/tests/acceptance/
working-directory: meteor/examples/admin-sdk-plugin/tests/acceptance/
run: npx playwright test --retries=2 --reporter=github --trace=on-first-retry --project chromium

- uses: actions/upload-artifact@v4
if: always()
with:
name: ats-test-results-${{ matrix.project }}
path: meteor/examples/TestPlugin/tests/acceptance/test-results/
path: meteor/examples/admin-sdk-plugin/tests/acceptance/test-results/

- uses: actions/upload-artifact@v4
if: always()
with:
name: ats-report-${{ matrix.project }}
path: meteor/examples/TestPlugin/tests/acceptance/playwright-report/
path: meteor/examples/admin-sdk-plugin/tests/acceptance/playwright-report/
25 changes: 25 additions & 0 deletions examples/admin-sdk-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Meteor Admin SDK Example Plugin

This package contains an example plugin. It uses the [Meteor Admin SDK](https://github.com/shopware/meteor/tree/main/packages/admin-sdk) to extend the administration.

## Prerequisites
We assume that you have a functioning Shopware 6 setup on your local machine.

## Plugin setup

1. Install all meteor dependencies: `cd <meteorRoot> && pnpm install`
2. Build all meteor packages: `cd <meteorRoot> && turbo run build`
3. Symlink the plugin to your Shopware 6 installation: `cd <shopwareRoot>/custom/plugins && ln -s <meteorRoot>/examples/admin-sdk-plugin TestPlugin`
4. It's important that the plugin Folder is named `TestPlugin` inside `custom/plugins`
5. Activate the plugin : `cd <shopwareRoot> && php bin/console plugin:refresh && php bin/console plugin:install -a -c TestPlugin`
6. Built the administration Javascript: `cd <shopwareRoot> && composer run build:js:admin`

Now you should see the plugin installed when opening the Shopware Admin and looking in "Extensions" -> "My Extensions".

## Acceptance tests

1. Create a `.env` file in `<meteorRoot>/examples/admin-sdk-plugin/tests/acceptance`
2. Specify your Shopware instance app url: `APP_URL=https://dev.local/`
3. Run the tests: `cd <meteorRoot> && pnpm --filter @shopware-ag/meteor-admin-sdk-example-plugin run test:ats`


File renamed without changes.
File renamed without changes.
File renamed without changes.
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 });
});
}
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
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
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
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
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
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
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
Expand Up @@ -243,7 +243,7 @@ export default defineComponent({
return {
id: column.property,
label: column.label,
parentGroup: (column.visible ?? true) ? "visible" : "hidden",
parentGroup: column.visible ?? true ? "visible" : "hidden",
position: column.position,
isVisible: column.visible ?? true,
isHidable: isPrimaryColumn(column) ? false : true,
Expand Down
Loading

0 comments on commit cfbcdfa

Please sign in to comment.