-
Notifications
You must be signed in to change notification settings - Fork 26.6k
test(docs-infra): reduce CI flakiness #29757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e4621dd
refactor(docs-infra): switch from promises to async/await in tests
gkalpak b385046
ci(docs-infra): wait for conditions to reduce flakiness on CI
gkalpak 84b9e47
ci(docs-infra): loosen conditions to reduce flakiness on CI
gkalpak 0a342f3
fixup! ci(docs-infra): wait for conditions to reduce flakiness on CI
gkalpak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
'use strict'; // necessary for es6 output in node | ||
|
||
import { browser, element, by } from 'protractor'; | ||
import { browser, element, ElementFinder, by } from 'protractor'; | ||
|
||
describe('Lifecycle hooks', function () { | ||
describe('Lifecycle hooks', () => { | ||
const sendKeys = (el: ElementFinder, input: string) => | ||
input.split('').reduce((prev, c) => prev.then(() => el.sendKeys(c)), Promise.resolve()); | ||
|
||
beforeAll(function () { | ||
beforeAll(() => { | ||
browser.get(''); | ||
}); | ||
|
||
it('should open correctly', function () { | ||
it('should open correctly', () => { | ||
expect(element.all(by.css('h2')).get(0).getText()).toEqual('Peek-A-Boo'); | ||
}); | ||
|
||
it('should support peek-a-boo', function () { | ||
it('should support peek-a-boo', async () => { | ||
let pabComp = element(by.css('peek-a-boo-parent peek-a-boo')); | ||
expect(pabComp.isPresent()).toBe(false, 'should not be able to find the "peek-a-boo" component'); | ||
|
||
let pabButton = element.all(by.css('peek-a-boo-parent button')).get(0); | ||
let updateHeroButton = element.all(by.css('peek-a-boo-parent button')).get(1); | ||
expect(pabButton.getText()).toContain('Create Peek'); | ||
pabButton.click().then(function () { | ||
expect(pabButton.getText()).toContain('Destroy Peek'); | ||
expect(pabComp.isDisplayed()).toBe(true, 'should be able to see the "peek-a-boo" component'); | ||
expect(pabComp.getText()).toContain('Windstorm'); | ||
expect(pabComp.getText()).not.toContain('Windstorm!'); | ||
expect(updateHeroButton.isPresent()).toBe(true, 'should be able to see the update hero button'); | ||
return updateHeroButton.click(); | ||
}).then(function () { | ||
expect(pabComp.getText()).toContain('Windstorm!'); | ||
return pabButton.click(); | ||
}).then(function () { | ||
expect(pabComp.isPresent()).toBe(false, 'should no longer be able to find the "peek-a-boo" component'); | ||
}); | ||
|
||
await pabButton.click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is only for WebDriver's browser.actions(). .click() is a WebElement method. |
||
expect(pabButton.getText()).toContain('Destroy Peek'); | ||
expect(pabComp.isDisplayed()).toBe(true, 'should be able to see the "peek-a-boo" component'); | ||
expect(pabComp.getText()).toContain('Windstorm'); | ||
expect(pabComp.getText()).not.toContain('Windstorm!'); | ||
expect(updateHeroButton.isPresent()).toBe(true, 'should be able to see the update hero button'); | ||
|
||
await updateHeroButton.click(); | ||
expect(pabComp.getText()).toContain('Windstorm!'); | ||
|
||
await pabButton.click(); | ||
expect(pabComp.isPresent()).toBe(false, 'should no longer be able to find the "peek-a-boo" component'); | ||
}); | ||
|
||
it('should support OnChanges hook', function () { | ||
it('should support OnChanges hook', () => { | ||
let onChangesViewEle = element.all(by.css('on-changes div')).get(0); | ||
let inputEles = element.all(by.css('on-changes-parent input')); | ||
let heroNameInputEle = inputEles.get(1); | ||
|
@@ -52,7 +55,7 @@ describe('Lifecycle hooks', function () { | |
expect(changeLogEles.count()).toEqual(7, 'should have 7 messages now'); | ||
}); | ||
|
||
it('should support DoCheck hook', function () { | ||
it('should support DoCheck hook', async () => { | ||
let doCheckViewEle = element.all(by.css('do-check div')).get(0); | ||
let inputEles = element.all(by.css('do-check-parent input')); | ||
let heroNameInputEle = inputEles.get(1); | ||
|
@@ -62,26 +65,25 @@ describe('Lifecycle hooks', function () { | |
let logCount: number; | ||
|
||
expect(titleEle.getText()).toContain('Windstorm can sing'); | ||
changeLogEles.count().then(function(count: number) { | ||
// 3 messages to start | ||
expect(count).toEqual(3, 'should start with 3 messages'); | ||
logCount = count; | ||
return heroNameInputEle.sendKeys('-foo-'); | ||
}).then(function () { | ||
expect(titleEle.getText()).toContain('Windstorm-foo- can sing'); | ||
return changeLogEles.count(); | ||
}).then(function(count: number) { | ||
// one more for each keystroke | ||
expect(count).toEqual(logCount + 5, 'should add 5 more messages'); | ||
logCount = count; | ||
return powerInputEle.sendKeys('-bar-'); | ||
}).then(function () { | ||
expect(titleEle.getText()).toContain('Windstorm-foo- can sing-bar-'); | ||
expect(changeLogEles.count()).toEqual(logCount + 6, 'should add 6 more messages'); | ||
}); | ||
|
||
let count = await changeLogEles.count(); | ||
// 3 messages to start | ||
expect(count).toEqual(3, 'should start with 3 messages'); | ||
|
||
logCount = count; | ||
await sendKeys(heroNameInputEle, '-foo-'); | ||
count = await changeLogEles.count(); | ||
expect(titleEle.getText()).toContain('Windstorm-foo- can sing'); | ||
expect(count).toBeGreaterThanOrEqual(logCount + 5, 'should add at least one more message for each keystroke'); | ||
|
||
logCount = count; | ||
await sendKeys(powerInputEle, '-bar-'); | ||
count = await changeLogEles.count(); | ||
expect(titleEle.getText()).toContain('Windstorm-foo- can sing-bar-'); | ||
expect(count).toBeGreaterThanOrEqual(logCount + 5, 'should add at least one more message for each keystroke'); | ||
}); | ||
|
||
it('should support AfterView hooks', function () { | ||
it('should support AfterView hooks', async () => { | ||
let parentEle = element(by.tagName('after-view-parent')); | ||
let buttonEle = parentEle.element(by.tagName('button')); // Reset | ||
let commentEle = parentEle.element(by.className('comment')); | ||
|
@@ -92,90 +94,81 @@ describe('Lifecycle hooks', function () { | |
expect(childViewInputEle.getAttribute('value')).toContain('Magneta'); | ||
expect(commentEle.isPresent()).toBe(false, 'comment should not be in DOM'); | ||
|
||
logEles.count().then(function(count: number) { | ||
logCount = count; | ||
return childViewInputEle.sendKeys('-test-'); | ||
}).then(function() { | ||
expect(childViewInputEle.getAttribute('value')).toContain('-test-'); | ||
expect(commentEle.isPresent()).toBe(true, 'should have comment because >10 chars'); | ||
expect(commentEle.getText()).toContain('long name'); | ||
return logEles.count(); | ||
}).then(function(count: number) { | ||
expect(logCount + 7).toBeGreaterThan(count - 3, | ||
'7 additional log messages should have been added'); | ||
expect(logCount + 7).toBeLessThan(count + 3, | ||
'7 additional log messages should have been added'); | ||
logCount = count; | ||
return buttonEle.click(); | ||
}).then(function() { | ||
expect(logEles.count()).toBeLessThan(logCount, 'log should shrink after reset'); | ||
}); | ||
}); | ||
logCount = await logEles.count(); | ||
await childViewInputEle.sendKeys('-test-'); | ||
|
||
expect(childViewInputEle.getAttribute('value')).toContain('-test-'); | ||
expect(commentEle.isPresent()).toBe(true, 'should have comment because >10 chars'); | ||
expect(commentEle.getText()).toContain('long name'); | ||
|
||
let count = await logEles.count(); | ||
expect(logCount + 7).toBeGreaterThan(count - 3, '7 additional log messages should have been added'); | ||
expect(logCount + 7).toBeLessThan(count + 3, '7 additional log messages should have been added'); | ||
|
||
it('should support AfterContent hooks', function () { | ||
logCount = count; | ||
await buttonEle.click(); | ||
expect(logEles.count()).toBeLessThan(logCount, 'log should shrink after reset'); | ||
}); | ||
|
||
it('should support AfterContent hooks', async () => { | ||
let parentEle = element(by.tagName('after-content-parent')); | ||
let buttonEle = parentEle.element(by.tagName('button')); // Reset | ||
let commentEle = parentEle.element(by.className('comment')); | ||
let logEles = parentEle.all(by.css('h4 ~ div')); | ||
let childViewInputEle = parentEle.element(by.css('app-child input')); | ||
let logCount: number; | ||
let logCount = await logEles.count(); | ||
|
||
expect(childViewInputEle.getAttribute('value')).toContain('Magneta'); | ||
expect(commentEle.isPresent()).toBe(false, 'comment should not be in DOM'); | ||
|
||
logEles.count().then(function(count: number) { | ||
logCount = count; | ||
return childViewInputEle.sendKeys('-test-'); | ||
}).then(function() { | ||
expect(childViewInputEle.getAttribute('value')).toContain('-test-'); | ||
expect(commentEle.isPresent()).toBe(true, 'should have comment because >10 chars'); | ||
expect(commentEle.getText()).toContain('long name'); | ||
return logEles.count(); | ||
}).then(function(count: number) { | ||
expect(logCount + 5).toEqual(count, '5 additional log messages should have been added'); | ||
logCount = count; | ||
return buttonEle.click(); | ||
}).then(function() { | ||
expect(logEles.count()).toBeLessThan(logCount, 'log should shrink after reset'); | ||
}); | ||
await sendKeys(childViewInputEle, '-test-'); | ||
let count = await logEles.count(); | ||
expect(childViewInputEle.getAttribute('value')).toContain('-test-'); | ||
expect(commentEle.isPresent()).toBe(true, 'should have comment because >10 chars'); | ||
expect(commentEle.getText()).toContain('long name'); | ||
expect(count).toBeGreaterThanOrEqual(logCount + 5, 'additional log messages should have been added'); | ||
|
||
logCount = count; | ||
await buttonEle.click(); | ||
expect(logEles.count()).toBeLessThan(logCount, 'log should shrink after reset'); | ||
}); | ||
|
||
it('should support spy\'s OnInit & OnDestroy hooks', function () { | ||
it('should support spy\'s OnInit & OnDestroy hooks', async () => { | ||
let inputEle = element(by.css('spy-parent input')); | ||
let addHeroButtonEle = element(by.cssContainingText('spy-parent button', 'Add Hero')); | ||
let resetHeroesButtonEle = element(by.cssContainingText('spy-parent button', 'Reset Heroes')); | ||
let heroEles = element.all(by.css('spy-parent div[mySpy')); | ||
let logEles = element.all(by.css('spy-parent h4 ~ div')); | ||
|
||
expect(heroEles.count()).toBe(2, 'should have two heroes displayed'); | ||
expect(logEles.count()).toBe(2, 'should have two log entries'); | ||
inputEle.sendKeys('-test-').then(function() { | ||
return addHeroButtonEle.click(); | ||
}).then(function() { | ||
expect(heroEles.count()).toBe(3, 'should have added one hero'); | ||
expect(heroEles.get(2).getText()).toContain('-test-'); | ||
expect(logEles.count()).toBe(3, 'should now have 3 log entries'); | ||
return resetHeroesButtonEle.click(); | ||
}).then(function() { | ||
expect(heroEles.count()).toBe(0, 'should no longer have any heroes'); | ||
expect(logEles.count()).toBe(7, 'should now have 7 log entries - 3 orig + 1 reset + 3 removeall'); | ||
}); | ||
|
||
await inputEle.sendKeys('-test-'); | ||
await addHeroButtonEle.click(); | ||
expect(heroEles.count()).toBe(3, 'should have added one hero'); | ||
expect(heroEles.get(2).getText()).toContain('-test-'); | ||
expect(logEles.count()).toBe(3, 'should now have 3 log entries'); | ||
|
||
await resetHeroesButtonEle.click(); | ||
expect(heroEles.count()).toBe(0, 'should no longer have any heroes'); | ||
expect(logEles.count()).toBe(7, 'should now have 7 log entries - 3 orig + 1 reset + 3 removeall'); | ||
}); | ||
|
||
it('should support "spy counter"', function () { | ||
it('should support "spy counter"', async () => { | ||
let updateCounterButtonEle = element(by.cssContainingText('counter-parent button', 'Update')); | ||
let resetCounterButtonEle = element(by.cssContainingText('counter-parent button', 'Reset')); | ||
let textEle = element(by.css('counter-parent app-counter > div')); | ||
let logEles = element.all(by.css('counter-parent h4 ~ div')); | ||
|
||
expect(textEle.getText()).toContain('Counter = 0'); | ||
expect(logEles.count()).toBe(2, 'should start with two log entries'); | ||
updateCounterButtonEle.click().then(function() { | ||
expect(textEle.getText()).toContain('Counter = 1'); | ||
expect(logEles.count()).toBe(3, 'should now have 3 log entries'); | ||
return resetCounterButtonEle.click(); | ||
}).then(function() { | ||
expect(textEle.getText()).toContain('Counter = 0'); | ||
expect(logEles.count()).toBe(7, 'should now have 7 log entries - 3 prev + 1 reset + 2 destroy + 1 init'); | ||
}); | ||
|
||
await updateCounterButtonEle.click(); | ||
expect(textEle.getText()).toContain('Counter = 1'); | ||
expect(logEles.count()).toBe(3, 'should now have 3 log entries'); | ||
|
||
await resetCounterButtonEle.click(); | ||
expect(textEle.getText()).toContain('Counter = 0'); | ||
expect(logEles.count()).toBe(7, 'should now have 7 log entries - 3 prev + 1 reset + 2 destroy + 1 init'); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does
.perform()
cause this to happen synchronously?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, (although it shouldn't matter here). It just how WebDriver's browser.actions() needs to be used.