Skip to content

Commit afae980

Browse files
committed
Fix test
1 parent cec8449 commit afae980

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

packages/server/api/test/unit/openops-tables/auth-admin-tables.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jest.mock('@openops/server-shared', () => ({
77
AppSystemProp: {
88
TABLES_TOKEN_LIFETIME_MINUTES: 'TABLES_TOKEN_LIFETIME_MINUTES',
99
OPENOPS_ADMIN_EMAIL: 'OPENOPS_ADMIN_EMAIL',
10-
OPENOPS_ADMIN_PASSWORD: 'OPENOPS_ADMIN_PASSWORD',
10+
DB_TYPE: 'DB_TYPE',
1111
},
1212
system: {
1313
getOrThrow: getOrThrowMock,
@@ -19,6 +19,13 @@ jest.mock('@openops/server-shared', () => ({
1919
},
2020
}));
2121

22+
const getUserByEmailOrFailMock = jest.fn().mockResolvedValue({});
23+
jest.mock('../../../src/app/user/user-service', () => ({
24+
userService: {
25+
getUserByEmailOrFail: getUserByEmailOrFailMock,
26+
},
27+
}));
28+
2229
const authenticateUserInOpenOpsTablesMock = jest.fn();
2330
jest.mock('@openops/common', () => ({
2431
authenticateUserInOpenOpsTables: authenticateUserInOpenOpsTablesMock,
@@ -29,6 +36,13 @@ import { authenticateAdminUserInOpenOpsTables } from '../../../src/app/openops-t
2936
describe('Authenticate admin user in OpenOps Tables', () => {
3037
beforeEach(() => {
3138
jest.clearAllMocks();
39+
40+
const user = {
41+
id: 'u1',
42+
password: 'secret',
43+
};
44+
45+
getUserByEmailOrFailMock.mockResolvedValue(user);
3246
});
3347

3448
it('returns cached tokens when available', async () => {
@@ -57,7 +71,6 @@ describe('Authenticate admin user in OpenOps Tables', () => {
5771
const res = await authenticateAdminUserInOpenOpsTables(axiosRetryConfig);
5872

5973
expect(getOrThrowMock).toHaveBeenNthCalledWith(1, 'OPENOPS_ADMIN_EMAIL');
60-
expect(getOrThrowMock).toHaveBeenNthCalledWith(2, 'OPENOPS_ADMIN_PASSWORD');
6174
expect(authenticateUserInOpenOpsTablesMock).toHaveBeenCalledWith(
6275
'admin@example.com',
6376
'secret',

0 commit comments

Comments
 (0)