Skip to content

Commit

Permalink
Clear review text field when changing between addons
Browse files Browse the repository at this point in the history
  • Loading branch information
pgengler committed Aug 19, 2021
1 parent 771d61d commit afac92b
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/components/admin-addon-review-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default class AdminAddonReviewForm extends Component {
@tracked
recentlySaved = false;

@tracked
reviewText = null;

questions = questions;

@service
Expand All @@ -19,6 +22,7 @@ export default class AdminAddonReviewForm extends Component {
@action
reset() {
this.reviewProperties = tracked({});
this.reviewText = null;
}

@action
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/prevent-default.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { helper } from '@ember/component/helper';
export default helper(function preventDefaultHelper([fn]) {
return (event) => {
event.preventDefault();
fn();
fn(event);
};
});
32 changes: 32 additions & 0 deletions tests/acceptance/admin-review-addon-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,38 @@ module('Acceptance | admin review addon', function (hooks) {
assert.equal(actualMessage, 'Failed to create review');
});

test('resets toggles/fields when changing addons', async function (assert) {
let firstAddon = server.create('addon', { note: null });
let secondAddon = server.create('addon', { note: null });
console.log('firstAddon: %O', firstAddon);
console.log('secondAddon: %O', secondAddon);

await visitAddon(firstAddon, '?list=needing-review');
await toggle('.test-toggle-is-wip');
await fillIn('.test-note-input', 'Some notes about this addon');
await click('.test-save-addon');

await answerQuestion('Are there meaningful tests?', 'Yes');
await answerQuestion('Is the README filled out?', 'Yes');
await answerQuestion('Does the addon have a build?', 'No');
await fillIn('.test-addon-review-notes', 'A note on the review');
await click('.test-addon-review-save');

// go to the other addon
await click(findByText('.test-review-list-item', secondAddon.name));
assertToggleState(assert, '.test-toggle-is-wip', {
checked: true,
text: 'Not a WIP',
});
assert.dom('.test-note-input').hasNoValue('clears addon note field');
assert
.dom('.test-review-question button.selected')
.doesNotExist('clears review questions');
assert
.dom('.test-addon-review-notes')
.hasNoValue('clears review note field');
});

module('lists', function () {
test('Visiting list without a list param defaults to needing-review', async function (assert) {
let addon = server.create('addon', {
Expand Down

0 comments on commit afac92b

Please sign in to comment.