From 8cddf75713e9d55081e2963a43b91c2dbe503c3c Mon Sep 17 00:00:00 2001 From: antgmann Date: Thu, 19 Dec 2024 16:28:31 +0000 Subject: [PATCH 01/16] Working changes with let instead of var --- .../shared/RolesPrivilegesCheckboxes.jsx | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx b/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx index 1cc554ed70d..ed9c172a0bd 100644 --- a/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx +++ b/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx @@ -50,6 +50,36 @@ const RolesPrivilegesCheckboxInput = (props) => { input.splice(index, 1); } } + if (input.includes(roleTypes.PRIME_SIMULATOR)) { + index = input.indexOf(roleTypes.PRIME_SIMULATOR); + if (index !== -1) { + input.splice(index, 1); + } + } + if (input.includes(roleTypes.QAE)) { + index = input.indexOf(roleTypes.QAE); + if (index !== -1) { + input.splice(index, 1); + } + } + if (input.includes(roleTypes.CUSTOMER_SERVICE_REPRESENTATIVE)) { + index = input.indexOf(roleTypes.CUSTOMER_SERVICE_REPRESENTATIVE); + if (index !== -1) { + input.splice(index, 1); + } + } + if (input.includes(roleTypes.GSR)) { + index = input.indexOf(roleTypes.GSR); + if (index !== -1) { + input.splice(index, 1); + } + } + if (input.includes(roleTypes.HQ)) { + index = input.indexOf(roleTypes.HQ); + if (index !== -1) { + input.splice(index, 1); + } + } } if (privilegesSelected.includes(elevatedPrivilegeTypes.SAFETY)) { @@ -110,8 +140,16 @@ const RolesPrivilegesCheckboxInput = (props) => { }; const parsePrivilegesCheckboxInput = (input) => { - var index; - if (rolesSelected.includes(roleTypes.CUSTOMER) || rolesSelected.includes(roleTypes.CONTRACTING_OFFICER)) { + let index; + if ( + rolesSelected.includes(roleTypes.CUSTOMER) || + rolesSelected.includes(roleTypes.CONTRACTING_OFFICER) || + rolesSelected.includes(roleTypes.PRIME_SIMULATOR) || + rolesSelected.includes(roleTypes.QAE) || + rolesSelected.includes(roleTypes.CUSTOMER_SERVICE_REPRESENTATIVE) || + rolesSelected.includes(roleTypes.GSR) || + rolesSelected.includes(roleTypes.HQ) + ) { if (input.includes(elevatedPrivilegeTypes.SUPERVISOR)) { index = input.indexOf(elevatedPrivilegeTypes.SUPERVISOR); if (index !== -1) { @@ -140,7 +178,6 @@ const RolesPrivilegesCheckboxInput = (props) => { return privilegesArray; }, []); }; - // filter the privileges to exclude the Safety Moves checkbox if the admin user is NOT a super admin const filteredPrivileges = officeUserPrivileges.filter((privilege) => { if (privilege.privilegeType === elevatedPrivilegeTypes.SAFETY && !adminUser?.super) { From a98f3982d590cf8a601530390c34e275d36f7695 Mon Sep 17 00:00:00 2001 From: antgmann Date: Thu, 19 Dec 2024 17:35:05 +0000 Subject: [PATCH 02/16] Fixed span and added tests --- playwright/tests/admin/officeUsers.spec.js | 341 ++++++++++++++++++ .../shared/RolesPrivilegesCheckboxes.jsx | 3 +- 2 files changed, 343 insertions(+), 1 deletion(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index fd7646a2604..3d25a5b02c5 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -110,6 +110,171 @@ 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 privileges on create page', 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'); + + // middle initials are not working for me in chrome outside of + // playwright - ahobson 2022-12-29 + // await page.getByLabel('Middle initials').fill('X'); + 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { 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 }); + + // 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 expect(supervisorCheckbox).toBeChecked(); + await taskOrderingOfficerCheckbox.click(); + await expect(taskOrderingOfficerCheckbox).toBeChecked(); + await taskInvoicingOfficerCheckbox.click(); + await expect(taskInvoicingOfficerCheckbox).toBeChecked(); + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + // Continue test to ensure form still submits with valid information + await taskOrderingOfficerCheckbox.click(); + await expect(taskOrderingOfficerCheckbox).not.toBeChecked(); + await taskInvoicingOfficerCheckbox.click(); + await expect(taskInvoicingOfficerCheckbox).not.toBeChecked(); + + // The autocomplete form results in multiple matching elements, so + // pick the input element + await page.getByLabel('Transportation Office').nth(0).fill('JPPSO Testy McTest'); + // 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('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'); + // middle initials are not working for me in chrome outside of + // playwright - ahobson 2022-12-29 + // await expect(page.locator('#middleInitials')).toHaveValue('X'); + await expect(page.locator('#telephone')).toHaveValue('222-555-1234'); + await expect(page.locator('#active')).toHaveText('Yes'); + }); }); test.describe('Office Users Show Page', () => { @@ -228,6 +393,182 @@ test.describe('Office Users Edit Page', () => { await expect(page.locator(`tr:has(:text("${email}")) >> td.column-lastName`)).toHaveText('NewLast'); }); + test('has correct supervisor privileges on edit page', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { 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 }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Deselect 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 expect(supervisorCheckbox).toBeChecked(); + await taskOrderingOfficerCheckbox.click(); + await expect(taskOrderingOfficerCheckbox).toBeChecked(); + await taskInvoicingOfficerCheckbox.click(); + await expect(taskInvoicingOfficerCheckbox).toBeChecked(); + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + // Continue test to ensure form still submits with valid information + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).not.toBeChecked(); + await taskInvoicingOfficerCheckbox.click(); + await expect(taskInvoicingOfficerCheckbox).not.toBeChecked(); + + 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; diff --git a/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx b/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx index ed9c172a0bd..d2fdac32c02 100644 --- a/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx +++ b/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx @@ -205,7 +205,8 @@ const RolesPrivilegesCheckboxInput = (props) => { optionValue="privilegeType" /> - Privileges cannot be selected with Customer or Contracting Officer roles. + The Supervisor privilege can only be selected for the following roles: Task Ordering Officer, Task Invoicing + Officer, Services Counselor. The Safety Moves privilege can only be selected for the following roles: Task Ordering Officer, Task Invoicing From c3b501ed27e410ef05deae3133c5379f080b6781 Mon Sep 17 00:00:00 2001 From: antgmann Date: Thu, 19 Dec 2024 19:51:32 +0000 Subject: [PATCH 03/16] Cut out comments --- playwright/tests/admin/officeUsers.spec.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 3d25a5b02c5..4e1b5642637 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -132,9 +132,6 @@ test.describe('Office User Create Page', () => { await firstName.focus(); await firstName.fill('Cypress'); - // middle initials are not working for me in chrome outside of - // playwright - ahobson 2022-12-29 - // await page.getByLabel('Middle initials').fill('X'); const lastName = page.getByLabel('Last name'); await lastName.focus(); await lastName.fill('Test'); @@ -269,9 +266,6 @@ test.describe('Office User Create Page', () => { await expect(page.locator('#email')).toHaveValue(testEmail); await expect(page.locator('#firstName')).toHaveValue('Cypress'); await expect(page.locator('#lastName')).toHaveValue('Test'); - // middle initials are not working for me in chrome outside of - // playwright - ahobson 2022-12-29 - // await expect(page.locator('#middleInitials')).toHaveValue('X'); await expect(page.locator('#telephone')).toHaveValue('222-555-1234'); await expect(page.locator('#active')).toHaveText('Yes'); }); From 2be96032a61c2d4a5d8dd73f4223e321cf145f20 Mon Sep 17 00:00:00 2001 From: antgmann Date: Thu, 19 Dec 2024 20:57:41 +0000 Subject: [PATCH 04/16] Experimental circleci solution --- playwright/tests/admin/officeUsers.spec.js | 366 +++++++++++++++++++++ 1 file changed, 366 insertions(+) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 4e1b5642637..8a98e12152e 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -263,6 +263,372 @@ test.describe('Office User Create Page', () => { 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('roles unauthorized for supervisor cannot select', 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 }); + + // 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(); + + // Continue test to ensure form still submits with valid information + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + // The autocomplete form results in multiple matching elements, so + // pick the input element + await page.getByLabel('Transportation Office').nth(0).fill('JPPSO Testy McTest'); + // 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('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('roles authorized for supervisor can select', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); + const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // 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(); + + // 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('JPPSO Testy McTest'); + // 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('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('roles unauthorized for supervisor cannot be selected after supervisor is selected', 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 servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); + const contractingOfficerCheckbox = page.getByLabel('Contracting Officer', { 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 }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Check selecting roles after having supervisor selected for unallowed roles + await supervisorCheckbox.click(); + await expect(supervisorCheckbox).toBeChecked(); + 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(); + + // Continue test to ensure form still submits with valid information + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + // The autocomplete form results in multiple matching elements, so + // pick the input element + await page.getByLabel('Transportation Office').nth(0).fill('JPPSO Testy McTest'); + // 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('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('roles authorized for supervisor can be selected after supervisor is selected', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); + const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Check selecting roles after having supervisor selected for allowed roles + await supervisorCheckbox.click(); + await expect(supervisorCheckbox).toBeChecked(); + await taskOrderingOfficerCheckbox.click(); + await expect(taskOrderingOfficerCheckbox).toBeChecked(); + await taskInvoicingOfficerCheckbox.click(); + await expect(taskInvoicingOfficerCheckbox).toBeChecked(); + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + // Continue test to ensure form still submits with valid information + await taskOrderingOfficerCheckbox.click(); + await expect(taskOrderingOfficerCheckbox).not.toBeChecked(); + await taskInvoicingOfficerCheckbox.click(); + await expect(taskInvoicingOfficerCheckbox).not.toBeChecked(); + + // The autocomplete form results in multiple matching elements, so + // pick the input element + await page.getByLabel('Transportation Office').nth(0).fill('JPPSO Testy McTest'); + // 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('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'); From 5090f9560696d89b63708e650a39753ad789a35f Mon Sep 17 00:00:00 2001 From: antgmann Date: Thu, 19 Dec 2024 21:41:31 +0000 Subject: [PATCH 05/16] Separate tests so playwright doesnt step on its own toes --- playwright/tests/admin/officeUsers.spec.js | 446 ++++++++++++++++++++- 1 file changed, 429 insertions(+), 17 deletions(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 8a98e12152e..7f4d9be8a8b 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -269,7 +269,7 @@ test.describe('Office User Create Page', () => { await expect(page.locator('#telephone')).toHaveValue('222-555-1234'); await expect(page.locator('#active')).toHaveText('Yes'); }); - test('roles unauthorized for supervisor cannot select', async ({ page, adminPage }) => { + test('roles unauthorized for supervisor cannot select 1', 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: @@ -307,12 +307,6 @@ test.describe('Office User Create Page', () => { 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 }); // Define constants for privileges const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); @@ -333,6 +327,79 @@ test.describe('Office User Create Page', () => { await expect(primeSimulatorCheckbox).toBeChecked(); await expect(supervisorCheckbox).not.toBeChecked(); await primeSimulatorCheckbox.click(); + + // Continue test to ensure form still submits with valid information + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + // The autocomplete form results in multiple matching elements, so + // pick the input element + await page.getByLabel('Transportation Office').nth(0).fill('JPPSO Testy McTest'); + // 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('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('roles unauthorized for supervisor cannot select 2', 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 servicesCounselorCheckbox = page.getByLabel('Services Counselor', { 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 }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Check roles that cannot have supervisor priveleges await qualityAssuranceEvaluatorCheckbox.click(); await supervisorCheckbox.click(); await expect(qualityAssuranceEvaluatorCheckbox).toBeChecked(); @@ -753,7 +820,7 @@ test.describe('Office Users Edit Page', () => { await expect(page.locator(`tr:has(:text("${email}")) >> td.column-lastName`)).toHaveText('NewLast'); }); - test('has correct supervisor privileges on edit page', async ({ page, adminPage }) => { + test('roles unauthorized for supervisor cannot select 1', async ({ page, adminPage }) => { const officeUser = await adminPage.testHarness.buildOfficeUserWithTOOAndTIO(); const email = officeUser.okta_email; @@ -815,12 +882,6 @@ test.describe('Office Users Edit Page', () => { 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 }); // Define constants for privileges const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); @@ -845,6 +906,96 @@ test.describe('Office Users Edit Page', () => { await expect(primeSimulatorCheckbox).toBeChecked(); await expect(supervisorCheckbox).not.toBeChecked(); await primeSimulatorCheckbox.click(); + + // Continue test to ensure form still submits with valid information + await servicesCounselorCheckbox.click(); + + 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('roles unauthorized for supervisor cannot select 2', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); + const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { 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 }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Deselect existing roles for testing + await taskOrderingOfficerCheckbox.click(); + await taskInvoicingOfficerCheckbox.click(); + + // Check roles that cannot have supervisor priveleges await qualityAssuranceEvaluatorCheckbox.click(); await supervisorCheckbox.click(); await expect(qualityAssuranceEvaluatorCheckbox).toBeChecked(); @@ -866,6 +1017,88 @@ test.describe('Office Users Edit Page', () => { await expect(supervisorCheckbox).not.toBeChecked(); await headquartersCheckbox.click(); + // Continue test to ensure form still submits with valid information + await servicesCounselorCheckbox.click(); + + 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('roles authorized for supervisor can select', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); + const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Deselect existing roles for testing + await taskOrderingOfficerCheckbox.click(); + await taskInvoicingOfficerCheckbox.click(); + // Check roles that can have supervisor priveleges await taskOrderingOfficerCheckbox.click(); await supervisorCheckbox.click(); @@ -883,9 +1116,103 @@ test.describe('Office Users Edit Page', () => { await supervisorCheckbox.click(); await expect(servicesCounselorCheckbox).toBeChecked(); await expect(supervisorCheckbox).toBeChecked(); - await servicesCounselorCheckbox.click(); + + // 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('roles unauthorized for supervisor cannot be selected after supervisor is selected', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { 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 }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Deselect existing roles for testing + await taskOrderingOfficerCheckbox.click(); + await taskInvoicingOfficerCheckbox.click(); // Check selecting roles after having supervisor selected for unallowed roles + await supervisorCheckbox.click(); + await expect(supervisorCheckbox).toBeChecked(); await customerCheckbox.click(); await expect(customerCheckbox).not.toBeChecked(); await contractingOfficerCheckbox.click(); @@ -901,7 +1228,92 @@ test.describe('Office Users Edit Page', () => { await headquartersCheckbox.click(); await expect(headquartersCheckbox).not.toBeChecked(); + // Continue test to ensure form still submits with valid information + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + 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('roles authorized for supervisor can be selected after supervisor is selected', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); + const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); + const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); + + // Define constants for privileges + const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); + + // Deselect existing roles for testing + await taskOrderingOfficerCheckbox.click(); + await taskInvoicingOfficerCheckbox.click(); + // Check selecting roles after having supervisor selected for allowed roles + await supervisorCheckbox.click(); await expect(supervisorCheckbox).toBeChecked(); await taskOrderingOfficerCheckbox.click(); await expect(taskOrderingOfficerCheckbox).toBeChecked(); @@ -911,8 +1323,8 @@ test.describe('Office Users Edit Page', () => { await expect(servicesCounselorCheckbox).toBeChecked(); // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).not.toBeChecked(); + await taskOrderingOfficerCheckbox.click(); + await expect(taskOrderingOfficerCheckbox).not.toBeChecked(); await taskInvoicingOfficerCheckbox.click(); await expect(taskInvoicingOfficerCheckbox).not.toBeChecked(); From 38dd6809b77a9489987e0a6ac18f58a00febebe5 Mon Sep 17 00:00:00 2001 From: antgmann Date: Thu, 19 Dec 2024 22:02:09 +0000 Subject: [PATCH 06/16] Remove old test --- playwright/tests/admin/officeUsers.spec.js | 158 --------------------- 1 file changed, 158 deletions(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 7f4d9be8a8b..e7f8f492f6c 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -111,164 +111,6 @@ test.describe('Office User Create Page', () => { await expect(page.locator('#active')).toHaveText('Yes'); }); - test('has correct supervisor privileges on create page', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { 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 }); - - // 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 expect(supervisorCheckbox).toBeChecked(); - await taskOrderingOfficerCheckbox.click(); - await expect(taskOrderingOfficerCheckbox).toBeChecked(); - await taskInvoicingOfficerCheckbox.click(); - await expect(taskInvoicingOfficerCheckbox).toBeChecked(); - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - - // Continue test to ensure form still submits with valid information - await taskOrderingOfficerCheckbox.click(); - await expect(taskOrderingOfficerCheckbox).not.toBeChecked(); - await taskInvoicingOfficerCheckbox.click(); - await expect(taskInvoicingOfficerCheckbox).not.toBeChecked(); - - // The autocomplete form results in multiple matching elements, so - // pick the input element - await page.getByLabel('Transportation Office').nth(0).fill('JPPSO Testy McTest'); - // 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('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('roles unauthorized for supervisor cannot select 1', async ({ page, adminPage }) => { await adminPage.signInAsNewAdminUser(); // we tested the side nav in the previous test, From b42b33c4cfee5103013b542eda2772d19944584c Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 20 Dec 2024 15:46:33 +0000 Subject: [PATCH 07/16] turn on hq ff for circleci --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b8d3c39da69..16b5e44a8d2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -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 @@ -935,7 +935,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' From c92b89199dd4c6a93fa842ac9aa29b4a4eaa5dc3 Mon Sep 17 00:00:00 2001 From: Ricky Mettler Date: Fri, 20 Dec 2024 18:07:16 +0000 Subject: [PATCH 08/16] change playwright tests to use actual transpo office --- playwright/tests/admin/officeUsers.spec.js | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index e7f8f492f6c..6a278020128 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -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(); @@ -176,10 +176,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(); @@ -269,10 +269,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(); @@ -351,10 +351,10 @@ test.describe('Office User Create Page', () => { // 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('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(); @@ -446,10 +446,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(); @@ -525,10 +525,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(); From 255a41d747ccb0cfa4bbaac8e63767338ebc811a Mon Sep 17 00:00:00 2001 From: antgmann Date: Mon, 23 Dec 2024 14:28:42 +0000 Subject: [PATCH 09/16] Attempt to re-consolidate tests, playwright not working locally --- playwright/tests/admin/officeUsers.spec.js | 906 ++++----------------- 1 file changed, 140 insertions(+), 766 deletions(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 6a278020128..78886ed7ef8 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -111,7 +111,7 @@ test.describe('Office User Create Page', () => { await expect(page.locator('#active')).toHaveText('Yes'); }); - test('roles unauthorized for supervisor cannot select 1', async ({ page, adminPage }) => { + 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: @@ -149,6 +149,14 @@ test.describe('Office User Create Page', () => { 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 }); @@ -169,79 +177,6 @@ test.describe('Office User Create Page', () => { await expect(primeSimulatorCheckbox).toBeChecked(); await expect(supervisorCheckbox).not.toBeChecked(); await primeSimulatorCheckbox.click(); - - // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - - // 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('roles unauthorized for supervisor cannot select 2', 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 servicesCounselorCheckbox = page.getByLabel('Services Counselor', { 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 }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - - // Check roles that cannot have supervisor priveleges await qualityAssuranceEvaluatorCheckbox.click(); await supervisorCheckbox.click(); await expect(qualityAssuranceEvaluatorCheckbox).toBeChecked(); @@ -263,73 +198,6 @@ test.describe('Office User Create Page', () => { await expect(supervisorCheckbox).not.toBeChecked(); await headquartersCheckbox.click(); - // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - - // 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('roles authorized for supervisor can select', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); - const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - // Check roles that can have supervisor priveleges await taskOrderingOfficerCheckbox.click(); await supervisorCheckbox.click(); @@ -347,81 +215,6 @@ test.describe('Office User Create Page', () => { await supervisorCheckbox.click(); await expect(servicesCounselorCheckbox).toBeChecked(); await expect(supervisorCheckbox).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('roles unauthorized for supervisor cannot be selected after supervisor is selected', 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 servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); - const contractingOfficerCheckbox = page.getByLabel('Contracting Officer', { 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 }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - // Check selecting roles after having supervisor selected for unallowed roles await supervisorCheckbox.click(); await expect(supervisorCheckbox).toBeChecked(); @@ -440,441 +233,85 @@ test.describe('Office User Create Page', () => { await headquartersCheckbox.click(); await expect(headquartersCheckbox).not.toBeChecked(); - // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - - // 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('roles authorized for supervisor can be selected after supervisor is selected', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); - const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - // Check selecting roles after having supervisor selected for allowed roles await supervisorCheckbox.click(); - await expect(supervisorCheckbox).toBeChecked(); - await taskOrderingOfficerCheckbox.click(); - await expect(taskOrderingOfficerCheckbox).toBeChecked(); - await taskInvoicingOfficerCheckbox.click(); - await expect(taskInvoicingOfficerCheckbox).toBeChecked(); - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - - // Continue test to ensure form still submits with valid information - await taskOrderingOfficerCheckbox.click(); - await expect(taskOrderingOfficerCheckbox).not.toBeChecked(); - await taskInvoicingOfficerCheckbox.click(); - await expect(taskInvoicingOfficerCheckbox).not.toBeChecked(); - - // 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', () => { - test('pulls up details page for an office user', async ({ page, adminPage }) => { - await adminPage.testHarness.buildOfficeUserWithTOOAndTIO(); - await adminPage.signInAsNewAdminUser(); - - expect(page.url()).toContain('/system/requested-office-users'); - await adminPage.waitForPage.adminPage(); - await page.getByRole('menuitem', { name: 'Office Users', exact: true }).click(); - expect(page.url()).toContain('/system/office-users'); - - // Click first office user row - await page.locator('tbody >> tr').first().click(); - - // Get first id field and check that it's in the URL - const id = await page.locator('.ra-field-id > span').first().textContent(); - expect(page.url()).toContain(id); - - // check that the office user's name is shown in the page title - const firstName = await page.locator('.ra-field-firstName > span').textContent(); - const lastName = await page.locator('.ra-field-lastName > span').textContent(); - - await expect(page.getByRole('heading', { name: `${firstName} ${lastName}` })).toBeVisible(); - - const labels = [ - 'Id', - 'User Id', - 'Email', - 'First name', - 'Middle initials', - 'Last name', - 'Telephone', - 'Active', - 'Transportation Offices', - 'Created at', - 'Updated at', - ]; - await adminPage.expectLabels(labels); - }); -}); - -test.describe('Office Users Edit Page', () => { - test('pulls up edit page for an office user', 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(); - - const tooCheckbox = page.getByLabel('Task Ordering Officer'); - const tioCheckbox = page.getByLabel('Task Invoicing Officer'); - - if (tioCheckbox.isChecked() && tooCheckbox.isChecked()) { - await tooCheckbox.click(); - } - - 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('roles unauthorized for supervisor cannot select 1', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { 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 }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - - // Deselect 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(); - - // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - - 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('roles unauthorized for supervisor cannot select 2', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); - const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { 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 }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - - // Deselect existing roles for testing - await taskOrderingOfficerCheckbox.click(); - await taskInvoicingOfficerCheckbox.click(); - - // Check roles that cannot have supervisor priveleges - 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(); + await expect(supervisorCheckbox).toBeChecked(); + await taskOrderingOfficerCheckbox.click(); + await expect(taskOrderingOfficerCheckbox).toBeChecked(); + await taskInvoicingOfficerCheckbox.click(); + await expect(taskInvoicingOfficerCheckbox).toBeChecked(); + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); // Continue test to ensure form still submits with valid information await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); + + // 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(); - await searchForOfficeUser(page, email); - await expect(page.locator(`tr:has(:text("${email}")) >> td.column-active >> svg`)).toHaveAttribute( - 'data-testid', - newStatus, - ); + // redirected to edit details page + const officeUserID = await page.locator('#id').inputValue(); - 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'); + 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', () => { + test('pulls up details page for an office user', async ({ page, adminPage }) => { + await adminPage.testHarness.buildOfficeUserWithTOOAndTIO(); + await adminPage.signInAsNewAdminUser(); + + expect(page.url()).toContain('/system/requested-office-users'); + await adminPage.waitForPage.adminPage(); + await page.getByRole('menuitem', { name: 'Office Users', exact: true }).click(); + expect(page.url()).toContain('/system/office-users'); + + // Click first office user row + await page.locator('tbody >> tr').first().click(); + + // Get first id field and check that it's in the URL + const id = await page.locator('.ra-field-id > span').first().textContent(); + expect(page.url()).toContain(id); + + // check that the office user's name is shown in the page title + const firstName = await page.locator('.ra-field-firstName > span').textContent(); + const lastName = await page.locator('.ra-field-lastName > span').textContent(); + + await expect(page.getByRole('heading', { name: `${firstName} ${lastName}` })).toBeVisible(); + + const labels = [ + 'Id', + 'User Id', + 'Email', + 'First name', + 'Middle initials', + 'Last name', + 'Telephone', + 'Active', + 'Transportation Offices', + 'Created at', + 'Updated at', + ]; + await adminPage.expectLabels(labels); }); - test('roles authorized for supervisor can select', async ({ page, adminPage }) => { +}); + +test.describe('Office Users Edit Page', () => { + test('pulls up edit page for an office user', async ({ page, adminPage }) => { const officeUser = await adminPage.testHarness.buildOfficeUserWithTOOAndTIO(); const email = officeUser.okta_email; @@ -929,37 +366,12 @@ test.describe('Office Users Edit Page', () => { 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); - const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - - // Deselect existing roles for testing - await taskOrderingOfficerCheckbox.click(); - await taskInvoicingOfficerCheckbox.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(); + const tooCheckbox = page.getByLabel('Task Ordering Officer'); + const tioCheckbox = page.getByLabel('Task Invoicing Officer'); - // Continue test to ensure form still submits with valid information + if (tioCheckbox.isChecked() && tooCheckbox.isChecked()) { + await tooCheckbox.click(); + } await page.getByRole('button', { name: 'Save' }).click(); await adminPage.waitForPage.adminPage(); @@ -973,10 +385,8 @@ test.describe('Office Users Edit Page', () => { 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('roles unauthorized for supervisor cannot be selected after supervisor is selected', async ({ - page, - adminPage, - }) => { + + test('has correct supervisor role permissions', async ({ page, adminPage }) => { const officeUser = await adminPage.testHarness.buildOfficeUserWithTOOAndTIO(); const email = officeUser.okta_email; @@ -1033,8 +443,6 @@ test.describe('Office Users Edit Page', () => { // Define constants for all roles checkboxes to be tested const customerCheckbox = page.getByLabel('Customer', { exact: true }); - const taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { 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 }); @@ -1044,14 +452,66 @@ test.describe('Office Users Edit Page', () => { 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 }); - // Deselect existing roles for testing + // 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(); // Check selecting roles after having supervisor selected for unallowed roles await supervisorCheckbox.click(); await expect(supervisorCheckbox).toBeChecked(); @@ -1070,90 +530,6 @@ test.describe('Office Users Edit Page', () => { await headquartersCheckbox.click(); await expect(headquartersCheckbox).not.toBeChecked(); - // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - - 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('roles authorized for supervisor can be selected after supervisor is selected', 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 taskOrderingOfficerCheckbox = page.getByLabel('Task Ordering Officer', { exact: true }); - const taskInvoicingOfficerCheckbox = page.getByLabel('Task Invoicing Officer', { exact: true }); - const servicesCounselorCheckbox = page.getByLabel('Services Counselor', { exact: true }); - - // Define constants for privileges - const supervisorCheckbox = page.getByLabel('Supervisor', { exact: true }); - - // Deselect existing roles for testing - await taskOrderingOfficerCheckbox.click(); - await taskInvoicingOfficerCheckbox.click(); - // Check selecting roles after having supervisor selected for allowed roles await supervisorCheckbox.click(); await expect(supervisorCheckbox).toBeChecked(); @@ -1165,10 +541,8 @@ test.describe('Office Users Edit Page', () => { await expect(servicesCounselorCheckbox).toBeChecked(); // Continue test to ensure form still submits with valid information - await taskOrderingOfficerCheckbox.click(); - await expect(taskOrderingOfficerCheckbox).not.toBeChecked(); - await taskInvoicingOfficerCheckbox.click(); - await expect(taskInvoicingOfficerCheckbox).not.toBeChecked(); + await servicesCounselorCheckbox.click(); + await expect(servicesCounselorCheckbox).toBeChecked(); await page.getByRole('button', { name: 'Save' }).click(); await adminPage.waitForPage.adminPage(); From ddfa2a34f014689a77188f12e142e90c546403d4 Mon Sep 17 00:00:00 2001 From: antgmann Date: Mon, 23 Dec 2024 15:09:57 +0000 Subject: [PATCH 10/16] Fix test --- playwright/tests/admin/officeUsers.spec.js | 8 -------- 1 file changed, 8 deletions(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 78886ed7ef8..095d604e28f 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -216,8 +216,6 @@ test.describe('Office User Create Page', () => { await expect(servicesCounselorCheckbox).toBeChecked(); await expect(supervisorCheckbox).toBeChecked(); // Check selecting roles after having supervisor selected for unallowed roles - await supervisorCheckbox.click(); - await expect(supervisorCheckbox).toBeChecked(); await customerCheckbox.click(); await expect(customerCheckbox).not.toBeChecked(); await contractingOfficerCheckbox.click(); @@ -234,8 +232,6 @@ test.describe('Office User Create Page', () => { await expect(headquartersCheckbox).not.toBeChecked(); // Check selecting roles after having supervisor selected for allowed roles - await supervisorCheckbox.click(); - await expect(supervisorCheckbox).toBeChecked(); await taskOrderingOfficerCheckbox.click(); await expect(taskOrderingOfficerCheckbox).toBeChecked(); await taskInvoicingOfficerCheckbox.click(); @@ -513,8 +509,6 @@ test.describe('Office Users Edit Page', () => { await expect(servicesCounselorCheckbox).toBeChecked(); await expect(supervisorCheckbox).toBeChecked(); // Check selecting roles after having supervisor selected for unallowed roles - await supervisorCheckbox.click(); - await expect(supervisorCheckbox).toBeChecked(); await customerCheckbox.click(); await expect(customerCheckbox).not.toBeChecked(); await contractingOfficerCheckbox.click(); @@ -531,8 +525,6 @@ test.describe('Office Users Edit Page', () => { await expect(headquartersCheckbox).not.toBeChecked(); // Check selecting roles after having supervisor selected for allowed roles - await supervisorCheckbox.click(); - await expect(supervisorCheckbox).toBeChecked(); await taskOrderingOfficerCheckbox.click(); await expect(taskOrderingOfficerCheckbox).toBeChecked(); await taskInvoicingOfficerCheckbox.click(); From b9be286be9fbef194ebc036decae176815279173 Mon Sep 17 00:00:00 2001 From: antgmann Date: Mon, 23 Dec 2024 15:36:06 +0000 Subject: [PATCH 11/16] Local playwright issues --- playwright/tests/admin/officeUsers.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 095d604e28f..e59de0b3093 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -215,6 +215,8 @@ test.describe('Office User Create Page', () => { 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(); @@ -508,6 +510,8 @@ test.describe('Office Users Edit Page', () => { 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(); From 8b622bc448106695bb7498f24d96977355199a0d Mon Sep 17 00:00:00 2001 From: antgmann Date: Mon, 23 Dec 2024 15:56:31 +0000 Subject: [PATCH 12/16] Hopefully final fix --- playwright/tests/admin/officeUsers.spec.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index e59de0b3093..5de4ac3ba44 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -242,9 +242,6 @@ test.describe('Office User Create Page', () => { await expect(servicesCounselorCheckbox).toBeChecked(); // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - // 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'); @@ -537,9 +534,6 @@ test.describe('Office Users Edit Page', () => { await expect(servicesCounselorCheckbox).toBeChecked(); // Continue test to ensure form still submits with valid information - await servicesCounselorCheckbox.click(); - await expect(servicesCounselorCheckbox).toBeChecked(); - await page.getByRole('button', { name: 'Save' }).click(); await adminPage.waitForPage.adminPage(); From 33b4a7ee410473c7a283969a051a5320d47f88ef Mon Sep 17 00:00:00 2001 From: antgmann Date: Mon, 23 Dec 2024 16:37:23 +0000 Subject: [PATCH 13/16] Roles changes --- playwright/tests/admin/officeUsers.spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/playwright/tests/admin/officeUsers.spec.js b/playwright/tests/admin/officeUsers.spec.js index 5de4ac3ba44..64fb83f27dd 100644 --- a/playwright/tests/admin/officeUsers.spec.js +++ b/playwright/tests/admin/officeUsers.spec.js @@ -236,8 +236,10 @@ test.describe('Office User Create Page', () => { // 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(); @@ -453,6 +455,10 @@ test.describe('Office Users Edit Page', () => { // 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(); @@ -528,8 +534,10 @@ test.describe('Office Users Edit Page', () => { // 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(); From 1817b65be2238b69c9f493fbb24717a2fb3573e4 Mon Sep 17 00:00:00 2001 From: antgmann Date: Tue, 7 Jan 2025 20:24:52 +0000 Subject: [PATCH 14/16] Remove duplicate message --- src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx b/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx index c6e0f7622fe..d2fdac32c02 100644 --- a/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx +++ b/src/scenes/SystemAdmin/shared/RolesPrivilegesCheckboxes.jsx @@ -212,10 +212,6 @@ const RolesPrivilegesCheckboxInput = (props) => { The Safety Moves privilege can only be selected for the following roles: Task Ordering Officer, Task Invoicing Officer, Services Counselor, Quality Assurance Evaluator, Customer Service Representative, and Headquarters. - - The Safety Moves privilege can only be selected for the following roles: Task Ordering Officer, Task Invoicing - Officer, Services Counselor, Quality Assurance Evaluator, Customer Service Representative, and Headquarters. - ); }; From 01d0b778f59dbcede0914a22d9d5631199dfe804 Mon Sep 17 00:00:00 2001 From: antgmann Date: Tue, 14 Jan 2025 20:43:09 +0000 Subject: [PATCH 15/16] Add tests for coverage --- .../ImportOfficeUserButton/validation.test.js | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/components/Admin/ImportOfficeUserButton/validation.test.js b/src/components/Admin/ImportOfficeUserButton/validation.test.js index 379cb8a7be6..6f9648927d3 100644 --- a/src/components/Admin/ImportOfficeUserButton/validation.test.js +++ b/src/components/Admin/ImportOfficeUserButton/validation.test.js @@ -1,6 +1,7 @@ -import { checkRequiredFields, checkTelephone, parseRoles } from './validation'; +import { checkRequiredFields, checkTelephone, parseRoles, parsePrivileges } from './validation'; import { adminOfficeRoles, roleTypes } from 'constants/userRoles'; +import { elevatedPrivilegeTypes } from 'constants/userPrivileges'; describe('checkRequiredFields', () => { it('success: does nothing if all fields provided', () => { @@ -71,3 +72,36 @@ describe('parseRoles', () => { expect(parseInvalidRoles).toThrowError('Invalid roles provided for row.'); }); }); + +describe('parsePrivileges', () => { + const supervisorPrivilege = { privilegeType: 'supervisor', name: 'Supervisor' }; + const safetyPrivilege = { privilegeType: 'safety', name: 'Safety Moves' }; + + it('fail: throws an error if there are no privileges', () => { + function parseEmptyPrivileges() { + parsePrivileges(''); + } + expect(parseEmptyPrivileges).toThrowError('Processing Error: Unable to parse privileges for row.'); + }); + + it('success: parses one privilege into an array of len 1', () => { + const privileges = elevatedPrivilegeTypes.SUPERVISOR; + const privilegesArray = parsePrivileges(privileges); + expect(privilegesArray).toHaveLength(1); + expect(privilegesArray).toContainEqual(supervisorPrivilege); + }); + + it('success: parses multiple privileges into an array', () => { + const privileges = `${elevatedPrivilegeTypes.SUPERVISOR}, ${elevatedPrivilegeTypes.SAFETY}`; + const privilegesArray = parsePrivileges(privileges); + expect(privilegesArray).toHaveLength(2); + expect(privilegesArray).toEqual(expect.arrayContaining([supervisorPrivilege, safetyPrivilege])); + }); + + it('fail: throws an error if there is an invalid role', () => { + function parseInvalidPrivileges() { + parsePrivileges('test_privilege'); + } + expect(parseInvalidPrivileges).toThrowError('Invalid privileges provided for row.'); + }); +}); From a3dbb6107b7de3d2b240114650f4daddd4be6948 Mon Sep 17 00:00:00 2001 From: antgmann Date: Tue, 14 Jan 2025 21:03:29 +0000 Subject: [PATCH 16/16] Fix typo --- src/components/Admin/ImportOfficeUserButton/validation.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Admin/ImportOfficeUserButton/validation.test.js b/src/components/Admin/ImportOfficeUserButton/validation.test.js index 6f9648927d3..7639ea9876f 100644 --- a/src/components/Admin/ImportOfficeUserButton/validation.test.js +++ b/src/components/Admin/ImportOfficeUserButton/validation.test.js @@ -98,7 +98,7 @@ describe('parsePrivileges', () => { expect(privilegesArray).toEqual(expect.arrayContaining([supervisorPrivilege, safetyPrivilege])); }); - it('fail: throws an error if there is an invalid role', () => { + it('fail: throws an error if there is an invalid privilege', () => { function parseInvalidPrivileges() { parsePrivileges('test_privilege'); }