-
Notifications
You must be signed in to change notification settings - Fork 148
Child suites retry fixed #899
Conversation
it('should retry only failed states', async () => { | ||
sandbox.spy(RegularSuiteRunner, 'create'); | ||
|
||
const suite = makeSuiteTree({suite: ['1st', '2nd', '3rd']}, {browsers: ['bro', 'firefox']}).suite; |
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.
Немножко улучшил тест
const childState = suite.children[0].states[0]; | ||
if (_.includes(childState.browsers, 'bro')) { //emulate State-runner behaviour | ||
runner.emit(Events.TEST_RESULT, {state: {name: 'childState'}, equal: false}); | ||
} |
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.
Долго мучался и страдал, но лучше не придумал. Проблема (исправленная) возникает из-за того, что в RegularSuiteRunner
выбирается DisabledStateRunner
, который не присылает event'ов. Сколько я ни пытался, расстабать RegularSuiteRunner
и застабать StateRunner
невозможно, придется переписывать все тесты. Поэтому просто моделирую поведение при выборе одного из StateRunner
'ов.
return; | ||
} | ||
|
||
const collection = new SuiteCollection([suite]).disableAll(); |
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.
Вот он – корень зла. Для тех, кто не в курсе, эта функция обнуляет браузеры всех стейтов, включая дочерние, отчего те в свою очередь, не способны запускаться. При этом........
const browser = this._browserAgent.browserId; | ||
const collection = new SuiteCollection([suite]); | ||
suite.states.forEach((state) => collection.disable(suite, {state: state.name})); | ||
this._statesToRetry.forEach((state) => collection.enable(suite, {state, browser})); |
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.
......в строй возвращаются лишь стейты ТЕКУЩЕГО сьюта, и после завершения функции, стейты дочерних сьютов остаются без браузеров :(
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.
Нужно обсудить сам тест - я в нем нифига не понял
.then(() => { | ||
stubWrappedRun_((runner) => { | ||
const childState = suite.children[0].states[0]; | ||
if (_.includes(childState.browsers, 'bro')) { //emulate State-runner behaviour |
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.
childState.browsers.includes('bro')
'state': 'rootState', | ||
child: ['childState'] | ||
} | ||
}, {browsers: ['bro', 'firefox']}).suite; |
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.
Создаем дерево сьютов
suite: {
rootState
browsers: ['bro', 'firefox']
}
|
–––> childSuite: {childState}
Самая запутанная часть (как мне кажется) теста, но что поделать, создатель видел функцию makeSuiteTree
именно такой
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.
Я, как создатель функции makeSuiteTree
, заявляю, что она не должна работать с такими входными параметрами, и не рассчитана на такой кейс.
|
||
stubWrappedRun_((runner) => runner.emit(Events.TEST_RESULT, {state: {name: 'rootState'}, equal: false})); | ||
|
||
return mkRunnerWithRetries_({suite, browserAgent: mkBrowserAgentStub_('bro')}) |
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.
Повторяем те действия в точности, как бы их делала gemini
на реальном тесте. 2 теста выполняются один за другим –> browsersPerSession = 1
, как раз то, что нам нужно воспроизвести.
Тест верхнего сьюта падает с ошибкой
const childState = suite.children[0].states[0]; | ||
if (childState.browsers.includes('bro')) { //emulate State-runner behaviour | ||
runner.emit(Events.TEST_RESULT, {state: {name: 'childState'}, equal: false}); | ||
} |
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.
Важнецкий момент! После прохождения первого теста программа оказывается в этой строчке, где решает, что же в итоге выбрать для дочернего сьюта: нормальный runner или disabled. DisabledStateRunner
не прокидывает событий, нужно этот момент в точности повторить, что я и делаю. Если убрать строчку childState.browsers.includes('bro')
, оригинальную проблему не возможно было бы воспроизвести
} | ||
}); | ||
|
||
return mkRunnerWithRetries_({suite: suite.children[0], browserAgent: mkBrowserAgentStub_('bro')}).run(); |
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.
Вызываем дочерний state
assert.equal(RegularSuiteRunner.create.callCount, 4); | ||
const retriedChildSuite = RegularSuiteRunner.create.getCall(3).args[0]; | ||
assert.deepEqual(retriedChildSuite.states[0].browsers, ['bro']); | ||
}); |
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.
Собственно, проверочки, что state вызвался, при чем с нормальными аргументами
969645c
to
5e4348b
Compare
5e4348b
to
a141462
Compare
No description provided.