Skip to content

Commit 9789ed3

Browse files
Merge pull request #87 from LambdaTest/stage
Support for large tests in result table
2 parents 0958142 + 30b25bb commit 9789ed3

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

commands/utils/polling.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ const Table = require('cli-table3');
33
var { constants } = require('./constants');
44

55
var INTERVAL = 2000
6-
const MAX_INTERVAL = 512000
6+
const MAX_EXPONENTIAL_INTERVAL = 512000 // 512 seconds (8.5 minutes)
7+
const FIXED_INTERVAL = 60000 // 1 minute in milliseconds
8+
const MAX_INTERVAL = 1800000; // 30 minutes in milliseconds
9+
var CURRENT_TIME = 0
10+
var FLAG = 0
711

812
async function shortPolling(buildId, retries = 0, options) {
913
await axios.get(new URL('?buildId=' + buildId, constants[options.env].BUILD_STATUS_URL).href, {
@@ -28,16 +32,18 @@ async function shortPolling(buildId, retries = 0, options) {
2832
import('chalk').then((chalk) => {
2933
const table = new Table({
3034
head: [
35+
{content: chalk.default.white('Sr. Number'), hAlign: 'center'},
3136
{content: chalk.default.white('Story'), hAlign: 'center'},
3237
{content: chalk.default.white('Mis-match %'), hAlign: 'center'},
3338
]
3439
});
35-
response.data.screenshots.forEach(screenshot => {
36-
let mismatch = screenshot.mismatchPercentage
40+
response.data.screenshots.forEach((screenshot, index) => {
41+
let mismatch = screenshot.mismatchPercentage;
3742
table.push([
43+
chalk.default.yellow(index + 1),
3844
chalk.default.yellow(screenshot.storyName),
3945
mismatch > 0 ? chalk.default.red(mismatch) : chalk.default.green(mismatch)
40-
])
46+
]);
4147
});
4248
console.log(table.toString());
4349

@@ -55,19 +61,26 @@ async function shortPolling(buildId, retries = 0, options) {
5561
return;
5662
} else {
5763
if (response.data.screenshots && response.data.screenshots.length > 0) {
58-
// TODO: show Screenshots processed current/total
64+
// TODO: show Screenshots processed current/total
5965
console.log('[smartui] Screenshots compared: ', response.data.screenshots.length)
6066
}
6167
}
6268
}
63-
64-
// Double the INTERVAL, up to the maximum INTERVAL of 512 secs (so ~15 mins in total)
65-
INTERVAL = Math.min(INTERVAL * 2, MAX_INTERVAL);
66-
if (INTERVAL == MAX_INTERVAL) {
69+
70+
CURRENT_TIME = CURRENT_TIME + INTERVAL
71+
if (CURRENT_TIME >= MAX_INTERVAL) {
6772
console.log('[smartui] Please check the build status on LambdaTest SmartUI.');
6873
return;
6974
}
7075

76+
// Adjust the interval
77+
if (Math.min(INTERVAL * 2, MAX_EXPONENTIAL_INTERVAL) < MAX_EXPONENTIAL_INTERVAL && FLAG == 0) {
78+
INTERVAL = Math.min(INTERVAL * 2, MAX_EXPONENTIAL_INTERVAL);
79+
} else {
80+
FLAG = 1
81+
INTERVAL = FIXED_INTERVAL; // Switch to fixed interval after reaching 256 seconds
82+
}
83+
7184
setTimeout(function () {
7285
shortPolling(buildId, 0, options)
7386
}, INTERVAL);

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-storybook",
3-
"version": "1.1.17",
3+
"version": "1.1.18",
44
"description": "LambdaTest's command-line interface (CLI) aimed to help you run your SmartUI tests on LambdaTest platform",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)