From f35d943128d677c5aa47aa194d94c22c140d65aa Mon Sep 17 00:00:00 2001 From: JC Date: Fri, 14 Apr 2023 08:33:21 -0600 Subject: [PATCH] Fix: test -> getting batch size from the screen --- components/SyncReport/SyncReport.tsx | 1 + e2e/sync_report.test.js | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/components/SyncReport/SyncReport.tsx b/components/SyncReport/SyncReport.tsx index e09b6e304..80d3b02ae 100644 --- a/components/SyncReport/SyncReport.tsx +++ b/components/SyncReport/SyncReport.tsx @@ -517,6 +517,7 @@ const SyncReport: React.FunctionComponent = ({ closeModal }) => } /> diff --git a/e2e/sync_report.test.js b/e2e/sync_report.test.js index 1ee163a39..fab194262 100644 --- a/e2e/sync_report.test.js +++ b/e2e/sync_report.test.js @@ -12,45 +12,58 @@ describe('Renders Sync Report data (blocks & batches) correctly.', () => { await element(by.id('header.drawmenu')).tap(); await element(by.id('menu.syncreport')).tap(); - // 10 seconds of timeout. + // waiting for starting the sync process await waitFor(element(by.id('syncreport.currentbatch'))).toBeVisible().withTimeout(10000); + // put the App in background await device.sendToHome(); + // put the App to sleep because we need some progress in BS to reproduce the bug await sleep(20000); + // put the App in foregroung again await device.launchApp({ newInstance: false }); - // 10 seconds of timeout. + // waiting for starting the sync process again await waitFor(element(by.id('syncreport.currentbatch'))).toBeVisible().withTimeout(10000); + // getting current batch & total batches from the screen const batches = element(by.id('syncreport.currentbatch')); const batches_attributes = await batches.getAttributes(); const batchNum = Number(batches_attributes.text.split(':')[1].split('of')[0]); const batchesNum = Number(batches_attributes.text.split(':')[2]); + // getting blocks now synced from the screen const blockssyncednow = element(by.id('syncreport.syncednow')); const blockssyncednow_attributes = await blockssyncednow.getAttributes(); const blockssyncednowNum = Number(blockssyncednow_attributes.text.split(' ')[0]); + // getting blocks not yet sync from the screen const blocksnotyetsynced = element(by.id('syncreport.notyetsynced')); const blocksnotyetsynced_attributes = await blocksnotyetsynced.getAttributes(); const blocksnotyetsyncedNum = Number(blocksnotyetsynced_attributes.text.split(' ')[0]); + // calculating total blocks in this sync process const blockstotalNum = blockssyncednowNum + blocksnotyetsyncedNum; + // getting blocks per batch or batch size from the screen + const batchsize = element(by.id('syncreport.blocksperbatch')); + const batchsize_attributes = await batchsize.getAttributes(); + const batchsizeNum = Number(batchsize_attributes.text); + log.info('batches', batchNum); log.info('total batches', batchesNum); log.info('blocks sync now', blockssyncednowNum); log.info('blocks not yet sync', blocksnotyetsyncedNum); log.info('blocks total', blockstotalNum); + log.info('batch size:', batchsizeNum); // a couple of examples: // batch: 1 -> means blocks between 0 and 100 // batch: 33 -> means blocks between 3200 and 3300 - if (blockssyncednowNum < (batchNum * 100) - 100 || blockssyncednowNum > (batchNum * 100)) { + if (blockssyncednowNum < (batchNum * batchsizeNum) - batchsizeNum || blockssyncednowNum > (batchNum * batchsizeNum)) { fail('The synced blocks are not align with the synced batches'); } - if (blockstotalNum < (batchesNum * 100) - 100 || blockstotalNum > (batchesNum * 100)) { + if (blockstotalNum < (batchesNum * batchsizeNum) - batchsizeNum || blockstotalNum > (batchesNum * batchsizeNum)) { fail('The total blocks in this process are not align with the total of batches'); } });