Member Index View Actions: "Add Organization" (#17879)
* Adds an Add Organization modal and e2e tests for the modal * Conditionally redirects to the correct view upon adding org * Combines modal tests within userIndexView.spec.js * Removes redundant code and switches assign role and add org button positions * Updates RSpec tests to account for conditional redirection * Lowercases the o in organization within _user_actions_dropdown.html.erb * Fixes failing e2e tests
This commit is contained in:
parent
a1dbfe35c8
commit
379a5fd3dd
5 changed files with 104 additions and 44 deletions
|
|
@ -51,7 +51,11 @@ module Admin
|
|||
flash[:danger] = organization_membership.errors_as_sentence
|
||||
end
|
||||
|
||||
redirect_to admin_user_path(organization_membership.user_id)
|
||||
if request.referer&.include?(admin_user_path(organization_membership.user_id))
|
||||
redirect_to admin_user_path(organization_membership.user_id)
|
||||
else
|
||||
redirect_to admin_users_path
|
||||
end
|
||||
end
|
||||
|
||||
format.js do
|
||||
|
|
|
|||
|
|
@ -133,5 +133,6 @@
|
|||
</div>
|
||||
<% if FeatureFlag.enabled?(:member_index_view) %>
|
||||
<%= render "admin/users/index/filters_modal" %>
|
||||
<%= render "admin/users/modals/add_organization_modal" %>
|
||||
<%= render "admin/users/modals/add_role_modal" %>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,18 @@
|
|||
Assign role
|
||||
</button>
|
||||
</li>
|
||||
<li><button class="c-btn align-left w-100 c-btn--icon-left"><%= crayons_icon_tag("team", aria_hidden: true, class: "c-btn__icon") %>Add organization</button></li>
|
||||
<li>
|
||||
<button class="c-btn align-left w-100 c-btn--icon-left"
|
||||
data-modal-title="Add organization"
|
||||
data-modal-size="small"
|
||||
data-modal-content-selector="#add-organization"
|
||||
data-user-name="<%= user.name %>"
|
||||
data-user-id="<%= user.id %>"
|
||||
data-form-action="<%= user_status_admin_user_path(user) %>">
|
||||
<%= crayons_icon_tag("team", aria_hidden: true, class: "c-btn__icon") %>
|
||||
Add organization
|
||||
</button>
|
||||
</li>
|
||||
<li><button class="c-btn align-left w-100 c-btn--icon-left"><%= crayons_icon_tag("wallet", aria_hidden: true, class: "c-btn__icon") %>Adjust credit balance</button><hr /></li>
|
||||
<% end %>
|
||||
<li><button data-copy-email="<%= user.email %>" type="button" class="c-btn w-100 align-left c-btn--icon-left"> <%= crayons_icon_tag("copy", aria_hidden: true, class: "c-btn__icon") %>Copy email address</button></li>
|
||||
|
|
|
|||
|
|
@ -339,45 +339,9 @@ describe('User index view', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('User index view with the member_index_view feature flag enabled', () => {
|
||||
describe('small screens', () => {
|
||||
beforeEach(() => {
|
||||
cy.testSetup();
|
||||
cy.fixture('users/adminUser.json').as('user');
|
||||
cy.enableFeatureFlag('member_index_view')
|
||||
.then(() => cy.get('@user'))
|
||||
.then((user) =>
|
||||
cy.loginAndVisit(user, '/admin/member_manager/users'),
|
||||
);
|
||||
cy.viewport('iphone-x');
|
||||
});
|
||||
|
||||
describe('User actions', () => {
|
||||
it('Opens the assign role modal', () => {
|
||||
cy.enableFeatureFlag('member_index_view');
|
||||
// Helper function for cypress-pipe
|
||||
const click = (el) => el.click();
|
||||
|
||||
cy.findByRole('button', { name: 'User actions: Admin McAdmin' })
|
||||
.as('userActionsButton')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('button', { name: 'Assign role' }).click();
|
||||
|
||||
cy.getModal().within(() => {
|
||||
cy.findByText('Add role').should('be.visible');
|
||||
cy.findByText('Add a note to this action:').should('be.visible');
|
||||
cy.findByRole('button', {
|
||||
name: 'Add',
|
||||
}).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('large screens', () => {
|
||||
describe('User index view with the member_index_view feature flag enabled', () => {
|
||||
describe('small screens', () => {
|
||||
beforeEach(() => {
|
||||
cy.testSetup();
|
||||
cy.fixture('users/adminUser.json').as('user');
|
||||
|
|
@ -386,7 +350,7 @@ describe('User index view', () => {
|
|||
.then((user) =>
|
||||
cy.loginAndVisit(user, '/admin/member_manager/users'),
|
||||
);
|
||||
cy.viewport('macbook-16');
|
||||
cy.viewport('iphone-x');
|
||||
});
|
||||
|
||||
describe('User actions', () => {
|
||||
|
|
@ -410,6 +374,86 @@ describe('User index view', () => {
|
|||
}).should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
it('Opens the add organization modal', () => {
|
||||
cy.enableFeatureFlag('member_index_view');
|
||||
// Helper function for cypress-pipe
|
||||
const click = (el) => el.click();
|
||||
|
||||
cy.findByRole('button', { name: 'User actions: Admin McAdmin' })
|
||||
.as('userActionsButton')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('button', { name: 'Add organization' }).click();
|
||||
|
||||
cy.getModal().within(() => {
|
||||
cy.findByText('Organization ID').should('be.visible');
|
||||
cy.findByText('Role').should('be.visible');
|
||||
cy.findByRole('button', {
|
||||
name: 'Add organization',
|
||||
}).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('large screens', () => {
|
||||
beforeEach(() => {
|
||||
cy.testSetup();
|
||||
cy.fixture('users/adminUser.json').as('user');
|
||||
cy.enableFeatureFlag('member_index_view')
|
||||
.then(() => cy.get('@user'))
|
||||
.then((user) =>
|
||||
cy.loginAndVisit(user, '/admin/member_manager/users'),
|
||||
);
|
||||
cy.viewport('macbook-16');
|
||||
});
|
||||
|
||||
describe('User actions', () => {
|
||||
it('Opens the assign role modal', () => {
|
||||
cy.enableFeatureFlag('member_index_view');
|
||||
// Helper function for cypress-pipe
|
||||
const click = (el) => el.click();
|
||||
|
||||
cy.findByRole('button', { name: 'User actions: Admin McAdmin' })
|
||||
.as('userActionsButton')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('button', { name: 'Assign role' }).click();
|
||||
|
||||
cy.getModal().within(() => {
|
||||
cy.findByText('Add role').should('be.visible');
|
||||
cy.findByText('Add a note to this action:').should(
|
||||
'be.visible',
|
||||
);
|
||||
cy.findByRole('button', {
|
||||
name: 'Add',
|
||||
}).should('exist');
|
||||
});
|
||||
});
|
||||
|
||||
it('Opens the add organization modal', () => {
|
||||
cy.enableFeatureFlag('member_index_view');
|
||||
// Helper function for cypress-pipe
|
||||
const click = (el) => el.click();
|
||||
|
||||
cy.findByRole('button', { name: 'User actions: Admin McAdmin' })
|
||||
.as('userActionsButton')
|
||||
.pipe(click)
|
||||
.should('have.attr', 'aria-expanded', 'true');
|
||||
|
||||
cy.findByRole('button', { name: 'Add organization' }).click();
|
||||
|
||||
cy.getModal().within(() => {
|
||||
cy.findByText('Organization ID').should('be.visible');
|
||||
cy.findByText('Role').should('be.visible');
|
||||
cy.findByRole('button', {
|
||||
name: 'Add organization',
|
||||
}).should('exist');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ RSpec.describe "/admin/organization_memberships", type: :request do
|
|||
}
|
||||
end.to not_change(user.organizations, :count)
|
||||
|
||||
expect(response).to redirect_to(admin_user_path(user.id))
|
||||
expect(response).to redirect_to(admin_users_path)
|
||||
expect(flash[:danger]).to include("does not exist")
|
||||
end
|
||||
|
||||
|
|
@ -36,7 +36,7 @@ RSpec.describe "/admin/organization_memberships", type: :request do
|
|||
}
|
||||
end.to not_change(user.organizations, :count)
|
||||
|
||||
expect(response).to redirect_to(admin_user_path(user.id))
|
||||
expect(response).to redirect_to(admin_users_path)
|
||||
expect(flash[:danger]).to include("not included in the list")
|
||||
end
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ RSpec.describe "/admin/organization_memberships", type: :request do
|
|||
}
|
||||
end.to change(user.organizations, :count).by(1)
|
||||
|
||||
expect(response).to redirect_to(admin_user_path(user.id))
|
||||
expect(response).to redirect_to(admin_users_path)
|
||||
expect(flash[:success]).to include("successfully added")
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue