Skip to content

Commit 38df46c

Browse files
Adjust test cases for Header language dropdown
1 parent 8516364 commit 38df46c

3 files changed

Lines changed: 18 additions & 3 deletions

File tree

frontend/src/components/header/tests/index.test.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,16 +134,18 @@ describe('Right side action items', () => {
134134
expect(screen.getByLabelText('Sample avatar')).toBeInTheDocument();
135135
});
136136

137-
test("when the user isn't logged in", () => {
137+
test("when the user isn't logged in", async () => {
138138
act(() => {
139139
store.dispatch({
140140
type: 'SET_USER_DETAILS',
141141
userDetails: {},
142142
});
143143
});
144144
setup();
145-
expect(screen.getByRole('combobox')).toBeInTheDocument();
146-
expect(screen.getByText('English')).toBeInTheDocument();
145+
await waitFor(() => {
146+
expect(screen.getByRole('combobox')).toBeInTheDocument();
147+
expect(screen.getByText('English')).toBeInTheDocument();
148+
});
147149
expect(
148150
screen.getByRole('button', {
149151
name: /log in/i,
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const systemLanguages = {
2+
supportedLanguages: [
3+
{
4+
code: 'en',
5+
language: 'English',
6+
},
7+
],
8+
};

frontend/src/network/tests/server-handlers.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ import {
7171
import tasksGeojson from '../../utils/tests/snippets/tasksGeometry';
7272
import { API_URL, OHSOME_STATS_API_URL, defaultChangesetComment } from '../../config';
7373
import { notifications, ownCountUnread } from './mockData/notifications';
74+
import { systemLanguages } from './mockData/header';
7475
import { authLogin, setUser, userRegister } from './mockData/auth';
7576
import {
7677
extendTask,
@@ -153,6 +154,10 @@ const handlers = [
153154
rest.get(API_URL + 'projects/queries/:projectId/similar-projects/', async (req, res, ctx) => {
154155
return res(ctx.json(similarProjects));
155156
}),
157+
// HEADER
158+
rest.get(API_URL + 'system/languages/', async (req, res, ctx) => {
159+
return res(ctx.json(systemLanguages));
160+
}),
156161
// AUTHENTICATION
157162
rest.get(API_URL + 'system/authentication/login/', async (req, res, ctx) => {
158163
return res(ctx.json(authLogin));

0 commit comments

Comments
 (0)