Skip to content

Commit

Permalink
Fixed last failing tests for messages
Browse files Browse the repository at this point in the history
  • Loading branch information
mfechner committed Jan 2, 2025
1 parent 89529a9 commit 39bd224
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions ui/src/layout/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ const Navigation = () => {
<ListItemText primary="A Raspberry PI" />
</ListItemButton>,
];

// TODO: on mobile (size maybe md or xs) the app list on left should be hidden by default
return (
<ResponsiveDrawer
classes={{root: classes.root, paper: classes.drawerPaper}}
Expand Down
1 change: 0 additions & 1 deletion ui/src/store/auth-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ export const logout = () => {
export const changePassword = (pass: string) => {
return async (dispatch: AppDispatch) => {
await axios.post(config.get('url') + 'current/user/password', {pass});
// TODO: this post can fail, maybe add error handling?
dispatch(uiActions.addSnackMessage('Password changed.'));
};
};
Expand Down
2 changes: 1 addition & 1 deletion ui/src/store/message-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const fetchMessages = (appId: number = AllMessages, since: number = 0) =>
const response = await axios.get(url);
return response.data;
};

dispatch(messageActions.loading(true));
let url;
if (appId === AllMessages) {
url = config.get('url') + 'message?since=' + since;
Expand Down
5 changes: 3 additions & 2 deletions ui/src/store/message-slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,13 @@ interface MessagesState {
hasMore: boolean;
nextSince: number;
loaded: boolean;
isLoading: boolean;
}

const initialMessageState: MessagesState = {
items: [],
hasMore: false,
nextSince: 0,
loaded: false,
isLoading: false,
}

export const messageSlice = createSlice({
Expand All @@ -38,6 +36,9 @@ export const messageSlice = createSlice({
},
clear(state) {
state.items = [];
},
loading(state, action: PayloadAction<boolean>) {
state.loaded = !action.payload;
}
}
});
Expand Down
14 changes: 7 additions & 7 deletions ui/src/tests/message.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {newTest, GotifyTest} from './setup';
import {clickByText, count, innerText, waitForCount, waitForExists} from './utils';
import * as auth from './authentication';
import * as selector from './selector';
import axios from 'axios';
import axios, {AxiosRequestConfig} from 'axios';
import {IApplication, IMessage, IMessageExtras} from '../types';

let page: Page;
Expand All @@ -18,7 +18,7 @@ beforeAll(async () => {
afterAll(async () => await gotify.close());

// eslint-disable-next-line
const axiosAuth = {auth: {username: 'admin', password: 'admin'}};
const axiosAuth: AxiosRequestConfig = {auth: {username: 'admin', password: 'admin'}};

let windowsServerToken: string;
let linuxServerToken: string;
Expand Down Expand Up @@ -47,7 +47,7 @@ describe.sequential('Messages', () => {
});
const createApp = (name: string) =>
axios
.post<IApplication>(`${gotify.url}/application`, {name}, axiosAuth)
.post<IApplication>(`${gotify.url}application`, {name}, axiosAuth)
.then((resp) => resp.data.token);
it('shows navigation', async () => {
await page.waitForSelector(naviId);
Expand Down Expand Up @@ -99,7 +99,7 @@ describe.sequential('Messages', () => {
for (const item of messages) {
const message = await innerText(item, '.content');
const title = await innerText(item, '.title');
result.push({message, title});
result.push({title, message});
}
return result;
};
Expand All @@ -122,7 +122,7 @@ describe.sequential('Messages', () => {
const backup3 = m('Backup done', 'Gotify Backup finished (0.1MB).');

const createMessage = (msg: Partial<IMessage>, token: string) =>
axios.post<IMessage>(`${gotify.url}/message`, msg, {
axios.post<IMessage>(`${gotify.url}message`, msg, {
headers: {'X-Gotify-Key': token},
});

Expand Down Expand Up @@ -156,7 +156,7 @@ describe.sequential('Messages', () => {
expect(await extractMessages(0)).toEqual([]);
await navigate('All Messages');
});
describe('add some messages', () => {
describe.sequential('add some messages', () => {
it('1', async () => {
await createMessage(windows2, windowsServerToken);
await expectMessages({
Expand Down Expand Up @@ -230,7 +230,7 @@ describe.sequential('Messages', () => {
backup: [backup1],
});
});
describe('add some more messages', () => {
describe.sequential('add some more messages', () => {
it('1', async () => {
await createMessage(linux3, linuxServerToken);
await expectMessages({
Expand Down

0 comments on commit 39bd224

Please sign in to comment.