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

a11y(arpa): fix headings and color contrast issues #3811

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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<a
download
:href="href"
class="btn btn-primary"
class="btn usdr-btn-primary"
:class="computedClasses"
@click="setLoadingState"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<template>
<a
:href="href"
class="btn-primary ml-2"
href=""
:download="href"
class="usdr-btn-primary ml-2"
:class="small ? 'btn-sm' : 'btn'"
>
Download file
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ export default {
},
navLinkClass(to) {
if (this.$route.path === to) {
return 'nav-link usdr-tab-nav-link active';
return 'nav-link usdr-link active';
}
return 'nav-link usdr-tab-nav-link';
return 'nav-link usdr-link';
},
dateFormat(d) {
return moment(d)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<div class="col-sm-2" />
<div class="col-sm-10">
<button
class="btn btn-primary"
class="btn usdr-btn-primary"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: before/after screenshots

Before

image

After

image

:disabled="disabled"
@click="validateAndSave()"
>
Expand Down
14 changes: 13 additions & 1 deletion packages/client/src/arpa_reporter/scss/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ hr {
color: $positive-default;
}

.usdr-tab-nav-link {
.usdr-link {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: renamed the class to be general as it only contains color setting.

color: #305CE0;
}

Expand All @@ -100,6 +100,14 @@ hr {
color: rgba(0,0,0)
}

.btn.usdr-btn-outline-primary,
.btn.usdr-btn-outline-primary:hover {
color: $usdr-brand-primary;
background-color: #ffffff;
border-color: $usdr-brand-primary;
}

a.usdr-btn-primary,
.btn.usdr-btn-primary,
.btn.usdr-btn-primary:hover {
color: #ffff;
Expand All @@ -120,4 +128,8 @@ hr {
-ms-flex: 1 1 0%;
flex: 1 1 0%;
min-width: 0;
}

.usdr-table-danger {
background-color: #FDD3D6;
}
2 changes: 1 addition & 1 deletion packages/client/src/arpa_reporter/views/AgenciesView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="mb-4">
<router-link
to="/agencies/new"
class="btn btn-primary"
class="btn usdr-btn-primary"
Copy link
Contributor Author

@lsr-explore lsr-explore Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer:

Screenshots

Before

image

After

image

>
Create New Agency
</router-link>
Expand Down
132 changes: 127 additions & 5 deletions packages/client/src/arpa_reporter/views/LoginView.spec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,143 @@
import LoginView from '@/arpa_reporter/views/LoginView.vue';

import { describe, it, expect } from 'vitest';
import { shallowMount } from '@vue/test-utils';
import {
describe, it, afterEach, vi, expect,
} from 'vitest';
import {
fireEvent, render, screen, cleanup, waitFor,
} from '@testing-library/vue';

const mockPost = vi.fn();
global.fetch = mockPost;

describe('LoginView component', () => {
const $route = {
query: {},
};

it('renders', () => {
const wrapper = shallowMount(LoginView, {
const mockRouter = {
push: vi.fn(),
resolve: vi.fn().mockReturnValue({
href: '/arpa_reporter/',
}),
};

afterEach(() => {
cleanup();
vi.clearAllMocks();
mockPost.mockClear();
});

it('it displays expected elements and handles successful login request', async () => {
mockPost.mockResolvedValueOnce(
new Promise((resolve) => {
resolve({
ok: true,
success: true,
json: () => Promise.resolve({ message: 'Email sent to [email protected]. Check your inbox', success: true }),
});
}),
);

render(LoginView, {
global: {
mocks: {
$route,
$http: { post: mockPost },
$router: mockRouter,
},
},
});

screen.getByRole('heading', { name: /ARPA Reporter Login/i, level: 1 });
const emailInput = screen.getByPlaceholderText(/email address/i);
const submitButton = screen.getByRole('button');

await fireEvent.update(emailInput, '[email protected]');
await fireEvent.click(submitButton);

await waitFor(() => screen.getByText(/Email sent to [email protected]. Check your inbox/i));
});

it('handles login error response', async () => {
mockPost.mockResolvedValueOnce(
new Promise((resolve) => {
resolve({
ok: true,
success: true,
json: () => Promise.resolve({ message: 'User "[email protected]" not found', success: true }),
});
}),
);

render(LoginView, {
global: {
mocks: {
$route,
$http: { post: mockPost },
$router: mockRouter,
},
},
});
expect(wrapper.exists()).toBe(true);

const emailInput = screen.getByPlaceholderText(/email address/i);
const submitButton = screen.getByRole('button');

await fireEvent.update(emailInput, '[email protected]');
await fireEvent.click(submitButton);

await waitFor(() => screen.getByText(/User "[email protected]" not found/i));
});

it('validates email format before submission', async () => {
render(LoginView, {
global: {
mocks: {
$route,
$http: { post: mockPost },
$router: mockRouter,
},
},
});

const emailInput = screen.getByPlaceholderText(/email address/i);
const submitButton = screen.getByRole('button');

await fireEvent.update(emailInput, 'invalid-email');
await fireEvent.click(submitButton);

expect(mockPost).not.toHaveBeenCalled();
screen.getByText(/please enter a valid email/i);
});
it('handles login error status', async () => {
mockPost.mockResolvedValueOnce(
new Promise((resolve) => {
resolve({
ok: false,
success: true,
statusText: 'Unable to connect to the server',
status: 500,
json: () => Promise.resolve({ }),
});
}),
);

render(LoginView, {
global: {
mocks: {
$route,
$http: { post: mockPost },
$router: mockRouter,
},
},
});

const emailInput = screen.getByPlaceholderText(/email address/i);
const submitButton = screen.getByRole('button');

await fireEvent.update(emailInput, '[email protected]');
await fireEvent.click(submitButton);

await waitFor(() => screen.getByText(/login: Unable to connect to the server \(500\)/i));
});
});
4 changes: 2 additions & 2 deletions packages/client/src/arpa_reporter/views/LoginView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- eslint-disable vuejs-accessibility/no-autofocus -->
<template>
<div class="my-3">
<h2>ARPA Reporter Login</h2>
<h1>ARPA Reporter Login</h1>
<form @submit="login">
<div class="form-group">
<input
Expand All @@ -16,7 +16,7 @@
</div>
<div class="form-group">
<button
class="btn btn-primary"
class="btn usdr-btn-primary"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: screenshots

Before

  • Color Contrast
  • Missing H1 heading

image

image

After

image

type="Submit"
@click="login"
>
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/arpa_reporter/views/NewTemplateView.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<div>
<h2>Upload Period Template</h2>
<h1>Upload Period Template</h1>

<p>
This upload will be used as the template for period <em>{{ reportingPeriod.name }}</em>
Expand All @@ -24,15 +24,15 @@
</div>
<div class="form-group">
<button
class="btn btn-primary"
class="btn usdr-btn-primary"
type="submit"
:disabled="uploadDisabled"
@click.prevent="uploadTemplate"
>
{{ uploadButtonLabel }}
</button>
<a
class="ml-3"
class="ml-3 usdr-link"
href="#"
@click="cancelUpload"
>Cancel</a>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/arpa_reporter/views/NewUploadView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default {
name: 'submit',
type: 'submit',
label: 'Submit',
inputClass: ['btn', 'btn-primary'],
inputClass: ['btn', 'usdr-btn-primary'],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: Screenshots

Before

image

After

image

},
{
type: 'button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<div class="mb-4">
<router-link
to="/reporting_periods/new"
class="btn btn-primary"
class="btn usdr-btn-primary"
>
Create New Reporting Period
</router-link>
Expand Down Expand Up @@ -36,14 +36,15 @@
<router-link
v-if="!p.certified_at"
:to="`/new_template/${p.id}`"
class="usdr-link"
>
Upload Template
</router-link>
</td>
<td>
<span v-if="isCurrentReportingPeriod(p)">
<button
class="btn btn-primary"
class="btn usdr-btn-primary"
data-toggle="modal"
data-target="#certify-reporting-period"
:disabled="certifying"
Expand Down Expand Up @@ -97,7 +98,7 @@
<div class="modal-footer">
<button
type="button"
class="btn btn-primary"
class="btn usdr-btn-primary"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer: before/after screenshots

Before

image

Repeated for each row
image

image

After

image


Note: This finding will be addressed in a separate PR

image

@click="handleCertify"
>
Certify
Expand Down
10 changes: 5 additions & 5 deletions packages/client/src/arpa_reporter/views/UploadView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
class="float-right"
>
<button
class="btn btn-primary ml-2"
class="btn usdr-btn-primary ml-2"
:disabled="validating"
@click="validateUpload"
>
Expand All @@ -148,14 +148,14 @@
:small="false"
/>
<button
class="btn btn-outline-primary ml-2"
class="btn usdr-btn-outline-primary ml-2"
:disabled="upload.invalidated_at"
@click="invalidateUpload"
>
Invalidate
</button>
<button
class="btn btn-outline-primary ml-2"
class="btn usdr-btn-outline-primary ml-2"
:disabled="validating"
@click="validateUpload"
>
Expand All @@ -178,7 +178,7 @@
Invalidate
</button>
<button
class="btn btn-primary ml-2"
class="btn usdr-btn-primary ml-2"
:disabled="validating"
@click="validateUpload"
>
Expand All @@ -187,7 +187,7 @@
</span>

<!--
<button class="btn btn-primary ml-2" @click="validateUpload" :disabled="validating">
<button class="btn usdr-btn-primary ml-2" @click="validateUpload" :disabled="validating">
<span v-if="validating">Validating...</span>
<span v-else-if="upload.validated_at">Re-validate</span>
<span v-else>Validate</span>
Expand Down
Loading
Loading