Skip to content

Commit

Permalink
reset branch
Browse files Browse the repository at this point in the history
  • Loading branch information
tiyiprh committed Aug 19, 2024
1 parent 8d4ed06 commit 7da9984
Show file tree
Hide file tree
Showing 2 changed files with 141 additions and 4 deletions.
133 changes: 133 additions & 0 deletions cypress/e2e/awx/access/users.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
/// <reference types="cypress" />

import { randomString } from '../../../../framework/utils/random-string';
import { Organization } from '../../../../frontend/awx/interfaces/Organization';
import { AwxUser } from '../../../../frontend/awx/interfaces/User';

describe('Users List Actions', () => {
let organization: Organization;
let user: AwxUser;

beforeEach(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
});

afterEach(() => {
cy.deleteAwxUser(user, { failOnStatusCode: false });
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
});

it('renders the users list page', () => {
cy.navigateTo('awx', 'users');
cy.verifyPageTitle('Users');
});

it('filters users by id', () => {
cy.navigateTo('awx', 'users');
cy.filterTableByMultiSelect('id', [user.id.toString()]);
cy.get('tr').should('have.length.greaterThan', 0);
if (user.id) {
cy.contains(user.id).should('be.visible');
}
cy.clearAllFilters();
});

it('creates and then deletes a basic user', () => {
const userName = 'E2E_User_' + randomString(4);
const password = randomString(12);
cy.navigateTo('awx', 'users');
cy.clickLink(/^Create user$/);
cy.get('[data-cy="username"]').type(userName);
cy.get('[data-cy="password"]').type(password);
cy.get('[data-cy="confirmpassword"]').type(password);
cy.singleSelectBy('[data-cy="organization"]', organization.name);
cy.clickButton(/^Create user$/);
cy.verifyPageTitle(userName);
// Clean up this user
cy.clickPageAction('delete-user');
cy.get('#confirm').click();
cy.clickButton(/^Delete user/);
cy.verifyPageTitle('Users');
});

it('renders the user details page', () => {
cy.navigateTo('awx', 'users');
cy.clickTableRowLink('username', user.username);
cy.verifyPageTitle(user.username);
cy.clickLink(/^Details$/);
cy.contains('#username', user.username);
});

it('edits a user from the details page', () => {
cy.navigateTo('awx', 'users');
cy.clickTableRowLink('username', user.username);
cy.verifyPageTitle(`Edit ${user.username}`);
cy.clickButton(/^Edit user$/);
cy.verifyPageTitle(`Edit ${user.username}`);
cy.get('[data-cy="username"]').type(user.username + 'a');
cy.clickButton(/^Save user$/);
cy.verifyPageTitle(`Edit ${user.username}`);
});

it('navigates to the edit form from the users list row item', () => {
cy.navigateTo('awx', 'users');
cy.clickTableRowPinnedAction(user.username, 'edit-user');
cy.verifyPageTitle(`Edit ${user.username}`);
});
});

describe('Users Delete Actions', () => {
let organization: Organization;
let user: AwxUser;

beforeEach(() => {
cy.createAwxOrganization().then((org) => {
organization = org;
cy.createAwxUser({ organization: organization.id }).then((testUser) => {
user = testUser;
});
});
});

afterEach(() => {
cy.deleteAwxUser(user, { failOnStatusCode: false });
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
});

it('deletes a user from the details page', () => {
cy.navigateTo('awx', 'users');
cy.clickTableRowLink('username', user.username);
cy.verifyPageTitle(user.username);
cy.clickPageAction('delete-user');
cy.get('#confirm').click();
cy.clickButton(/^Delete user/);
cy.verifyPageTitle('Users');
});

it('deletes a user from the users list row item', () => {
cy.navigateTo('awx', 'users');
cy.clickTableRowKebabAction(user.username, 'delete-user');
cy.get('#confirm').click();
cy.clickButton(/^Delete user/);
cy.contains(/^Success$/);
cy.clickButton(/^Close$/);
cy.clickButton(/^Clear all filters$/);
});

it('deletes a user from the users list toolbar', () => {
cy.navigateTo('awx', 'users');
cy.selectTableRow(user.username);
cy.clickToolbarKebabAction('delete-selected-users');
cy.get('#confirm').click();
cy.clickButton(/^Delete user/);
cy.contains(/^Success$/);
cy.clickButton(/^Close$/);
cy.clickButton(/^Clear all filters$/);
});
});
12 changes: 8 additions & 4 deletions frontend/awx/access/users/UserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export function CreateUser() {
return (
<PageLayout>
<PageHeader
title={t('Create User')}
title={t('Create user')}
breadcrumbs={[
{ label: t('Users'), to: getPageUrl(AwxRoute.Users) },
{ label: t('Create User') },
{ label: t('Create user') },
]}
/>
<AwxPageForm
Expand Down Expand Up @@ -130,10 +130,14 @@ export function EditUser() {
return (
<PageLayout>
<PageHeader
title={t('Edit User')}
title={user?.username ? t('Edit {{userName}}', { userName: user?.username }) : t('User')}
breadcrumbs={[
{ label: t('Users'), to: getPageUrl(AwxRoute.Users) },
{ label: t('Edit User') },
{
label: user?.username
? t('Edit {{userName}}', { userName: user?.username })
: t('User'),
},
]}
/>
<AwxPageForm<IUserInput>
Expand Down

0 comments on commit 7da9984

Please sign in to comment.