Skip to content

Commit

Permalink
Revert "Password" (#118)
Browse files Browse the repository at this point in the history
* Revert "Password (#113)"

This reverts commit 970e208.

* Update App.vue

* Update App.spec.js

* change version
  • Loading branch information
slavik-lvovsky authored Jan 21, 2020
1 parent 970e208 commit a464187
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 67 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "Apache 2.0",
"description": "Provide rich user experience for Yeoman generators using VSCode extension or the browser",
"repository": "https://github.com/SAP/yeoman-ui",
"version": "0.0.27",
"version": "0.0.28",
"engines": {
"vscode": "^1.39.2"
},
Expand Down
2 changes: 1 addition & 1 deletion frontend/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
],
coverageThreshold: {
"global": {
"branches": 87,
"branches": 86,
"functions": 98,
"lines": 95,
"statements": 95
Expand Down
2 changes: 1 addition & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "yeoman-ui-frontend",
"displayName": "Yeoman UI Frontend",
"version": "0.2.7",
"version": "0.2.8",
"publisher": "SAP",
"license": "Apache 2.0",
"description": "Frontend for the yeoman UI framework",
Expand Down
13 changes: 4 additions & 9 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,14 @@ export default {
}
},
methods: {
async updateQuestionsFromIndex(changedQuestionIndex) {
async updateQuestionsFromIndex(questionIndex) {
const questions = _.get(this, "currentPrompt.questions", []);
const relevantQuestionsToUpdate = _.slice(questions, changedQuestionIndex)
const relevantQuestionsToUpdate = _.slice(questions, questionIndex)
let showBusy = true
const that = this
let questionIndex = changedQuestionIndex - 1;
const finished = relevantQuestionsToUpdate.reduce((p, question) => {
questionIndex++;
return p.then(() => that.updateQuestion(question, questionIndex, changedQuestionIndex))
return p.then(() => that.updateQuestion(question))
}, Promise.resolve());
setTimeout(() => {
Expand All @@ -188,7 +186,7 @@ export default {
_.isEmpty(this.prompts) ||
(this.currentPrompt.status === PENDING && !this.isDone);
},
async updateQuestion(question, questionIndex, changedQuestionIndex) {
async updateQuestion(question) {
const newAnswers = this.currentPrompt.answers
try {
if (question.when === FUNCTION) {
Expand Down Expand Up @@ -217,9 +215,6 @@ export default {
question.answer = question.default;
}
}
if (question.type === "password" && questionIndex !== changedQuestionIndex) {
question.answer = undefined;
}
if (question._message === FUNCTION) {
question.message = await this.rpc.invoke("evaluateMethod", [
[newAnswers],
Expand Down
7 changes: 0 additions & 7 deletions frontend/src/components/QuestionTypes/QuestionInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ export default {
return type === "input" ? "text" : type;
}
},
watch: {
"currentQuestion.answer": {
handler(currentAnswer) {
this.text = currentAnswer;
}
}
},
methods: {
onChange() {
const currentValue = _.isEmpty(this.text) ? _.get(this.currentQuestion, "default") : this.text;
Expand Down
20 changes: 0 additions & 20 deletions frontend/tests/App.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,26 +212,6 @@ describe('App.vue', () => {

invokeSpy.mockRestore();
})

test('invoke for question that comes before question of type password', async () => {
wrapper.vm.rpc = {
invoke: jest.fn().mockResolvedValue()
}
wrapper.vm.prompts = [{
questions: [{
name: 'serviceQ', validate: '__Function', answer: 'serviceAnswer', isWhen: true
}, {
name: 'passwordQ', validate: '__Function', answer: "somePassword", isWhen: true, type: "password"
}],
answers: {}
}]
wrapper.vm.generatorName = "testGen";
wrapper.vm.promptIndex = 0;

await wrapper.vm.updateQuestionsFromIndex(0)

expect(wrapper.vm.prompts[0].questions[1].answer).toBeUndefined()
})
})

describe('setQuestionProps - method', () => {
Expand Down
28 changes: 0 additions & 28 deletions frontend/tests/components/QuestionTypes/QuestionInput.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,6 @@ describe('QuestionInput.vue', () => {
})
})

describe('currentQuestion.answe - watch', () => {
test('current answer is undefined', () => {
wrapper = initComponent(QuestionInput, {
currentQuestion: {
type: 'input', default: 'testDefault', answer: 'testAnswer'
},
updateQuestionsFromIndex: () => {}
})

wrapper.vm.$data.text = ''
wrapper.vm.$options.watch["currentQuestion.answer"].handler.call(wrapper.vm, undefined)
expect(wrapper.vm.$data.text).toBeUndefined()
})

test('current answer is defined', () => {
wrapper = initComponent(QuestionInput, {
currentQuestion: {
type: 'input', default: 'testDefault', answer: 'testAnswer'
},
updateQuestionsFromIndex: () => {}
})

wrapper.vm.$data.text = ''
wrapper.vm.$options.watch["currentQuestion.answer"].handler.call(wrapper.vm, "test")
expect(wrapper.vm.$data.text).toBe("test")
})
})

describe('text - method', () => {
test('text size is 0', async () => {
wrapper = initComponent(QuestionInput, {
Expand Down

0 comments on commit a464187

Please sign in to comment.