Skip to content

Commit 5af64a4

Browse files
committed
Make tests independent of exact button count
1 parent 7281147 commit 5af64a4

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

test/android/test.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe('Test Android unpinning', function () {
159159

160160
it("all requests should fail", async () => {
161161
const buttons = await driver.$$('android=new UiSelector().className("android.widget.Button")');
162-
expect(buttons).to.have.lengthOf(13, 'Expected buttons were not present');
162+
const buttonCount = await buttons.length;
163163

164164
buttons.map(button => button.click());
165165
await Promise.all(await buttons.map(async (button) => {
@@ -170,7 +170,7 @@ describe('Test Android unpinning', function () {
170170
}));
171171

172172
expect(seenRequests).to.have.lengthOf(0, 'Expected all requests to fail');
173-
expect(tlsFailures).to.have.lengthOf(13, 'Expected TLS failures for all requests');
173+
expect(tlsFailures).to.have.lengthOf(buttonCount, 'Expected TLS failures for all requests');
174174
});
175175

176176
});
@@ -183,7 +183,6 @@ describe('Test Android unpinning', function () {
183183

184184
it('all buttons should succeed initially', async () => {
185185
const buttons = await driver.$$('android=new UiSelector().className("android.widget.Button")');
186-
expect(buttons).to.have.lengthOf(13, 'Expected buttons were not present');
187186

188187
buttons.map(button => button.click());
189188
await Promise.all(await buttons.map(async (button) => {
@@ -213,7 +212,6 @@ describe('Test Android unpinning', function () {
213212

214213
it("all unpinned requests should succeed, all others should fail", async () => {
215214
const buttons = await driver.$$('android=new UiSelector().className("android.widget.Button")');
216-
expect(buttons).to.have.lengthOf(13, 'Expected buttons were not present');
217215

218216
buttons.map(button => button.click());
219217
await Promise.all(await buttons.map(async (button) => {
@@ -249,7 +247,7 @@ describe('Test Android unpinning', function () {
249247

250248
it("all buttons except 'Raw custom-pinned request' should succeed", async () => {
251249
const buttons = await driver.$$('android=new UiSelector().className("android.widget.Button")');
252-
expect(buttons).to.have.lengthOf(13, 'Expected buttons were not present');
250+
const buttonCount = await buttons.length;
253251

254252
buttons.map(button => button.click());
255253
await Promise.all(await buttons.map(async (button) => {
@@ -259,7 +257,8 @@ describe('Test Android unpinning', function () {
259257
}
260258
}));
261259

262-
expect(seenRequests).to.have.lengthOf(14, 'Expected all requests to be intercepted');
260+
const reqCount = buttonCount + 1; // WebView makes a favicon request
261+
expect(seenRequests).to.have.lengthOf(reqCount - 1, 'Expected all but one request to be intercepted');
263262
expect(tlsFailures).to.have.lengthOf(1, 'Expected only raw request to fail');
264263
});
265264

0 commit comments

Comments
 (0)