Skip to content

Commit

Permalink
:feat: Add command
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Mar 28, 2024
1 parent a003dba commit 63282bd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"test:online": "$npm_package_config_testCommand --tags @online",
"test:vr": "$npm_package_config_testCommand --tags @vr",
"test:llcssbg": "$npm_package_config_testCommand --tags @llcssbg",
"test:llimages": "$npm_package_config_testCommand --tags @llimg",
"test:delayjs:genesis": "THEME=genesis-sample-develop $npm_package_config_testCommand --tags @delayjs",
"test:delayjs:flatsome": "THEME=flatsome $npm_package_config_testCommand --tags @delayjs",
"test:delayjs:divi": "THEME=Divi $npm_package_config_testCommand --tags @delayjs",
Expand Down
41 changes: 28 additions & 13 deletions src/support/steps/ll-css-bg-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,35 @@ When('I go to {string} Check initial image loaded', async function (this: ICusto
});

Then('I must see other lazyloaded images', async function (this: ICustomWorld) {
const scrollPage: Promise<void> = new Promise((resolve) => {
let totalHeight = 0;
const distance = 100;
const timer = setInterval(() => {
const scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;

if(totalHeight >= scrollHeight){
clearInterval(timer);
resolve();
await this.page.evaluate(async () => {
const scrollPage: Promise<void> = new Promise((resolve) => {
let totalHeight = 0;
const distance = 100;
const timer = setInterval(() => {
const scrollHeight = document.body.scrollHeight;
window.scrollBy(0, distance);
totalHeight += distance;

if (totalHeight >= scrollHeight) {
clearInterval(timer);
resolve();
}
}, 700);
});

await scrollPage;
this.page.on('request', request => {
if (request.resourceType() === 'image') {
console.log(request.url());
//expect(images).not.toContain(LL_BACKGROUND_IMAGES.templateOne.onLoad)
}
}, 700);
});
});

await scrollPage;
this.page.on('request', request => {
if (request.resourceType() === 'image') {
console.log(request.url());
//expect(images).not.toContain(LL_BACKGROUND_IMAGES.templateOne.onLoad)
}
});
});

0 comments on commit 63282bd

Please sign in to comment.