fix(tests): fix timeout testing

This commit is contained in:
Alexey Kasyanchuk 2021-02-15 15:57:01 +03:00
parent 4c1c730094
commit 1c8b3a36a2
2 changed files with 15 additions and 8 deletions

View File

@ -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() {

View File

@ -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() {
@ -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')
@ -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() {
@ -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');