Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

B 21997 UI order #14532

Merged
merged 29 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8cddf75
Working changes with let instead of var
antgmann Dec 19, 2024
a98f398
Fixed span and added tests
antgmann Dec 19, 2024
2ff3f26
Merge branch 'main' into B-21997-UI-Order
antgmann Dec 19, 2024
c3b501e
Cut out comments
antgmann Dec 19, 2024
2be9603
Experimental circleci solution
antgmann Dec 19, 2024
5090f95
Separate tests so playwright doesnt step on its own toes
antgmann Dec 19, 2024
38dd680
Remove old test
antgmann Dec 19, 2024
b42b33c
turn on hq ff for circleci
r-mettler Dec 20, 2024
c92b891
change playwright tests to use actual transpo office
r-mettler Dec 20, 2024
255a41d
Attempt to re-consolidate tests, playwright not working locally
antgmann Dec 23, 2024
ddfa2a3
Fix test
antgmann Dec 23, 2024
b9be286
Local playwright issues
antgmann Dec 23, 2024
8b622bc
Hopefully final fix
antgmann Dec 23, 2024
33b4a7e
Roles changes
antgmann Dec 23, 2024
eba18be
Merge branch 'main' into B-21997-UI-Order
antgmann Jan 7, 2025
0b26e27
Merge branch 'main' into B-21997-UI-Order
antgmann Jan 7, 2025
1817b65
Remove duplicate message
antgmann Jan 7, 2025
61148c2
Merge branch 'main' into B-21997-UI-Order
antgmann Jan 8, 2025
96d0d42
Merge branch 'main' into B-21997-UI-Order
r-mettler Jan 8, 2025
9048041
Merge branch 'main' into B-21997-UI-Order
antgmann Jan 9, 2025
749b73e
Merge branch 'main' into B-21997-UI-Order
r-mettler Jan 10, 2025
be960dd
Merge branch 'main' into B-21997-UI-Order
r-mettler Jan 13, 2025
d8554cf
Merge branch 'main' into B-21997-UI-Order
antgmann Jan 14, 2025
01d0b77
Add tests for coverage
antgmann Jan 14, 2025
a3dbb61
Fix typo
antgmann Jan 14, 2025
fad47fd
Merge branch 'main' into B-21997-UI-Order
antgmann Jan 15, 2025
ccbbff7
Merge branch 'main' into B-21997-UI-Order
antgmann Jan 15, 2025
c29a9e7
Merge branch 'main' into B-21997-UI-Order
r-mettler Jan 16, 2025
7c07606
Merge branch 'main' into B-21997-UI-Order
r-mettler Jan 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ commands:
export FEATURE_FLAG_VALIDATION_CODE_REQUIRED=false
export FEATURE_FLAG_MOVE_LOCK=false
export FEATURE_FLAG_OKTA_DODID_INPUT=false
export FEATURE_FLAG_HEADQUARTERS_ROLE=false
export FEATURE_FLAG_HEADQUARTERS_ROLE=true
export FEATURE_FLAG_GSR_ROLE=false
export FEATURE_FLAG_SAFETY_MOVE=false
export FEATURE_FLAG_MANAGE_SUPPORTING_DOCS=false
Expand Down Expand Up @@ -936,7 +936,7 @@ commands:
FEATURE_FLAG_VALIDATION_CODE_REQUIRED: 'false'
FEATURE_FLAG_MOVE_LOCK: 'false'
FEATURE_FLAG_OKTA_DODID_INPUT: 'false'
FEATURE_FLAG_HEADQUARTERS_ROLE: 'false'
FEATURE_FLAG_HEADQUARTERS_ROLE: 'true'
FEATURE_FLAG_GSR_ROLE: 'false'
FEATURE_FLAG_SAFETY_MOVE: 'false'
FEATURE_FLAG_MANAGE_SUPPORTING_DOCS: 'false'
Expand Down
331 changes: 329 additions & 2 deletions playwright/tests/admin/officeUsers.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ test.describe('Office User Create Page', () => {

// The autocomplete form results in multiple matching elements, so
// pick the input element
await page.getByLabel('Transportation Office').nth(0).fill('JPPSO Testy McTest');
await page.getByLabel('Transportation Office').nth(0).fill('PPPO Scott AFB - USAF');
// the autocomplete might return multiples because of concurrent
// tests running that are adding offices
await page.getByRole('option', { name: 'JPPSO Testy McTest' }).first().click();
await page.getByRole('option', { name: 'PPPO Scott AFB - USAF' }).first().click();

await page.getByRole('button', { name: 'Save' }).click();
await adminPage.waitForPage.adminPage();
Expand All @@ -110,6 +110,161 @@ test.describe('Office User Create Page', () => {
await expect(page.locator('#telephone')).toHaveValue('222-555-1234');
await expect(page.locator('#active')).toHaveText('Yes');
});

test('has correct supervisor role permissions', async ({ page, adminPage }) => {
await adminPage.signInAsNewAdminUser();
// we tested the side nav in the previous test,
// so let's work with the assumption that we were already redirected to this page:
expect(page.url()).toContain('/system/requested-office-users');
await page.getByRole('menuitem', { name: 'Office Users', exact: true }).click();
expect(page.url()).toContain('/system/office-users');

await page.getByRole('link', { name: 'Create' }).click();
await expect(page.getByRole('heading', { name: 'Create Office Users', exact: true })).toBeVisible();

expect(page.url()).toContain('/system/office-users/create');

// we need to add the date to the email so that it is unique every time (only one record per email allowed in db)
const testEmail = `cy.admin_user.${Date.now()}@example.com`;

// create an office user
const firstName = page.getByLabel('First name');
await firstName.focus();
await firstName.fill('Cypress');

const lastName = page.getByLabel('Last name');
await lastName.focus();
await lastName.fill('Test');

const email = page.getByLabel('Email');
await email.focus();
await email.fill(testEmail);

const phone = page.getByLabel('Telephone');
await phone.focus();
await phone.fill('222-555-1234');

// Define constants for all roles checkboxes to be tested
const customerCheckbox = page.getByLabel('Customer', { exact: true });
const contractingOfficerCheckbox = page.getByLabel('Contracting Officer', { exact: true });
const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true });
const primeSimulatorCheckbox = page.getByLabel('Prime Simulator', { exact: true });
const qualityAssuranceEvaluatorCheckbox = page.getByLabel('Quality Assurance Evaluator', { exact: true });
const customerServiceRepersentativeCheckbox = page.getByLabel('Customer Service Representative', { exact: true });
const governmentSurveillanceRepresentativeCheckbox = page.getByLabel('Government Surveillance Representative', {
exact: true,
});
const headquartersCheckbox = page.getByLabel('Headquarters', { exact: true });
const taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true });
const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true });

// Define constants for privileges
const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true });

// Check roles that cannot have supervisor priveleges
await customerCheckbox.click();
await supervisorCheckbox.click();
await expect(customerCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await customerCheckbox.click();
await contractingOfficerCheckbox.click();
await supervisorCheckbox.click();
await expect(contractingOfficerCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await contractingOfficerCheckbox.click();
await primeSimulatorCheckbox.click();
await supervisorCheckbox.click();
await expect(primeSimulatorCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await primeSimulatorCheckbox.click();
await qualityAssuranceEvaluatorCheckbox.click();
await supervisorCheckbox.click();
await expect(qualityAssuranceEvaluatorCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await qualityAssuranceEvaluatorCheckbox.click();
await customerServiceRepersentativeCheckbox.click();
await supervisorCheckbox.click();
await expect(customerServiceRepersentativeCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await customerServiceRepersentativeCheckbox.click();
await governmentSurveillanceRepresentativeCheckbox.click();
await supervisorCheckbox.click();
await expect(governmentSurveillanceRepresentativeCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await governmentSurveillanceRepresentativeCheckbox.click();
await headquartersCheckbox.click();
await supervisorCheckbox.click();
await expect(headquartersCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await headquartersCheckbox.click();

// Check roles that can have supervisor priveleges
await taskOrderingOfficerCheckbox.click();
await supervisorCheckbox.click();
await expect(taskOrderingOfficerCheckbox).toBeChecked();
await expect(supervisorCheckbox).toBeChecked();
await taskOrderingOfficerCheckbox.click();
await supervisorCheckbox.click();
await taskInvoicingOfficerCheckbox.click();
await supervisorCheckbox.click();
await expect(taskInvoicingOfficerCheckbox).toBeChecked();
await expect(supervisorCheckbox).toBeChecked();
await taskInvoicingOfficerCheckbox.click();
await supervisorCheckbox.click();
await servicesCounselorCheckbox.click();
await supervisorCheckbox.click();
await expect(servicesCounselorCheckbox).toBeChecked();
await expect(supervisorCheckbox).toBeChecked();
await servicesCounselorCheckbox.click();

// Check selecting roles after having supervisor selected for unallowed roles
await customerCheckbox.click();
await expect(customerCheckbox).not.toBeChecked();
await contractingOfficerCheckbox.click();
await expect(contractingOfficerCheckbox).not.toBeChecked();
await primeSimulatorCheckbox.click();
await expect(primeSimulatorCheckbox).not.toBeChecked();
await qualityAssuranceEvaluatorCheckbox.click();
await expect(qualityAssuranceEvaluatorCheckbox).not.toBeChecked();
await customerServiceRepersentativeCheckbox.click();
await expect(customerServiceRepersentativeCheckbox).not.toBeChecked();
await governmentSurveillanceRepresentativeCheckbox.click();
await expect(governmentSurveillanceRepresentativeCheckbox).not.toBeChecked();
await headquartersCheckbox.click();
await expect(headquartersCheckbox).not.toBeChecked();

// Check selecting roles after having supervisor selected for allowed roles
await taskOrderingOfficerCheckbox.click();
await expect(taskOrderingOfficerCheckbox).toBeChecked();
await taskOrderingOfficerCheckbox.click();
await taskInvoicingOfficerCheckbox.click();
await expect(taskInvoicingOfficerCheckbox).toBeChecked();
await taskInvoicingOfficerCheckbox.click();
await servicesCounselorCheckbox.click();
await expect(servicesCounselorCheckbox).toBeChecked();

// Continue test to ensure form still submits with valid information
// The autocomplete form results in multiple matching elements, so
// pick the input element
await page.getByLabel('Transportation Office').nth(0).fill('PPPO Scott AFB - USAF');
// the autocomplete might return multiples because of concurrent
// tests running that are adding offices
await page.getByRole('option', { name: 'PPPO Scott AFB - USAF' }).first().click();

await page.getByRole('button', { name: 'Save' }).click();
await adminPage.waitForPage.adminPage();

// redirected to edit details page
const officeUserID = await page.locator('#id').inputValue();

await expect(page.getByRole('heading', { name: `Office Users #${officeUserID}` })).toBeVisible();

await expect(page.locator('#email')).toHaveValue(testEmail);
await expect(page.locator('#firstName')).toHaveValue('Cypress');
await expect(page.locator('#lastName')).toHaveValue('Test');
await expect(page.locator('#telephone')).toHaveValue('222-555-1234');
await expect(page.locator('#active')).toHaveText('Yes');
});
});

test.describe('Office Users Show Page', () => {
Expand Down Expand Up @@ -228,6 +383,178 @@ test.describe('Office Users Edit Page', () => {
await expect(page.locator(`tr:has(:text("${email}")) >> td.column-lastName`)).toHaveText('NewLast');
});

test('has correct supervisor role permissions', async ({ page, adminPage }) => {
const officeUser = await adminPage.testHarness.buildOfficeUserWithTOOAndTIO();
const email = officeUser.okta_email;

await adminPage.signInAsNewAdminUser();

expect(page.url()).toContain('/system/requested-office-users');
await page.getByRole('menuitem', { name: 'Office Users', exact: true }).click();
expect(page.url()).toContain('/system/office-users');
await searchForOfficeUser(page, email);
await page.getByText(email).click();
await adminPage.waitForPage.adminPage();

await page.getByRole('link', { name: 'Edit' }).click();
await adminPage.waitForPage.adminPage();

const disabledFields = ['id', 'email', 'userId', 'createdAt', 'updatedAt'];
for (const field of disabledFields) {
await expect(page.locator(`#${field}`)).toBeDisabled();
}

const firstName = page.getByLabel('First name');
await firstName.focus();
await firstName.clear();
await firstName.fill('NewFirst');

const lastName = page.getByLabel('Last name');
await lastName.focus();
await lastName.clear();
await lastName.fill('NewLast');

// The autocomplete form results in multiple matching elements, so
// pick the input element
await expect(page.getByLabel('Transportation Office').nth(0)).toBeEditable();

// Add a Transportation Office Assignment
await page.getByTestId('addTransportationOfficeButton').click();
// n = 2 because of the disabled GBLOC input
await expect(page.getByLabel('Transportation Office').nth(2)).toBeEditable();
await page.getByLabel('Transportation Office').nth(2).fill('AGFM');
// the autocomplete might return multiples because of concurrent
// tests running that are adding offices
await page.getByRole('option', { name: 'JPPSO - North East (AGFM) - USAF' }).first().click();
// Set as primary transportation office
await page.getByLabel('Primary Office').nth(1).click();
await page.getByText('You cannot designate more than one primary transportation office.');
await page.getByLabel('Primary Office').nth(1).click();

// set the user to the active status they did NOT have before
const activeStatus = await page.locator('div:has(label :text-is("Active")) >> input[name="active"]').inputValue();

const newStatus = (activeStatus !== 'true').toString();
await page.locator('div:has(label :text-is("Active")) >> #active').click();
await page.locator(`ul[aria-labelledby="active-label"] >> li[data-value="${newStatus}"]`).click();

// Define constants for all roles checkboxes to be tested
const customerCheckbox = page.getByLabel('Customer', { exact: true });
const contractingOfficerCheckbox = page.getByLabel('Contracting Officer', { exact: true });
const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true });
const primeSimulatorCheckbox = page.getByLabel('Prime Simulator', { exact: true });
const qualityAssuranceEvaluatorCheckbox = page.getByLabel('Quality Assurance Evaluator', { exact: true });
const customerServiceRepersentativeCheckbox = page.getByLabel('Customer Service Representative', { exact: true });
const governmentSurveillanceRepresentativeCheckbox = page.getByLabel('Government Surveillance Representative', {
exact: true,
});
const headquartersCheckbox = page.getByLabel('Headquarters', { exact: true });
const taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true });
const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true });

// Define constants for privileges
const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true });

// Disable existing roles for testing
await taskOrderingOfficerCheckbox.click();
await taskInvoicingOfficerCheckbox.click();

// Check roles that cannot have supervisor priveleges
await customerCheckbox.click();
await supervisorCheckbox.click();
await expect(customerCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await customerCheckbox.click();
await contractingOfficerCheckbox.click();
await supervisorCheckbox.click();
await expect(contractingOfficerCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await contractingOfficerCheckbox.click();
await primeSimulatorCheckbox.click();
await supervisorCheckbox.click();
await expect(primeSimulatorCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await primeSimulatorCheckbox.click();
await qualityAssuranceEvaluatorCheckbox.click();
await supervisorCheckbox.click();
await expect(qualityAssuranceEvaluatorCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await qualityAssuranceEvaluatorCheckbox.click();
await customerServiceRepersentativeCheckbox.click();
await supervisorCheckbox.click();
await expect(customerServiceRepersentativeCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await customerServiceRepersentativeCheckbox.click();
await governmentSurveillanceRepresentativeCheckbox.click();
await supervisorCheckbox.click();
await expect(governmentSurveillanceRepresentativeCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await governmentSurveillanceRepresentativeCheckbox.click();
await headquartersCheckbox.click();
await supervisorCheckbox.click();
await expect(headquartersCheckbox).toBeChecked();
await expect(supervisorCheckbox).not.toBeChecked();
await headquartersCheckbox.click();

// Check roles that can have supervisor priveleges
await taskOrderingOfficerCheckbox.click();
await supervisorCheckbox.click();
await expect(taskOrderingOfficerCheckbox).toBeChecked();
await expect(supervisorCheckbox).toBeChecked();
await taskOrderingOfficerCheckbox.click();
await supervisorCheckbox.click();
await taskInvoicingOfficerCheckbox.click();
await supervisorCheckbox.click();
await expect(taskInvoicingOfficerCheckbox).toBeChecked();
await expect(supervisorCheckbox).toBeChecked();
await taskInvoicingOfficerCheckbox.click();
await supervisorCheckbox.click();
await servicesCounselorCheckbox.click();
await supervisorCheckbox.click();
await expect(servicesCounselorCheckbox).toBeChecked();
await expect(supervisorCheckbox).toBeChecked();
await servicesCounselorCheckbox.click();

// Check selecting roles after having supervisor selected for unallowed roles
await customerCheckbox.click();
await expect(customerCheckbox).not.toBeChecked();
await contractingOfficerCheckbox.click();
await expect(contractingOfficerCheckbox).not.toBeChecked();
await primeSimulatorCheckbox.click();
await expect(primeSimulatorCheckbox).not.toBeChecked();
await qualityAssuranceEvaluatorCheckbox.click();
await expect(qualityAssuranceEvaluatorCheckbox).not.toBeChecked();
await customerServiceRepersentativeCheckbox.click();
await expect(customerServiceRepersentativeCheckbox).not.toBeChecked();
await governmentSurveillanceRepresentativeCheckbox.click();
await expect(governmentSurveillanceRepresentativeCheckbox).not.toBeChecked();
await headquartersCheckbox.click();
await expect(headquartersCheckbox).not.toBeChecked();

// Check selecting roles after having supervisor selected for allowed roles
await taskOrderingOfficerCheckbox.click();
await expect(taskOrderingOfficerCheckbox).toBeChecked();
await taskOrderingOfficerCheckbox.click();
await taskInvoicingOfficerCheckbox.click();
await expect(taskInvoicingOfficerCheckbox).toBeChecked();
await taskInvoicingOfficerCheckbox.click();
await servicesCounselorCheckbox.click();
await expect(servicesCounselorCheckbox).toBeChecked();

// Continue test to ensure form still submits with valid information
await page.getByRole('button', { name: 'Save' }).click();
await adminPage.waitForPage.adminPage();

await searchForOfficeUser(page, email);
await expect(page.locator(`tr:has(:text("${email}")) >> td.column-active >> svg`)).toHaveAttribute(
'data-testid',
newStatus,
);

await expect(page.locator(`tr:has(:text("${email}")) >> td.column-firstName`)).toHaveText('NewFirst');
await expect(page.locator(`tr:has(:text("${email}")) >> td.column-lastName`)).toHaveText('NewLast');
});

test('prevents safety move priv selection with Customer role', async ({ page, adminPage }) => {
const officeUser = await adminPage.testHarness.buildOfficeUserWithCustomer();
const email = officeUser.okta_email;
Expand Down
Loading
Loading