fix: CI tests - switch login to text input, fix session validation regex, fix playerManagement test
This commit is contained in:
@@ -12916,3 +12916,43 @@ Connected to MongoDB
|
||||
[2026-06-23T12:51:53.129Z] SESSION: Invalid session format session_anders_1782219113016_mb3dpv
|
||||
[2026-06-23T12:52:17.342Z] MariaDB: Created mission The Hunt for Fabius Bile
|
||||
[2026-06-23T12:52:17.344Z] API: Created mission The Hunt for Fabius Bile
|
||||
[2026-06-23T13:01:39.491Z] MariaDB: Tables created successfully
|
||||
[2026-06-23T13:03:36.764Z] Session created: session_gm_1782219816511_nz4ek3
|
||||
[2026-06-23T13:03:36.766Z] API: Player login gm success
|
||||
[2026-06-23T13:03:36.808Z] API: Fetch player gm success
|
||||
[2026-06-23T13:03:36.889Z] SESSION: Invalid session format session_gm_1782219816511_nz4ek3
|
||||
[2026-06-23T13:06:44.094Z] Session created: session_gm_1782220004085_l5yvpv
|
||||
[2026-06-23T13:06:44.097Z] API: Player login gm success
|
||||
[2026-06-23T13:06:44.139Z] API: Fetch player gm success
|
||||
[2026-06-23T13:06:44.199Z] SESSION: Invalid session format session_gm_1782220004085_l5yvpv
|
||||
[2026-06-23T13:07:59.552Z] Session created: session_gm_1782220079547_93upxg
|
||||
[2026-06-23T13:07:59.554Z] API: Player login gm success
|
||||
[2026-06-23T13:07:59.593Z] API: Fetch player gm success
|
||||
[2026-06-23T13:07:59.653Z] SESSION: Invalid session format session_gm_1782220079547_93upxg
|
||||
[2026-06-23T13:09:07.744Z] Session created: session_gm_1782220147557_uu58jh
|
||||
[2026-06-23T13:09:07.750Z] API: Player login gm success
|
||||
[2026-06-23T13:09:07.785Z] API: Fetch player gm success
|
||||
[2026-06-23T13:09:07.858Z] SESSION: Invalid session format session_gm_1782220147557_uu58jh
|
||||
[2026-06-23T13:10:48.117Z] MariaDB: Tables created successfully
|
||||
[2026-06-23T13:11:33.695Z] Session created: session_gm_1782220293640_ngbf0d
|
||||
[2026-06-23T13:11:33.697Z] API: Player login gm success
|
||||
[2026-06-23T13:11:33.747Z] API: Fetch player gm success
|
||||
[2026-06-23T13:11:33.790Z] SESSION: Invalid session format session_gm_1782220293640_ngbf0d
|
||||
[2026-06-23T13:12:20.725Z] Session created: session_gm_1782220340688_jaaf1x
|
||||
[2026-06-23T13:12:20.728Z] API: Player login gm success
|
||||
[2026-06-23T13:12:20.773Z] API: Fetch player gm success
|
||||
[2026-06-23T13:12:20.806Z] SESSION: Invalid session format session_gm_1782220340688_jaaf1x
|
||||
[2026-06-23T13:12:47.576Z] SESSION: Invalid session format session_gm_1782220340688_jaaf1x
|
||||
[2026-06-23T13:13:13.917Z] MariaDB: Tables created successfully
|
||||
[2026-06-23T13:13:19.595Z] SESSION: Invalid session format session_gm_1782220340688_jaaf1x
|
||||
[2026-06-23T13:13:49.416Z] SESSION: Invalid session format session_gm_1782220340688_jaaf1x
|
||||
[2026-06-23T13:14:20.269Z] MariaDB: Tables created successfully
|
||||
[2026-06-23T13:14:28.748Z] SESSION: Session validation successful gm
|
||||
[2026-06-23T13:15:08.508Z] Session created: session_gm_1782220508444_yddd8d
|
||||
[2026-06-23T13:15:08.510Z] API: Player login gm success
|
||||
[2026-06-23T13:15:08.564Z] API: Fetch player gm success
|
||||
[2026-06-23T13:15:08.651Z] SESSION: Session validation successful gm
|
||||
[2026-06-23T13:15:08.738Z] API: Fetch player gm success
|
||||
[2026-06-23T13:17:14.755Z] MariaDB: Error getting all weapons {"message":"Table 'deathwatch.weapons' doesn't exist","code":"ER_NO_SUCH_TABLE","errno":1146,"sql":"SELECT * FROM weapons ORDER BY id","sqlState":"42S02","sqlMessage":"Table 'deathwatch.weapons' doesn't exist"}
|
||||
[2026-06-23T13:17:14.768Z] MariaDB: Error getting all bestiary {"message":"Table 'deathwatch.bestiary' doesn't exist","code":"ER_NO_SUCH_TABLE","errno":1146,"sql":"SELECT * FROM bestiary ORDER BY id","sqlState":"42S02","sqlMessage":"Table 'deathwatch.bestiary' doesn't exist"}
|
||||
[2026-06-23T13:33:33.058Z] MariaDB: Tables created successfully
|
||||
|
||||
14
src/App.js
14
src/App.js
@@ -240,16 +240,14 @@ function App() {
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col sm:flex-row gap-2">
|
||||
<select
|
||||
className="rounded-lg border border-slate-600 bg-slate-800 px-3 py-2 text-white text-sm"
|
||||
<input
|
||||
className="rounded-lg border border-slate-600 bg-slate-800 px-3 py-2 text-white placeholder-slate-400 text-sm"
|
||||
type="text"
|
||||
placeholder="Username"
|
||||
value={loginName}
|
||||
onChange={e=>{setLoginName(e.target.value); setLoginPw(e.target.value==='gm'?'bongo':'1234');}}
|
||||
>
|
||||
<option value="">Select user...</option>
|
||||
{players.map(p => (
|
||||
<option key={p.name} value={p.name}>{p.name}</option>
|
||||
))}
|
||||
</select>
|
||||
data-testid="login-user-input"
|
||||
/>
|
||||
<input
|
||||
className="rounded-lg border border-slate-600 bg-slate-800 px-3 py-2 text-white placeholder-slate-400 text-sm"
|
||||
type="password"
|
||||
|
||||
@@ -21,7 +21,7 @@ describe('Login Functionality', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
localStorageMock.getItem.mockReturnValue(null);
|
||||
|
||||
|
||||
// Mock axios to handle different endpoints
|
||||
mockedAxios.get.mockImplementation((url) => {
|
||||
if (url === '/api/players/names') {
|
||||
@@ -47,7 +47,7 @@ describe('Login Functionality', () => {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Default POST mock - will be overridden per test with mockResolvedValueOnce
|
||||
mockedAxios.post.mockImplementation((url, data) => {
|
||||
if (url === '/api/players/login') {
|
||||
@@ -77,20 +77,18 @@ describe('Login Functionality', () => {
|
||||
|
||||
render(<App />);
|
||||
|
||||
// Wait for players list to load
|
||||
// Wait for the login form to appear
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/gm/i)).toBeInTheDocument();
|
||||
expect(screen.getByPlaceholderText(/username/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Find login inputs
|
||||
const nameInput = screen.getByPlaceholderText(/player name|username/i);
|
||||
const nameInput = screen.getByPlaceholderText(/username/i);
|
||||
const passwordInput = screen.getByPlaceholderText(/password/i);
|
||||
const loginButton = screen.getByRole('button', { name: /login|enter/i });
|
||||
const loginButton = screen.getByRole('button', { name: /login/i });
|
||||
|
||||
// Fill in login form with GM credentials (test credentials)
|
||||
const testGmPassword = 'bongo'; // GM password from .env
|
||||
// Fill in login form with GM credentials
|
||||
fireEvent.change(nameInput, { target: { value: 'gm' } });
|
||||
fireEvent.change(passwordInput, { target: { value: testGmPassword } });
|
||||
fireEvent.change(passwordInput, { target: { value: 'bongo' } });
|
||||
|
||||
// Click login button
|
||||
fireEvent.click(loginButton);
|
||||
@@ -101,7 +99,7 @@ describe('Login Functionality', () => {
|
||||
'/api/players/login',
|
||||
{
|
||||
name: 'gm',
|
||||
password: testGmPassword
|
||||
password: 'bongo'
|
||||
}
|
||||
);
|
||||
});
|
||||
@@ -124,12 +122,12 @@ describe('Login Functionality', () => {
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/gm/i)).toBeInTheDocument();
|
||||
expect(screen.getByPlaceholderText(/username/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const nameInput = screen.getByPlaceholderText(/player name|username/i);
|
||||
const nameInput = screen.getByPlaceholderText(/username/i);
|
||||
const passwordInput = screen.getByPlaceholderText(/password/i);
|
||||
const loginButton = screen.getByRole('button', { name: /login|enter/i });
|
||||
const loginButton = screen.getByRole('button', { name: /login/i });
|
||||
|
||||
fireEvent.change(nameInput, { target: { value: 'gm' } });
|
||||
fireEvent.change(passwordInput, { target: { value: 'wrong_password' } });
|
||||
@@ -152,16 +150,15 @@ describe('Login Functionality', () => {
|
||||
render(<App />);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/gm/i)).toBeInTheDocument();
|
||||
expect(screen.getByPlaceholderText(/username/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const nameInput = screen.getByPlaceholderText(/player name|username/i);
|
||||
const nameInput = screen.getByPlaceholderText(/username/i);
|
||||
const passwordInput = screen.getByPlaceholderText(/password/i);
|
||||
const loginButton = screen.getByRole('button', { name: /login|enter/i });
|
||||
const loginButton = screen.getByRole('button', { name: /login/i });
|
||||
|
||||
const testPlayerPassword = '1234'; // Player password from .env
|
||||
fireEvent.change(nameInput, { target: { value: 'nonexistent' } });
|
||||
fireEvent.change(passwordInput, { target: { value: testPlayerPassword } });
|
||||
fireEvent.change(passwordInput, { target: { value: '1234' } });
|
||||
fireEvent.click(loginButton);
|
||||
|
||||
await waitFor(() => {
|
||||
@@ -182,20 +179,19 @@ describe('Login Functionality', () => {
|
||||
|
||||
render(<App />);
|
||||
|
||||
// Wait for players list to load
|
||||
// Wait for the login form to appear
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText(/anders/i)).toBeInTheDocument();
|
||||
expect(screen.getByPlaceholderText(/username/i)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
// Find login inputs
|
||||
const nameInput = screen.getByPlaceholderText(/player name|username/i);
|
||||
const nameInput = screen.getByPlaceholderText(/username/i);
|
||||
const passwordInput = screen.getByPlaceholderText(/password/i);
|
||||
const loginButton = screen.getByRole('button', { name: /login|enter/i });
|
||||
const loginButton = screen.getByRole('button', { name: /login/i });
|
||||
|
||||
// Fill in login form with player credentials
|
||||
const testPlayerPassword = '1234'; // Player password from .env
|
||||
fireEvent.change(nameInput, { target: { value: 'anders' } });
|
||||
fireEvent.change(passwordInput, { target: { value: testPlayerPassword } });
|
||||
fireEvent.change(passwordInput, { target: { value: '1234' } });
|
||||
|
||||
// Click login button
|
||||
fireEvent.click(loginButton);
|
||||
@@ -206,7 +202,7 @@ describe('Login Functionality', () => {
|
||||
'/api/players/login',
|
||||
{
|
||||
name: 'anders',
|
||||
password: testPlayerPassword
|
||||
password: '1234'
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -105,11 +105,11 @@ describe('PlayerManagement Component', () => {
|
||||
await waitFor(() => {
|
||||
expect(mockedAxios.post).toHaveBeenCalledWith(
|
||||
'/api/players/gm/add-or-update',
|
||||
{
|
||||
expect.objectContaining({
|
||||
name: 'NewPlayer',
|
||||
requisitionPoints: 75,
|
||||
password: 'testpass'
|
||||
},
|
||||
}),
|
||||
{
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user