Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Add tests for changes in 4665 #51

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 59 additions & 1 deletion end2end/tests/lifecycleNewRequest.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,57 @@ test('Cancel Requests', async () => {
await expect(page.getByText('New Request', { exact: true })).toBeVisible();
await expect(page.getByRole('link', { name: uniqueText + ' to Edit, Copy, and Cancel' })).toHaveCount(0);
});

/**
* Test for 4665
* Verify that a negative amount is allowed for currency
* in a new request
*/
test('Negative Currency Allowed in New Request', async () => {

await page.goto('https://host.docker.internal/Test_Request_Portal/?a=newform');
await page.getByRole('cell', { name: 'Select an Option Service' }).locator('a').click();
await page.getByRole('option', { name: 'Concrete Music' }).click();
await page.getByLabel('Title of Request').click();
await page.getByLabel('Title of Request').fill(uniqueText + ' to Test Negative Currency');

// Choose the Input Formats form
await page.locator('label').filter({ hasText: 'Input Formats (For testing' }).locator('span').click();
await page.getByRole('button', { name: 'Click here to Proceed' }).click();
await page.getByLabel('currency').click();

// Fill in a negative number for the currency
await page.getByLabel('currency').fill('-300');

// After saving, verify the negative number is still visible
await page.locator('#save_indicator').click();
await expect(page.getByLabel('currency')).toHaveValue('-300.00');

// Verify negative number is still visible after the request is created
await page.getByRole('button', { name: 'Show single page' }).click();
await expect(page.locator('#data_37_1')).toContainText('-$300.00');
});

/**
* Test for 4665
* Verify that a negative amount is allowed for currency
* when editing a request
*/
test("Negative Currency Allowed When Editing a Request", async () => {

await page.goto('https://host.docker.internal/Test_Request_Portal/');
await page.getByRole('link', { name: uniqueText + ' to Test Negative Currency' }).click();
await page.getByRole('button', { name: 'Edit Basic input types field' }).click();
await page.getByLabel('currency').click();
await page.getByLabel('currency').click();

// Change the currency amount to -50
await page.getByLabel('currency').fill('-50');

// Save the changes and verify the amount has changed to -50
await page.getByRole('button', { name: 'Save Change' }).click();
await expect(page.locator('#data_37_1')).toContainText('-$50.00');
})

/**
* Set of tests which do the following:
Expand Down Expand Up @@ -273,7 +324,7 @@ test.describe('Archive and Restore Question',() => {
// Verify the Reviewer 1 field is visible but the Reviewer 2 field is not in the created request
await page.getByRole('link', { name: uniqueText + ' to Create' }).click();
await expect(page.getByText('Reviewer 1', { exact: true })).toBeVisible();
await expect(page.getByText('Reviewer 2', { exact: true })).not.toBeVisible();
await expect(page.getByText('Reviewer 2', { exact: true })).not.toBeVisible();
});

/**
Expand Down Expand Up @@ -348,6 +399,13 @@ test.afterAll(async () => {
await page.getByPlaceholder('Enter Comment').click();
await page.getByPlaceholder('Enter Comment').fill('No longer needed');
await page.getByRole('button', { name: 'Yes' }).click();
await expect(page.locator('#bodyarea')).toContainText('has been cancelled!');

// Cancel the form used for testing negative currency
await page.goto('https://host.docker.internal/Test_Request_Portal/');
await page.getByRole('link', { name: uniqueText + ' to Test Negative Currency' }).click();
await page.getByRole('button', { name: 'Cancel Request' }).click();
await page.getByRole('button', { name: 'Yes' }).click();

// Close the page
await page.close();
Expand Down
39 changes: 39 additions & 0 deletions end2end/tests/reportBuilder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,3 +342,42 @@ test('Report builder workflow and create row button functionality', async ({ pag
await newRowTitle.waitFor({ state: 'visible' });
await expect(newRowTitle).toContainText('untitled');
});

/**
* Test for 4665
* Verify that a negative currency is
* allowed to be added to a report
*/
test('Report Allows Negative Currency', async ({ page}) => {

// Create a new report
await page.goto("https://host.docker.internal/Test_Request_Portal/")
await page.getByText('Report Builder Create custom').click();
await page.getByRole('cell', { name: 'Current Status' }).locator('a').click();
await page.getByRole('option', { name: 'Type' }).click();

// Choose reports which use the Input Formats form
await page.getByRole('cell', { name: 'Complex Form' }).locator('a').click();
await page.getByRole('option', { name: 'Input Formats' }).click();
await page.getByRole('button', { name: 'Next Step' }).click();
await page.locator('#indicatorList').getByText('Input Formats').click();

// Choose currency as one of the columns
await page.getByText('currency', { exact: true }).click();
await page.getByRole('button', { name: 'Generate Report' }).click();
await page.locator('[data-record-id="962"]').click();

// Input a negative currency
await page.getByRole('textbox', { name: 'currency' }).click();
await page.getByRole('textbox', { name: 'currency' }).fill('-200');
await page.getByRole('button', { name: 'Save Change' }).click();

// Verify the negative currency is displayed
await expect(page.locator('[data-record-id="962"]')).toContainText('-200.00');

// Clear out the currency value as to not affect other tests
await page.locator('[data-record-id="962"]').click();
await page.getByRole('textbox', { name: 'currency' }).click();
await page.getByRole('textbox', { name: 'currency' }).fill('');
await page.getByRole('button', { name: 'Save Change' }).click();
})
Loading