From a464187c7262d62a83e6263a3ae2f50284f46f05 Mon Sep 17 00:00:00 2001 From: Stanislav Lvovsky Date: Tue, 21 Jan 2020 13:33:51 +0200 Subject: [PATCH] Revert "Password" (#118) * Revert "Password (#113)" This reverts commit 970e2082a93abe2369a4e644fb73cff17cf78a38. * Update App.vue * Update App.spec.js * change version --- backend/package.json | 2 +- frontend/jest.config.js | 2 +- frontend/package.json | 2 +- frontend/src/App.vue | 13 +++------ .../QuestionTypes/QuestionInput.vue | 7 ----- frontend/tests/App.spec.js | 20 ------------- .../QuestionTypes/QuestionInput.spec.js | 28 ------------------- 7 files changed, 7 insertions(+), 67 deletions(-) diff --git a/backend/package.json b/backend/package.json index fd1d8af4..bba85e62 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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" }, diff --git a/frontend/jest.config.js b/frontend/jest.config.js index 12d1d63c..30f21213 100644 --- a/frontend/jest.config.js +++ b/frontend/jest.config.js @@ -35,7 +35,7 @@ module.exports = { ], coverageThreshold: { "global": { - "branches": 87, + "branches": 86, "functions": 98, "lines": 95, "statements": 95 diff --git a/frontend/package.json b/frontend/package.json index 5f2f7189..c3c98c00 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -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", diff --git a/frontend/src/App.vue b/frontend/src/App.vue index f05ca900..cbc1b9d5 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -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(() => { @@ -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) { @@ -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], diff --git a/frontend/src/components/QuestionTypes/QuestionInput.vue b/frontend/src/components/QuestionTypes/QuestionInput.vue index 6e5412a3..66bbd548 100644 --- a/frontend/src/components/QuestionTypes/QuestionInput.vue +++ b/frontend/src/components/QuestionTypes/QuestionInput.vue @@ -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; diff --git a/frontend/tests/App.spec.js b/frontend/tests/App.spec.js index 4553e5ff..10958355 100644 --- a/frontend/tests/App.spec.js +++ b/frontend/tests/App.spec.js @@ -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', () => { diff --git a/frontend/tests/components/QuestionTypes/QuestionInput.spec.js b/frontend/tests/components/QuestionTypes/QuestionInput.spec.js index eb3fbbf4..d03520aa 100644 --- a/frontend/tests/components/QuestionTypes/QuestionInput.spec.js +++ b/frontend/tests/components/QuestionTypes/QuestionInput.spec.js @@ -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, {