Skip to content

Using ATS with headless storefront (Shopware Frontends) #560

Description

@krzysztofkaszanek

Hi, I'm exploring the new Acceptance Test Suite and I think it's a great improvement from the e2e-testsuite-platform that we were using in our E2E tests before.

ATS works great with standard Shopware projects that use the Twig Storefront. But I struggle to make it work with a project based on the Shopware Frontends (Nuxt.js storefront). The main problem is that baseUrl of the tests is overwritten here:

const baseUrl = `${SalesChannelBaseConfig.appUrl}test-${uuid}/`;

StorefrontPage: async ({ DefaultSalesChannel, SalesChannelBaseConfig, browser, AdminApiContext, InstanceMeta, CustomTranslationResources }, use) => {
const { url, salesChannel } = DefaultSalesChannel;
const locale = getLocale();
const languageHelper = await LanguageHelper.createInstance(locale, CustomTranslationResources);
const context = await browser.newContext({
baseURL: url,
locale,
extraHTTPHeaders: { 'Accept-Language': locale },
});
LanguageHelper.setForContext(context as unknown as Record<string, unknown>, languageHelper);
// Set context for this execution thread
setCurrentContext(context as unknown as Record<string, unknown>);
let page;
if (!(await isThemeCompiled(AdminApiContext, DefaultSalesChannel.url))) {
base.slow();
await AdminApiContext.post(`./_action/theme/${SalesChannelBaseConfig.defaultThemeId}/assign/${salesChannel.id}`);
await clearDelayedCache(AdminApiContext);
page = await context.newPage();
if (InstanceMeta.isSaaS) {
while (!(await isThemeCompiled(AdminApiContext, DefaultSalesChannel.url))) {
await clearDelayedCache(AdminApiContext);
await page.waitForTimeout(4000);
}
}
} else {
page = await context.newPage();
}
await page.goto('./', { waitUntil: 'load' });
await use(page);
await page.close();
setCurrentContext(null);
await context.close();
},

As a result all "page.goto"s are prefixed with ${SalesChannelBaseConfig.appUrl}test-${uuid}/. As opposed to the Standard Storefront, our headless Storefront doesn't handle this Sales Channel domain prefix, as far as I know the demo template also doesn't implement it.

I tried to go around it, by trying to only use TestDataService in my test - to create some basic data, and then continue with standard Playwright page object. However, as soon as I add page fixture in my tests, I notice there is a bunch of additional fixtures from ATS fired in the "Before Hooks" steps, so it looks like page is also overwritten by ATS at some point, making this workaround not feasible.

Do you know, if there is a way to use ATS (or parts of it, like TestDataService), without overwriting the baseUrl and page fixture? I would really appreciate any tips and suggestions. Thank you!

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions