Skip to content

Commit 7f77dc3

Browse files
author
DavertMik
committed
added test for case insensitive opt
1 parent 38123e9 commit 7f77dc3

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

lib/helper/Playwright.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3500,7 +3500,6 @@ async function proceedSee(assertType, text, context, strict = false) {
35003500
}
35013501

35023502
if (store?.currentStep?.opts?.ignoreCase === true) {
3503-
description = description.toLowerCase()
35043503
text = text.toLowerCase()
35053504
allText = allText.map(elText => elText.toLowerCase())
35063505
}

lib/helper/Puppeteer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2769,6 +2769,11 @@ async function proceedSee(assertType, text, context, strict = false) {
27692769
allText = await Promise.all(els.map(el => el.getProperty('innerText').then(p => p.jsonValue())))
27702770
}
27712771

2772+
if (store?.currentStep?.opts?.ignoreCase === true) {
2773+
text = text.toLowerCase()
2774+
allText = allText.map(elText => elText.toLowerCase())
2775+
}
2776+
27722777
if (strict) {
27732778
return allText.map(elText => equals(description)[assertType](text, elText))
27742779
}

lib/helper/WebDriver.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const Helper = require('@codeceptjs/helper')
77
const promiseRetry = require('promise-retry')
88
const stringIncludes = require('../assert/include').includes
99
const { urlEquals, equals } = require('../assert/equal')
10+
const store = require('../store')
1011
const { debug } = require('../output')
1112
const { empty } = require('../assert/empty')
1213
const { truth } = require('../assert/truth')
@@ -2698,7 +2699,14 @@ async function proceedSee(assertType, text, context, strict = false) {
26982699
const smartWaitEnabled = assertType === 'assert'
26992700
const res = await this._locate(withStrictLocator(context), smartWaitEnabled)
27002701
assertElementExists(res, context)
2701-
const selected = await forEachAsync(res, async el => this.browser.getElementText(getElementId(el)))
2702+
let selected = await forEachAsync(res, async el => this.browser.getElementText(getElementId(el)))
2703+
2704+
// apply ignoreCase option
2705+
if (store?.currentStep?.opts?.ignoreCase === true) {
2706+
text = text.toLowerCase()
2707+
selected = selected.map(elText => elText.toLowerCase())
2708+
}
2709+
27022710
if (strict) {
27032711
if (Array.isArray(selected) && selected.length !== 0) {
27042712
return selected.map(elText => equals(description)[assertType](text, elText))

test/helper/webapi.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const chai = require('chai')
2-
2+
const store = require('../../lib/store')
33
const expect = chai.expect
44
const assert = chai.assert
55
const path = require('path')
@@ -101,6 +101,17 @@ module.exports.tests = function () {
101101
await I.dontSee('Info')
102102
})
103103

104+
it('should check text on site with ignoreCase option', async () => {
105+
if (isHelper('TestCafe')) return // It won't be implemented
106+
await I.amOnPage('/')
107+
await I.see('Welcome')
108+
store.currentStep = { opts: { ignoreCase: true } }
109+
await I.see('welcome to test app!')
110+
await I.see('test link', 'a')
111+
store.currentStep = {}
112+
await I.dontSee('welcome')
113+
})
114+
104115
it('should check text inside element', async () => {
105116
await I.amOnPage('/')
106117
await I.see('Welcome to test app!', 'h1')

0 commit comments

Comments
 (0)