fix: resolve final workbench re-review findings
This commit is contained in:
@@ -40,6 +40,24 @@ describe('ServerLogin', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it.each([
|
||||
['localhost', 'http://localhost'],
|
||||
['localhost:8080', 'http://localhost:8080'],
|
||||
['192.168.1.20:3000', 'http://192.168.1.20:3000'],
|
||||
['example.com:8443', 'http://example.com:8443'],
|
||||
['https://example.com', 'https://example.com'],
|
||||
])('accepts and normalizes a valid server value: %s', async (server, apiBase) => {
|
||||
const onLogin = vi.fn();
|
||||
render(ServerLogin, { props: { apiBase: 'http://localhost:8080', onLogin } });
|
||||
|
||||
await fireEvent.input(screen.getByLabelText('Server IP or domain'), { target: { value: server } });
|
||||
await fireEvent.input(screen.getByLabelText('Email or username'), { target: { value: 'david@example.com' } });
|
||||
await fireEvent.input(screen.getByLabelText('Password'), { target: { value: 'secret' } });
|
||||
await fireEvent.click(screen.getByRole('button', { name: 'Log in' }));
|
||||
|
||||
expect(onLogin).toHaveBeenCalledWith({ apiBase, account: 'david@example.com' });
|
||||
});
|
||||
|
||||
it('shows an error when account or password is missing', async () => {
|
||||
render(ServerLogin, { props: { apiBase: 'http://localhost:8080' } });
|
||||
|
||||
@@ -57,6 +75,12 @@ describe('ServerLogin', () => {
|
||||
['https://user:secret@example.com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['http://', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['ftp://example.com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['http:////example.com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['http://example..com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['http://-bad.com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['http://bad-.com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['http://bad_host.com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
['http://bad!.com', 'Enter a valid HTTP or HTTPS server address.'],
|
||||
])('rejects an invalid server value: %s', async (server, error) => {
|
||||
const onLogin = vi.fn();
|
||||
render(ServerLogin, { props: { apiBase: 'http://localhost:8080', onLogin } });
|
||||
|
||||
Reference in New Issue
Block a user