Skip to content

Commit

Permalink
Updating Internal Dashboard Existing Email (#1095)
Browse files Browse the repository at this point in the history
* Updating Internal Dashboard Existing Email

- There was an issue found when updating an existing user's email address.
  Namely, the updated email would not show after saving.
- Added additional UI tests that exercise both changing / discarding & changing
  / saving each of the User Settings ( e-mail, user type, mapped person, and
  institution ).

* Fixing eslint issues

* Removing extraneous function call

This function sets field.value = field.originalValue, since we already assume that field.value
is the up to date value ( hence calling resetDirtyState / resetUserSettings to set
field.originalValue && field.startValue = field.value ). This is an extraneous function
call and can be removed.

* Updating functions called

`resetUserSettings` is meant to make sure that the user fields `originalValue`
property matches up with the field's current value. Typically this is done after
changes have been saved.

`revertUserSettings` is meant to make sure that the fields current value is
equal to the original value. Which is the desirable behavior in this case.

So while ultimately the form functioned as intended when strictly viewing the
interface, this was more by accident then by design. It also causes confusion
while attempting to read / review the code which is never desirable.

* Removing the setting of `startValue`

`startValue` is defined by ExtJs as "The value that the Field had at the time it
was last focused. This is the value that is passed to the change event which is
fired if the value has been changed when the Field is blurred.". And as we do
not have any code that currently operates on the field value passed to its
change event, there's no reason to be updating it here.

Co-authored-by: Ben Plessinger <[email protected]>
  • Loading branch information
ryanrath and plessbd authored Jul 2, 2020
1 parent b6c11d2 commit 2714d6f
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 68 deletions.
1 change: 1 addition & 0 deletions html/internal_dashboard/js/admin_panel/AdminPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ XDMoD.AdminPanel = Ext.extend(Ext.Window, {
return;

if (resp == 'no') {
sectionExistingUsers.revertUserSettings();
sectionExistingUsers.resetDirtyState();
self.hide();
}
Expand Down
11 changes: 4 additions & 7 deletions html/internal_dashboard/js/admin_panel/SectionExistingUsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ XDMoD.ExistingUsers = Ext.extend(Ext.Panel, {
}

if (resp === 'no') {
self.resetDirtyState();
self.revertUserSettings();

updateSaveIndicator();
self.reloadUserList(menuItem.type_id);
Expand Down Expand Up @@ -787,7 +787,7 @@ XDMoD.ExistingUsers = Ext.extend(Ext.Panel, {
/**
* Reverts the User Settings ( E-Mail Address, User Type, Map To, Institution ) to their original values.
*/
var revertUserSettings = function () {
self.revertUserSettings = function () {
// eslint-disable-next-line no-use-before-define
var fieldValues = userSettings.getForm().getFieldValues();
for (var id in fieldValues) {
Expand Down Expand Up @@ -819,9 +819,6 @@ XDMoD.ExistingUsers = Ext.extend(Ext.Panel, {
if (field.originalValue !== field.getValue()) {
field.originalValue = field.getValue();
}
if (field.startValue !== field.getValue()) {
field.startValue = field.getValue();
}
}
}
};
Expand Down Expand Up @@ -982,7 +979,6 @@ XDMoD.ExistingUsers = Ext.extend(Ext.Panel, {
}

self.resetDirtyState();
revertUserSettings();

updateSaveIndicator();

Expand Down Expand Up @@ -1324,6 +1320,7 @@ XDMoD.ExistingUsers = Ext.extend(Ext.Panel, {
clicksToEdit: 1,
border: true,
margins: '2 0 2 2',
cls: 'admin_panel_existing_user_list',

viewConfig: {
emptyText: 'No users in this category currently exist'
Expand Down Expand Up @@ -1383,7 +1380,7 @@ XDMoD.ExistingUsers = Ext.extend(Ext.Panel, {
}

if (resp === 'no') {
self.resetDirtyState();
self.revertUserSettings();
// eslint-disable-next-line no-use-before-define
updateSaveIndicator();

Expand Down
192 changes: 148 additions & 44 deletions tests/ui/test/specs/xdmod/internalDashboard.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,30 @@
const page = require('./internalDashboard.page.js');
const settings = [
{
label: 'E-Mail Address',
type: 'text',
updated: '[email protected]',
original: '[email protected]'
},
{
label: 'User Type',
type: 'dropdown',
updated: 'Testing',
original: 'External'
},
{
label: 'Map To',
type: 'dropdown',
updated: 'Auk, Great',
original: 'Unknown, Unknown'
},
{
label: 'Institution',
type: 'dropdown',
updated: 'Unknown Organization',
original: 'Screwdriver'
}
];

describe('Internal Dashboard', function () {
page.login('mgr');
Expand Down Expand Up @@ -127,28 +153,8 @@ describe('Internal Dashboard', function () {
});
});
describe('Make sure that updates to the newly created users Settings can be discarded', function () {
const settings = [
{
label: 'User Type',
type: 'text',
updated: 'Testing',
expected: 'External'
},
{
label: 'Map To',
type: 'text',
updated: 'Auk, Great',
expected: 'Unknown, Unknown'
},
{
label: 'Institution',
type: 'text',
updated: 'Unknown Organization',
expected: 'Screwdriver'
}
];
settings.forEach(function (value) {
describe(`Checking: ${value.label}`, function () {
settings.forEach(function (setting) {
describe(`Checking: ${setting.label}`, function () {
it('Select the "Existing Users" tab', function () {
browser.waitForVisible(page.selectors.user_management.tabs.existing_users());
browser.waitAndClick(page.selectors.user_management.tabs.existing_users());
Expand All @@ -164,23 +170,31 @@ describe('Internal Dashboard', function () {
browser.waitForVisible(page.selectors.create_manage_users.window);
browser.waitForVisible(page.selectors.create_manage_users.current_users.container);
});
it(`Change the "${value.label}" to "${value.updated}"`, function () {
const inputTrigger = page.selectors.create_manage_users.current_users.settings.inputTriggerByLabelText(value.label);
browser.waitForVisible(inputTrigger);
browser.click(inputTrigger);
it(`Change the "${setting.label}" to "${setting.updated}"`, function () {
if ('dropdown' === setting.type) {
const inputTrigger = page.selectors.create_manage_users.current_users.settings.dropDownTriggerByLabel(setting.label);
browser.waitForVisible(inputTrigger);
browser.click(inputTrigger);

const inputDropDown = page.selectors.combo.container;
browser.waitForVisible(inputDropDown);
const inputDropDown = page.selectors.combo.container;
browser.waitForVisible(inputDropDown);

const dropDownValue = page.selectors.combo.itemByText(value.updated);
browser.waitForVisible(dropDownValue);
browser.waitAndClick(dropDownValue);
const dropDownValue = page.selectors.combo.itemByText(setting.updated);
browser.waitForVisible(dropDownValue);
browser.waitAndClick(dropDownValue);

browser.waitForInvisible(inputDropDown);
browser.waitForInvisible(inputDropDown);

const input = page.selectors.create_manage_users.current_users.settings.inputByLabelText(value.label, value.type);
const updatedValue = browser.getValue(input);
expect(updatedValue).to.equal(value.updated);
const input = page.selectors.create_manage_users.current_users.settings.inputByLabel(setting.label, 'text');
const updatedValue = browser.getValue(input);
expect(updatedValue).to.equal(setting.updated);
} else if ('text' === setting.type) {
const input = page.selectors.create_manage_users.current_users.settings.inputByLabel(setting.label, setting.type);
browser.waitForVisible(input);
browser.setValue(input, setting.updated);
const updatedValue = browser.getValue(input);
expect(updatedValue).to.equal(setting.updated);
}
});
it('Ensure that the user dirty message is shown', function () {
const dirtyMessage = page.selectors.create_manage_users.bottom_bar.messageByText('unsaved changes');
Expand Down Expand Up @@ -209,12 +223,13 @@ describe('Internal Dashboard', function () {
browser.waitForVisible(page.selectors.create_manage_users.window);
browser.waitForVisible(page.selectors.create_manage_users.current_users.container);
});
it(`Check that the ${value.label} is back to ${value.expected}`, function () {
const userTypeInput = page.selectors.create_manage_users.current_users.settings.inputByLabelText(value.label, value.type);
it(`Check that the ${setting.label} is back to ${setting.original}`, function () {
const inputType = 'dropdown' === setting.type ? 'text' : setting.type;
const inputElem = page.selectors.create_manage_users.current_users.settings.inputByLabel(setting.label, inputType);

browser.waitForVisible(userTypeInput);
const userType = browser.getValue(userTypeInput);
expect(userType).to.equal(value.expected);
browser.waitForVisible(inputElem);
const inputValue = browser.getValue(inputElem);
expect(inputValue).to.equal(setting.original);
});
it('Close the Edit Existing User Modal', function () {
const closeButton = page.selectors.create_manage_users.current_users.button('Close');
Expand All @@ -224,6 +239,95 @@ describe('Internal Dashboard', function () {
});
});
});
describe('Make sure that the newly created user can have its settings updated successfully', function () {
settings.forEach(function (setting) {
describe(`Checking: ${setting.label}`, function () {
it('Select the "Existing Users" tab', function () {
browser.waitForVisible(page.selectors.user_management.tabs.existing_users());
browser.waitAndClick(page.selectors.user_management.tabs.existing_users());
});
it('Ensure that the "Existing Users" table is displayed', function () {
browser.waitForVisible(page.selectors.existing_users.table.container);
});
it('Double click the users row in the `Existing Users` table', function () {
const usernameCol = page.selectors.existing_users.table.col_for_user('btest', 'Username');
browser.waitForValue(usernameCol);
browser.doubleClick(usernameCol);

browser.waitForVisible(page.selectors.create_manage_users.window);
browser.waitForVisible(page.selectors.create_manage_users.current_users.container);
});
it(`Change the "${setting.label}" to "${setting.updated}"`, function () {
if ('dropdown' === setting.type) {
const inputTrigger = page.selectors.create_manage_users.current_users.settings.dropDownTriggerByLabel(setting.label);
browser.waitForVisible(inputTrigger);
browser.click(inputTrigger);

const inputDropDown = page.selectors.combo.container;
browser.waitForVisible(inputDropDown);

const dropDownValue = page.selectors.combo.itemByText(setting.updated);
browser.waitForVisible(dropDownValue);
browser.waitAndClick(dropDownValue);

browser.waitForInvisible(inputDropDown);
} else if ('text' === setting.type) {
const input = page.selectors.create_manage_users.current_users.settings.inputByLabel(setting.label, setting.type);
browser.waitForVisible(input);
browser.setValue(input, setting.updated);
}
});
it('Ensure that the user dirty message is shown', function () {
const dirtyMessage = page.selectors.create_manage_users.bottom_bar.messageByText('unsaved changes');
browser.waitForVisible(dirtyMessage);
});
it('Click the save button', function () {
const saveButton = page.selectors.create_manage_users.current_users.button('Save Changes');
browser.waitAndClick(saveButton);

const updateModal = page.selectors.updateSuccessNotification('btest');
browser.waitForVisible(updateModal);
browser.waitForInvisible(updateModal);
});
if ('User Type' === setting.label) {
it('Check that the user is not still selected.', function () {
const noUserSelectedModal = page.selectors.create_manage_users.current_users.settings.noUserSelectedModal();
browser.waitForVisible(noUserSelectedModal);
});
it('Check that the user is not listed in the Existing Users table', function () {
const updatedUser = page.selectors.create_manage_users.current_users.user_list.col_for_user('btest', 'Username');
browser.waitForInvisible(updatedUser);
});
it(`Change the Displayed User Type to: "${setting.updated}"`, function () {
const displayedUserType = page.selectors.create_manage_users.current_users.user_list.toolbar.buttonByLabel('Displaying', setting.original);
browser.waitForVisible(displayedUserType);
browser.waitAndClick(displayedUserType);

const newUserTypeItem = page.selectors.create_manage_users.current_users.user_list.dropDownItemByText(setting.updated);
browser.waitForVisible(newUserTypeItem);
browser.waitAndClick(newUserTypeItem);
});
it('Check that the user is listed in the Existing Users table.', function () {
const updatedUser = page.selectors.create_manage_users.current_users.user_list.col_for_user('btest', 'Username');
browser.waitForVisible(updatedUser);
});
} else {
it(`Check that "${setting.label}" has been updated successfully to "${setting.updated}"`, function () {
const inputType = 'dropdown' === setting.type ? 'text' : setting.type;
const input = page.selectors.create_manage_users.current_users.settings.inputByLabel(setting.label, inputType);
browser.waitForVisible(input);
const updatedValue = browser.getValue(input);
expect(updatedValue).to.equal(setting.updated);
});
}

it('Close the edit user modal', function () {
const closeButton = page.selectors.create_manage_users.current_users.button('Close');
browser.waitAndClick(closeButton);
});
});
});
});
describe('Remove the newly created User', function () {
it('Ensure that were on the "Existing Users" tab', function () {
browser.waitForVisible(page.selectors.user_management.tabs.existing_users());
Expand All @@ -239,14 +343,14 @@ describe('Internal Dashboard', function () {
browser.waitForVisible(page.selectors.create_manage_users.window);
});
it('Ensure that the "Actions" button is visible and click it', function () {
browser.waitForVisible(page.selectors.create_manage_users.current_users.toolbar.actions.button());
browser.waitForLoadedThenClick(page.selectors.create_manage_users.current_users.toolbar.actions.button());
browser.waitForVisible(page.selectors.create_manage_users.current_users.settings.toolbar.actions.button());
browser.waitForLoadedThenClick(page.selectors.create_manage_users.current_users.settings.toolbar.actions.button());
});
it('Ensure that the Actions menu has been displayed', function () {
browser.waitForVisible(page.selectors.create_manage_users.current_users.toolbar.actions.container);
browser.waitForVisible(page.selectors.create_manage_users.current_users.settings.toolbar.actions.container);
});
it('Click the "Delete This User" menu item', function () {
const deleteUserItem = page.selectors.create_manage_users.current_users.toolbar.actions.itemWithText('Delete This Account');
const deleteUserItem = page.selectors.create_manage_users.current_users.settings.toolbar.actions.itemWithText('Delete This Account');
browser.waitForVisible(deleteUserItem);
browser.click(deleteUserItem);
});
Expand Down
Loading

0 comments on commit 2714d6f

Please sign in to comment.