Skip to content

Commit

Permalink
Fix: test -> getting batch size from the screen
Browse files Browse the repository at this point in the history
  • Loading branch information
juanky201271 committed Apr 14, 2023
1 parent 3664fc4 commit f35d943
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions components/SyncReport/SyncReport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ const SyncReport: React.FunctionComponent<SyncReportProps> = ({ closeModal }) =>
}
/>
<DetailLine
testID="syncreport.blocksperbatch"
label={translate('report.blocksperbatch') as string}
value={syncingStatusReport.blocksPerBatch.toString()}
/>
Expand Down
21 changes: 17 additions & 4 deletions e2e/sync_report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
});
Expand Down

0 comments on commit f35d943

Please sign in to comment.