* Updates the copy for all modals within Admin Member Detail view * Resolve most failing tests within managaUserOptions.spec.js * Update app/views/admin/users/show/profile/actions/_export.html.erb Co-authored-by: Suzanne Aitchison <suzanne@forem.com> * Update cypress/integration/seededFlows/adminFlows/users/manageUserOptions.spec.js Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
125 lines
3.7 KiB
JavaScript
125 lines
3.7 KiB
JavaScript
function openUserOptions(callback) {
|
|
cy.findByRole('button', { name: 'Options' })
|
|
.should('have.attr', 'aria-haspopup', 'true')
|
|
.should('have.attr', 'aria-expanded', 'false')
|
|
.click()
|
|
.then(([button]) => {
|
|
expect(button.getAttribute('aria-expanded')).to.equal('true');
|
|
const dropdownId = button.getAttribute('aria-controls');
|
|
|
|
cy.get(`#${dropdownId}`).within(callback);
|
|
});
|
|
}
|
|
|
|
function verifyAndDismissUserUpdatedMessage(message) {
|
|
cy.findByTestId('flash-success')
|
|
.as('success')
|
|
.then((element) => {
|
|
expect(element.text().trim()).equal(message);
|
|
});
|
|
|
|
cy.get('@success').within(() => {
|
|
cy.findByRole('button', { name: 'Dismiss message' })
|
|
.should('have.focus')
|
|
.click();
|
|
});
|
|
|
|
cy.findByTestId('flash-success').should('not.exist');
|
|
}
|
|
|
|
describe('Manage User Options', () => {
|
|
describe('As an admin', () => {
|
|
beforeEach(() => {
|
|
cy.testSetup();
|
|
cy.fixture('users/adminUser.json').as('user');
|
|
cy.get('@user').then((user) => {
|
|
cy.loginAndVisit(user, '/admin/users/2');
|
|
});
|
|
});
|
|
|
|
it(`should export a user's data to an admin`, () => {
|
|
openUserOptions(() => {
|
|
cy.findByRole('button', { name: 'Export data' }).click();
|
|
});
|
|
|
|
cy.getModal().within(() => {
|
|
cy.findByRole('button', { name: 'Export to Admin' }).click();
|
|
});
|
|
|
|
verifyAndDismissUserUpdatedMessage(
|
|
'Data exported to the admin. The job will complete momentarily.',
|
|
);
|
|
});
|
|
|
|
it(`should export a user's data to the user`, () => {
|
|
openUserOptions(() => {
|
|
cy.findByRole('button', { name: 'Export data' }).click();
|
|
});
|
|
|
|
cy.getModal().within(() => {
|
|
cy.findByRole('button', { name: 'Export to User' }).click();
|
|
});
|
|
|
|
verifyAndDismissUserUpdatedMessage(
|
|
'Data exported to the user. The job will complete momentarily.',
|
|
);
|
|
});
|
|
|
|
it(`should merge a user's account with another account`, () => {
|
|
openUserOptions(() => {
|
|
cy.findByRole('button', { name: 'Merge users' }).click();
|
|
});
|
|
|
|
cy.getModal().within(() => {
|
|
cy.findByRole('spinbutton', { name: 'User ID' }).type('3');
|
|
cy.findByRole('button', { name: 'Merge and delete' }).click();
|
|
});
|
|
});
|
|
|
|
it(`should banish a user for spam`, () => {
|
|
openUserOptions(() => {
|
|
cy.findByRole('button', { name: 'Banish user' }).click();
|
|
});
|
|
|
|
cy.getModal().within(() => {
|
|
cy.findByRole('button', { name: 'Banish Trusted User 1 \\:/' }).click();
|
|
});
|
|
|
|
verifyAndDismissUserUpdatedMessage(
|
|
'This user is being banished in the background. The job will complete soon.',
|
|
);
|
|
});
|
|
|
|
it(`should delete a user`, () => {
|
|
openUserOptions(() => {
|
|
cy.findByRole('button', { name: 'Delete user' }).click();
|
|
});
|
|
|
|
cy.getModal().within(() => {
|
|
cy.findByRole('button', {
|
|
name: 'Delete now',
|
|
}).click();
|
|
});
|
|
|
|
verifyAndDismissUserUpdatedMessage(
|
|
'@trusted_user_1 (email: trusted-user-1@forem.local, user_id: 2) has been fully deleted. If this is a GDPR delete, delete them from Mailchimp & Google Analytics and confirm on the page.',
|
|
);
|
|
});
|
|
|
|
it(`should not unpublish all posts of a user if the user has no posts`, () => {
|
|
openUserOptions(() => {
|
|
cy.findByRole('button', { name: 'Unpublish all posts' }).should(
|
|
'not.exist',
|
|
);
|
|
});
|
|
});
|
|
|
|
it(`should not remove social accounts of a user if the user has no social accounts`, () => {
|
|
openUserOptions(() => {
|
|
cy.findByRole('button', { name: 'Remove social accounts' }).should(
|
|
'not.exist',
|
|
);
|
|
});
|
|
});
|
|
});
|
|
});
|