Skip to content

Commit e648a0f

Browse files
author
David Haeffner
committed
Placed the waitForWindow emitter behind an "extras" key in the Command emitter in java-junit, and updated code-export-util/emit to work with the emitter.extras keys using a whitelist
1 parent eb0322b commit e648a0f

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

packages/code-export-java-junit/src/command.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export const emitters = {
112112
waitForElementNotEditable: emitWaitForElementNotEditable,
113113
waitForElementNotPresent: emitWaitForElementNotPresent,
114114
waitForElementNotVisible: emitWaitForElementNotVisible,
115-
waitForWindow: emitWaitForWindow,
116115
webdriverAnswerOnVisiblePrompt: emitAnswerOnNextPrompt,
117116
webdriverChooseCancelOnVisibleConfirmation: emitChooseCancelOnNextConfirmation,
118117
webdriverChooseCancelOnVisiblePrompt: emitChooseCancelOnNextConfirmation,
@@ -1049,5 +1048,5 @@ async function emitWaitForElementNotVisible(locator, timeout) {
10491048
export default {
10501049
emit,
10511050
register,
1052-
emitWaitForWindow,
1051+
extras: { emitWaitForWindow },
10531052
}

packages/code-export-utils/src/emit.js

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,18 +147,28 @@ async function emitTest(
147147
if (!testLevel) testLevel = 1
148148
if (!commandLevel) commandLevel = 2
149149
const methods = findReusedTestMethods(test, tests)
150-
if (findCommandThatOpensWindow(test.commands) && emitter.emitWaitForWindow) {
151-
const method = await emitter.emitWaitForWindow()
152-
const result = await emitMethod(method, {
153-
emitter,
154-
commandPrefixPadding,
155-
generateMethodDeclaration: method.generateMethodDeclaration,
156-
terminatingKeyword,
157-
overrideCommandEmitting: true,
158-
})
159-
await registerMethod(method.name, result, {
160-
generateMethodDeclaration,
161-
hooks,
150+
if (emitter.extras) {
151+
Object.keys(emitter.extras).forEach(async emitter_name => {
152+
let ignore = true
153+
if (
154+
emitter_name === 'emitWaitForWindow' &&
155+
findCommandThatOpensWindow(test.commands)
156+
)
157+
ignore = false
158+
if (!ignore) {
159+
const method = await emitter.extras[emitter_name]()
160+
const result = await emitMethod(method, {
161+
emitter,
162+
commandPrefixPadding,
163+
generateMethodDeclaration: method.generateMethodDeclaration,
164+
terminatingKeyword,
165+
overrideCommandEmitting: true,
166+
})
167+
await registerMethod(method.name, result, {
168+
generateMethodDeclaration,
169+
hooks,
170+
})
171+
}
162172
})
163173
}
164174
for (const method of methods) {

0 commit comments

Comments
 (0)