Skip to content

Commit

Permalink
removed soft expect helper
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Oct 31, 2024
1 parent 771232c commit a86706f
Show file tree
Hide file tree
Showing 16 changed files with 1,217 additions and 2,497 deletions.
1 change: 1 addition & 0 deletions lib/helper/JSONResponse.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const Helper = require('@codeceptjs/helper')

const chai = require('chai')

const expect = chai.expect
chai.use(require('chai-deep-match'))
const joi = require('joi')
Expand Down
381 changes: 0 additions & 381 deletions lib/helper/SoftExpectHelper.js

This file was deleted.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"figures": "3.2.0",
"fn-args": "4.0.0",
"fs-extra": "11.2.0",
"glob": "6.0.1",
"glob": "^9",
"html-minifier-terser": "7.2.0",
"inquirer": "6.5.2",
"joi": "17.13.3",
Expand Down Expand Up @@ -125,7 +125,7 @@
"@wdio/selenium-standalone-service": "8.3.2",
"@wdio/utils": "9.1.2",
"@xmldom/xmldom": "0.9.4",
"apollo-server-express": "2.25.3",
"@apollo/server": "^4",
"chai-as-promised": "7.1.2",
"chai-subset": "1.6.0",
"cheerio": "^1.0.0",
Expand All @@ -141,7 +141,7 @@
"graphql": "16.9.0",
"husky": "9.1.6",
"inquirer-test": "2.0.1",
"jsdoc": "4.0.3",
"jsdoc": "^3",
"jsdoc-typeof-plugin": "1.0.0",
"json-server": "0.10.1",
"playwright": "1.48.2",
Expand All @@ -150,7 +150,6 @@
"qrcode-terminal": "0.12.0",
"rosie": "2.1.1",
"runok": "0.9.3",
"semver": "7.6.3",
"sinon": "18.0.0",
"sinon-chai": "3.7.0",
"testcafe": "3.5.0",
Expand Down
219 changes: 110 additions & 109 deletions test/helper/AppiumV2_ios_test.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
const chai = require('chai');
const expect = chai.expect;
const assert = chai.assert;
const path = require('path');
const chai = require('chai')

const Appium = require('../../lib/helper/Appium');
const AssertionFailedError = require('../../lib/assert/error');
const fileExists = require('../../lib/utils').fileExists;
global.codeceptjs = require('../../lib');
const expect = chai.expect
const assert = chai.assert
const path = require('path')

let app;
const Appium = require('../../lib/helper/Appium')
const AssertionFailedError = require('../../lib/assert/error')
const fileExists = require('../../lib/utils').fileExists
global.codeceptjs = require('../../lib')

let app
// iOS test app is built from https://github.com/appium/ios-test-app and uploaded to Saucelabs
const apk_path = 'storage:filename=TestApp-iphonesimulator.zip';
const smallWait = 3;
const apk_path = 'storage:filename=TestApp-iphonesimulator.zip'
const smallWait = 3

describe('Appium iOS Tests', function () {
this.timeout(0);
this.timeout(0)

before(async () => {
global.codecept_dir = path.join(__dirname, '/../data');
global.codecept_dir = path.join(__dirname, '/../data')
app = new Appium({
app: apk_path,
appiumV2: true,
Expand All @@ -40,166 +41,166 @@ describe('Appium iOS Tests', function () {
port: 80,
user: process.env.SAUCE_USERNAME,
key: process.env.SAUCE_ACCESS_KEY,
});
await app._beforeSuite();
app.isWeb = false;
await app._before();
});
})
await app._beforeSuite()
app.isWeb = false
await app._before()
})

after(async () => {
await app._after();
});
await app._after()
})

describe('app installation : #removeApp', () => {
describe('#grabAllContexts, #grabContext, #grabOrientation, #grabSettings', () => {
it('should grab all available contexts for screen', async () => {
await app.resetApp();
const val = await app.grabAllContexts();
assert.deepEqual(val, ['NATIVE_APP']);
});
await app.resetApp()
const val = await app.grabAllContexts()
assert.deepEqual(val, ['NATIVE_APP'])
})

it('should grab current context', async () => {
const val = await app.grabContext();
assert.equal(val, 'NATIVE_APP');
});
const val = await app.grabContext()
assert.equal(val, 'NATIVE_APP')
})

it('should grab custom settings', async () => {
const val = await app.grabSettings();
assert.deepEqual(val, { imageElementTapStrategy: 'w3cActions' });
});
});
});
const val = await app.grabSettings()
assert.deepEqual(val, { imageElementTapStrategy: 'w3cActions' })
})
})
})

describe('device orientation : #seeOrientationIs #setOrientation', () => {
it('should return correct status about device orientation', async () => {
await app.seeOrientationIs('PORTRAIT');
await app.seeOrientationIs('PORTRAIT')
try {
await app.seeOrientationIs('LANDSCAPE');
await app.seeOrientationIs('LANDSCAPE')
} catch (e) {
e.should.be.instanceOf(AssertionFailedError);
e.inspect().should.include('expected orientation to be LANDSCAPE');
e.should.be.instanceOf(AssertionFailedError)
e.inspect().should.include('expected orientation to be LANDSCAPE')
}
});
});
})
})

describe('#hideDeviceKeyboard', () => {
it('should hide device Keyboard @quick', async () => {
await app.resetApp();
await app.click('~IntegerA');
await app.resetApp()
await app.click('~IntegerA')
try {
await app.click('~locationStatus');
await app.click('~locationStatus')
} catch (e) {
e.message.should.include('element');
e.message.should.include('element')
}
await app.hideDeviceKeyboard('pressKey', 'Done');
await app.click('~locationStatus');
});
await app.hideDeviceKeyboard('pressKey', 'Done')
await app.click('~locationStatus')
})

it('should assert if no keyboard', async () => {
try {
await app.hideDeviceKeyboard('pressKey', 'Done');
await app.hideDeviceKeyboard('pressKey', 'Done')
} catch (e) {
e.message.should.include(
'An unknown server-side error occurred while processing the command. Original error: Soft keyboard not present, cannot hide keyboard',
);
)
}
});
});
})
})

describe('see text : #see', () => {
it('should work inside elements @second', async () => {
await app.resetApp();
await app.see('Compute Sum', '~ComputeSumButton');
});
});
await app.resetApp()
await app.see('Compute Sum', '~ComputeSumButton')
})
})

describe('#appendField', () => {
it('should be able to send special keys to element @second', async () => {
await app.resetApp();
await app.waitForElement('~IntegerA', smallWait);
await app.click('~IntegerA');
await app.appendField('~IntegerA', '1');
await app.hideDeviceKeyboard('pressKey', 'Done');
await app.see('1', '~IntegerA');
});
});
await app.resetApp()
await app.waitForElement('~IntegerA', smallWait)
await app.click('~IntegerA')
await app.appendField('~IntegerA', '1')
await app.hideDeviceKeyboard('pressKey', 'Done')
await app.see('1', '~IntegerA')
})
})

describe('#waitForText', () => {
it('should return error if not present', async () => {
try {
await app.waitForText('Nothing here', 1, '~IntegerA');
await app.waitForText('Nothing here', 1, '~IntegerA')
} catch (e) {
e.message.should.contain(
'element (~IntegerA) is not in DOM or there is no element(~IntegerA) with text "Nothing here" after 1 sec',
);
)
}
});
});
})
})

describe('#seeNumberOfElements @second', () => {
it('should return 1 as count', async () => {
await app.resetApp();
await app.seeNumberOfElements('~IntegerA', 1);
});
});
await app.resetApp()
await app.seeNumberOfElements('~IntegerA', 1)
})
})

describe('see element : #seeElement, #dontSeeElement', () => {
it('should check visible elements on page @quick', async () => {
await app.resetApp();
await app.seeElement('~IntegerA');
await app.dontSeeElement('#something-beyond');
await app.dontSeeElement('//input[@id="something-beyond"]');
});
});
await app.resetApp()
await app.seeElement('~IntegerA')
await app.dontSeeElement('#something-beyond')
await app.dontSeeElement('//input[@id="something-beyond"]')
})
})

describe('#click @quick', () => {
it('should click by accessibility id', async () => {
await app.resetApp();
await app.tap('~ComputeSumButton');
await app.see('0');
});
});
await app.resetApp()
await app.tap('~ComputeSumButton')
await app.see('0')
})
})

describe('#fillField @second', () => {
it('should fill field by accessibility id', async () => {
await app.resetApp();
await app.waitForElement('~IntegerA', smallWait);
await app.click('~IntegerA');
await app.fillField('~IntegerA', '1');
await app.hideDeviceKeyboard('pressKey', 'Done');
await app.see('1', '~IntegerA');
});
});
await app.resetApp()
await app.waitForElement('~IntegerA', smallWait)
await app.click('~IntegerA')
await app.fillField('~IntegerA', '1')
await app.hideDeviceKeyboard('pressKey', 'Done')
await app.see('1', '~IntegerA')
})
})

describe('#grabTextFrom, #grabValueFrom, #grabAttributeFrom @quick', () => {
it('should grab text from page', async () => {
await app.resetApp();
const val = await app.grabTextFrom('~ComputeSumButton');
assert.equal(val, 'Compute Sum');
});
await app.resetApp()
const val = await app.grabTextFrom('~ComputeSumButton')
assert.equal(val, 'Compute Sum')
})

it('should grab attribute from element', async () => {
await app.resetApp();
const val = await app.grabAttributeFrom('~ComputeSumButton', 'label');
assert.equal(val, 'Compute Sum');
});
await app.resetApp()
const val = await app.grabAttributeFrom('~ComputeSumButton', 'label')
assert.equal(val, 'Compute Sum')
})

it('should be able to grab elements', async () => {
await app.resetApp();
const id = await app.grabNumberOfVisibleElements('~ComputeSumButton');
assert.strictEqual(1, id);
});
});
await app.resetApp()
const id = await app.grabNumberOfVisibleElements('~ComputeSumButton')
assert.strictEqual(1, id)
})
})

describe('#saveScreenshot', () => {
beforeEach(() => {
global.output_dir = path.join(global.codecept_dir, 'output');
});
global.output_dir = path.join(global.codecept_dir, 'output')
})

it('should create a screenshot file in output dir', async () => {
const sec = new Date().getUTCMilliseconds();
await app.saveScreenshot(`screenshot_${sec}.png`);
assert.ok(fileExists(path.join(global.output_dir, `screenshot_${sec}.png`)), null, 'file does not exists');
});
});
});
const sec = new Date().getUTCMilliseconds()
await app.saveScreenshot(`screenshot_${sec}.png`)
assert.ok(fileExists(path.join(global.output_dir, `screenshot_${sec}.png`)), null, 'file does not exists')
})
})
})
7 changes: 4 additions & 3 deletions test/helper/AppiumV2_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const chai = require('chai');
const expect = chai.expect;
const assert = chai.assert;
const chai = require('chai')

const expect = chai.expect
const assert = chai.assert

let app
const apk_path = 'storage:filename=selendroid-test-app-0.17.0.apk'
Expand Down
7 changes: 4 additions & 3 deletions test/helper/Appium_test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const chai = require('chai');
const expect = chai.expect;
const assert = chai.assert;
const chai = require('chai')

const expect = chai.expect
const assert = chai.assert

const path = require('path')

Expand Down
Loading

0 comments on commit a86706f

Please sign in to comment.