-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from shopware/move-theme-compilation
fix: move the theme compilation into the StorefrontPage fixture
- Loading branch information
Showing
5 changed files
with
43 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,23 @@ | ||
import { Page, Request } from 'playwright-core'; | ||
import { type AdminApiContext } from './AdminApiContext'; | ||
|
||
export const isSaaSInstance = async (adminApiContext: AdminApiContext): Promise<boolean> => { | ||
const instanceFeatures = await adminApiContext.get('./instance/features'); | ||
return instanceFeatures.ok(); | ||
}; | ||
|
||
export const isThemeCompiled = async (page: Page): Promise<boolean> => { | ||
let allCSSFound = false; | ||
export const isThemeCompiled = async (context: AdminApiContext, storefrontUrl: string): Promise<boolean> => { | ||
const response = await context.get(storefrontUrl); | ||
|
||
const listener = (request: Request) => { | ||
if (request.url().includes('all.css')) { | ||
allCSSFound = true; | ||
} | ||
}; | ||
const body = (await response.body()).toString(); | ||
|
||
/** | ||
* We request the storefront index and see if a all.css is loaded. | ||
* If that does not happen, the theme is not assigned/compiled | ||
*/ | ||
page.on('request', listener); | ||
await page.goto('./', { waitUntil: 'load' }); | ||
page.off('request', listener); | ||
const matches = body.match(/.*"(https:\/\/.*all\.css[^"]*)".*/); | ||
if (matches && matches?.length > 1) { | ||
const allCssUrl = matches[1]; | ||
|
||
return allCSSFound; | ||
const allCssResponse = await context.get(allCssUrl); | ||
|
||
return allCssResponse.status() < 400; | ||
} | ||
|
||
return false; | ||
}; |