Skip to content

Commit

Permalink
dashboard, make test async
Browse files Browse the repository at this point in the history
Signed-off-by: Aaron Chong <aaronchongth@gmail.com>
  • Loading branch information
aaronchongth committed Jul 18, 2024
1 parent ec7faa4 commit 9408632
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"start:rmf-server:psql": "RMF_SERVER_USE_SIM_TIME=true npm run --prefix ../api-server start:psql",
"start:sim": "concurrently npm:start:rmf-server npm:start:rmf npm:start:react",
"storybook": "storybook dev -p 6006",
"test": "DOTENV_CONFIG_PATH=./.env jest --watch",
"test:coverage": "DOTENV_CONFIG_PATH=./.env jest --coverage",
"test": "jest --watch",
"test:coverage": "jest --coverage",
"test:e2e": "cd e2e && npm test",
"test:e2e:dev": "cd e2e && pnpm run test:dev"
},
Expand Down
5 changes: 3 additions & 2 deletions packages/dashboard/src/components/tests/appbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('AppBar', () => {
expect(root.getByLabelText('user-btn')).toBeTruthy();
});

test('logout is triggered when logout button is clicked', () => {
test('logout is triggered when logout button is clicked', async () => {
const authenticator = new StubAuthenticator('test');
const appConfig: AppConfig = {
authenticator,
Expand All @@ -78,8 +78,9 @@ describe('AppBar', () => {
</AppConfigContext.Provider>,
);
userEvent.click(root.getByLabelText('user-btn'));
await expect(waitFor(() => root.getByText('Logout'))).resolves.not.toThrow();
userEvent.click(root.getByText('Logout'));
expect(spy).toHaveBeenCalledTimes(1);
await expect(waitFor(() => expect(spy).toHaveBeenCalledTimes(1))).resolves.not.toThrow();
});

test('uses headerLogo from logo resources manager', async () => {
Expand Down
7 changes: 7 additions & 0 deletions packages/dashboard/src/setupTests.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
import '@testing-library/jest-dom';

const env = process.env as any;
env.REACT_APP_TRAJECTORY_SERVER = 'http://localhost';
env.REACT_APP_AUTH_PROVIDER = '';
env.REACT_APP_KEYCLOAK_CONFIG = '';
env.REACT_APP_RMF_SERVER = 'http://localhost';
env.PUBLIC_URL = 'http://localhost';

0 comments on commit 9408632

Please sign in to comment.