Skip to content

Commit

Permalink
fix(tests): fix timeout testing
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Feb 15, 2021
1 parent 0f59293 commit 826b3a7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
13 changes: 12 additions & 1 deletion tests/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,18 @@ const startApplication = function() {
waitTimeout: 30000,
quitTimeout: 15000
});
return this.app.start();
return this.app.start().then(() => {
this.app.client.notExisting$ = async (selector) => {
const waitforTimeout = this.app.client.options.waitforTimeout;
this.app.client.options.waitforTimeout = 150;
await this.app.client.setTimeouts(this.app.client.options.waitforTimeout, this.app.client.options.waitforTimeout, this.app.client.options.waitforTimeout);
const notExistElement = await this.app.client.$(selector)
const isExist = await notExistElement.isExisting();
this.app.client.options.waitforTimeout = waitforTimeout;
await this.app.client.setTimeouts(this.app.client.options.waitforTimeout, this.app.client.options.waitforTimeout, this.app.client.options.waitforTimeout);
return !isExist
}
});
};

const stopApplication = function() {
Expand Down
10 changes: 3 additions & 7 deletions tests/download.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,14 @@ describe("download", function() {
const { app } = this
await app.client.$('.torrentRow .progressDownloading')
console.log('download progress', await (await app.client.$('.torrentRow .progressDownloading')).getText());
app.client.options.waitforTimeout = 60000
await app.client.waitUntil(async () => {
return (await (await app.client.$('.torrentRow .progressDownloading')).getText()) === '100.0%'
}, 60000, 'expected that download will be finished', 200)
app.client.options.waitforTimeout = 500
// There is some time before button will be replaced
await asyncWait(800);

// Check Buttons After finish
assert(!(await (await app.client.$('.torrentRow .deleteDownloadBeforeFinish')).isExisting()));
assert(await app.client.notExisting$('.torrentRow .deleteDownloadBeforeFinish'));
})

it("check file after download", async function() {
Expand All @@ -81,7 +79,7 @@ describe("download", function() {
assert.equal(await (await app.client.$('.search-list .torrentRow .progressDownloading')).getText(), '100.0%')
// Click cancel of download
await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).click()
assert(!(await (await app.client.$('.torrentRow .deleteDownloadAfterFinish')).isExisting()));
assert(await app.client.notExisting$('.torrentRow .deleteDownloadAfterFinish'));
// Download deleted, but must be keeped in search
const value = await (await app.client.$('.search-list .torrentRow .torrentName')).getText()
assert.equal(value, 'Roblox_setup.exe')
Expand All @@ -92,7 +90,7 @@ describe("download", function() {
const { app } = this
await (await app.client.$('#downloadTab')).click()
await app.client.$('.downloads-list')
assert(!(await (await app.client.$('.torrentRow')).isExisting()));
assert(await app.client.notExisting$('.torrentRow'));
})

it("file must still exists after delete from manager", async function() {
Expand All @@ -115,11 +113,9 @@ describe("download", function() {
}, fileFolder)
await (await app.client.$('.torrentRow .downloadDirectoryButton')).click()
// Downloading check
app.client.options.waitforTimeout = 60000
await app.client.waitUntil(async () => {
return (await (await app.client.$('.torrentRow .progressDownloading')).getText()) === '100.0%'
}, 60000, 'expected that download will be finished', 200)
app.client.options.waitforTimeout = 500
// Check downloaded to directory
assert(fs.existsSync(fileFolderTest));
assert.equal(await md5(fileFolderTest), '7df171da63e2013c9b17e1857615b192');
Expand Down

0 comments on commit 826b3a7

Please sign in to comment.