Merge pull request #2266 from GSA/2168-when-a-user-schedules-a-job-they-should-see-scheduled-instead-of-sent-on-the-service-activity-page

Updating/Fix job status states
This commit is contained in:
Beverly Nguyen
2025-01-23 11:21:04 -08:00
committed by GitHub
6 changed files with 205 additions and 164 deletions

View File

@@ -657,9 +657,8 @@ def test_should_show_recent_templates_on_dashboard(
]
assert "Total messages" in headers
table_rows = page.find_all("tbody")[0].find_all("tr")
assert len(table_rows) == 0
table_rows = page.find_all("tbody")[1].find_all("tr")
assert len(table_rows) == 2
@pytest.mark.parametrize(
@@ -1943,7 +1942,6 @@ def test_service_dashboard_shows_batched_jobs(
job_table_body = page.find("table", class_="job-table")
rows = job_table_body.find_all("tbody")[0].find_all("tr")
assert len(rows) == 0
assert len(rows) == 1
assert job_table_body is not None

View File

@@ -21,7 +21,7 @@ Object.defineProperty(HTMLElement.prototype, 'clientWidth', {
beforeAll(done => {
// Set up the DOM with the D3 script included
document.body.innerHTML = `
<div id="activityChartContainer"">
<div id="activityChartContainer">
<form class="usa-form">
<label class="usa-label" for="options">Account</label>
<select class="usa-select margin-bottom-2" name="options" id="options">
@@ -40,6 +40,9 @@ beforeAll(done => {
</div>
</div>
<div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div>
<div id="activityContainer" data-currentUserName="Test User"></div>
<div id="aria-live-account" class="usa-sr-only" aria-live="polite"></div>
`;
// Load the D3 script dynamically
@@ -178,3 +181,59 @@ const data = await fetchData('service');
expect(global.fetch).toHaveBeenCalledWith('/daily_stats.json');
expect(data).toEqual(mockResponse);
});
test('handleDropdownChange updates DOM for individual selection', () => {
document.body.innerHTML = `
<div id="activityChartContainer">
<div class="chart-subtitle"></div>
</div>
<div id="aria-live-account"></div>
<div id="activityContainer" data-currentUserName="Test User"></div>
<div id="tableActivity">
<h2 id="table-heading"></h2>
<table id="activity-table">
<caption id="caption"></caption>
<tbody>
<tr><td class="sender-column">Test User</td></tr>
<tr><td class="sender-column">Other User</td></tr>
<tr><td class="sender-column">Test User</td></tr>
<tr><td class="sender-column">Test User</td></tr>
<tr><td class="sender-column">Other User</td></tr>
<tr><td class="sender-column">Test User</td></tr>
<tr><td class="sender-column">Test User</td></tr>
</tbody>
</table>
</div>
<select id="options">
<option value="service">Service</option>
<option value="individual">Individual</option>
</select>
`;
window.currentUserName = "Test User";
jest.spyOn(window, 'fetchData').mockImplementation(() => {});
const selectElement = document.getElementById('options');
selectElement.value = 'individual';
const event = { target: selectElement };
window.handleDropdownChange(event);
expect(document.getElementById('table-heading').textContent).toBe('My activity');
expect(document.getElementById('caption').textContent).toContain('Test User');
document.querySelectorAll('.sender-column').forEach(col => {
expect(col.style.display).toBe('none');
});
const rows = Array.from(document.querySelectorAll('#activity-table tbody tr'));
const visibleRows = rows.filter(row => row.style.display !== 'none');
expect(visibleRows.length).toBeLessThanOrEqual(5);
visibleRows.forEach(row => {
const sender = row.querySelector('.sender-column').textContent.trim();
expect(sender).toBe('Test User');
});
window.fetchData.mockRestore();
});