Skip to content

Commit

Permalink
Require root folder to be selected when configuring addon
Browse files Browse the repository at this point in the history
  • Loading branch information
futa-ikeda committed Nov 22, 2024
1 parent 53585c6 commit b69f3c1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class ConfiguredAddonEdit extends Component<Args> {
}

get disableSave() {
return this.invalidDisplayName || this.args.onSave.isRunning;
return !this.selectedFolder || this.invalidDisplayName || this.args.onSave.isRunning;
}

get onSaveArgs() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ module('Integration | Component | addons-service | configured-addon-edit', funct

const mirageConfiguredAddon = server.create('configured-storage-addon', {
displayName: 'My configured addon',
rootFolder: 'rooty',
rootFolder: undefined,
externalStorageService: boxAddon,
accountOwner: userRef,
authorizedResource: resourceRef,
Expand All @@ -56,25 +56,26 @@ module('Integration | Component | addons-service | configured-addon-edit', funct
/>
`);

// Initial state when no folder is selected
assert.dom('[data-test-display-name-input]').hasValue('My configured addon', 'Display name is poopulated');
assert.dom('[data-test-folder-path-option]').exists({ count: 1 }, 'Has root folder path option');
assert.dom('[data-test-go-to-root]').exists('Go to root button exists');
assert.dom('[data-test-folder-path-option]').doesNotExist('No folder option when at root');
assert.dom('[data-test-folder-link]').exists({ count: 5 }, 'Root folder has 5 folders');
assert.dom('[data-test-root-folder-option]').exists({ count: 5 }, 'Checkbox available for each folder option');
assert.dom('[data-test-root-folder-save]').isEnabled('Save button is enabled');
assert.dom('[data-test-root-folder-save]').isDisabled('Save button is disabled when no folder is selected');

// updating and reseting the display name
assert.dom('[data-test-display-name-error]').doesNotExist('No error message initially');
await fillIn('[data-test-display-name-input]', '');
assert.dom('[data-test-root-folder-save]').isDisabled('Save button is disabled');
assert.dom('[data-test-display-name-error]').exists('Error message is shown when display name is empty');
await fillIn('[data-test-display-name-input]', 'My configured addon');
assert.dom('[data-test-root-folder-save]').isEnabled('Save button is enabled after display name is set');
assert.dom('[data-test-display-name-error]').doesNotExist('No error message after display name is set');

// Navigate into a folder
const folderLinks = this.element.querySelectorAll('[data-test-folder-link]');
await click(folderLinks[0]);
assert.dom('[data-test-folder-path-option]').exists({ count: 2 }, 'Has root folder and subfolder path option');
assert.dom('[data-test-folder-path-option]').exists({ count: 1 }, 'Has root option and first folderoption');

// Navigate back to root
const navButtons = this.element.querySelectorAll('[data-test-folder-path-option]');
Expand All @@ -89,7 +90,7 @@ module('Integration | Component | addons-service | configured-addon-edit', funct
// Save
await click('[data-test-root-folder-save]');
const args = {
rootFolder: 'rooty-1',
rootFolder: 'root-1-1',
displayName: 'My configured addon',
};

Expand Down

0 comments on commit b69f3c1

Please sign in to comment.