-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(arpa): fix headings and color contrast issues
- Loading branch information
1 parent
d6d0562
commit 0b8830c
Showing
14 changed files
with
149 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,7 +86,7 @@ hr { | |
color: $positive-default; | ||
} | ||
|
||
.usdr-tab-nav-link { | ||
.usdr-link { | ||
color: #305CE0; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
132 changes: 127 additions & 5 deletions
132
packages/client/src/arpa_reporter/views/LoginView.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters