Skip to content

Commit

Permalink
PR review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
VanessaScherma committed Nov 14, 2024
1 parent 7eec74a commit c433a39
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 89 deletions.
1 change: 1 addition & 0 deletions .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
yarn test:unit
yarn test:preview:unit
yarn test:preview:int
yarn test:coverage:int-unit
- name: Upload unit and integration test coverage to Codecov
uses: codecov/codecov-action@v3
Expand Down
5 changes: 2 additions & 3 deletions client/config/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ if (typeof window !== 'undefined') {
REACT_APP_WORKBENCHLINK_VSCODE: '/tools/vscode/',
REACT_APP_WORKBENCHLINK_JUPYTERLAB: '/lab',
REACT_APP_WORKBENCHLINK_JUPYTERNOTEBOOK: '',
REACT_APP_WORKBENCHLINK_DT_PREVIEW: '/preview/digitaltwins',

REACT_APP_CLIENT_ID: '38bf4764fad5ebb2ebbf49b4f57c7720145b61266f13bf4891ff7851dd5c6563',
REACT_APP_AUTH_AUTHORITY: 'https://maestro.cps.digit.au.dk/gitlab',
REACT_APP_CLIENT_ID: '1be55736756190b3ace4c2c4fb19bde386d1dcc748d20b47ea8cfb5935b8446c',
REACT_APP_AUTH_AUTHORITY: 'https://gitlab.com/',
REACT_APP_REDIRECT_URI: 'http://localhost:4000/Library',
REACT_APP_LOGOUT_REDIRECT_URI: 'http://localhost:4000/',
REACT_APP_GITLAB_SCOPES: 'openid profile read_user read_repository api',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,4 @@ describe('Digital Twins', () => {
screen.getByText('The Digital Twin as a Service'),
).toBeInTheDocument();
});

/*
it('fetches subfolders with project id', async () => {
const gitlabInstance = mockGitlabInstance;
const dispatch = jest.fn();
const setError = jest.fn();
const init = jest.spyOn(mockGitlabInstance, 'init');
gitlabInstance.projectId = 1;
const getDTSubfolders = jest.spyOn(mockGitlabInstance, 'getDTSubfolders');
await functions.fetchSubfolders(gitlabInstance, dispatch, setError);
expect(init).toHaveBeenCalled();
expect(getDTSubfolders).toHaveBeenCalledWith(1);
expect(dispatch).toHaveBeenCalled();
});
it('fetches subfolders without project id', async () => {
const gitlabInstance = mockGitlabInstance;
const dispatch = jest.fn();
const setError = jest.fn();
const init = jest.spyOn(mockGitlabInstance, 'init');
gitlabInstance.projectId = null;
const getDTSubfolders = jest.spyOn(mockGitlabInstance, 'getDTSubfolders');
await functions.fetchSubfolders(gitlabInstance, dispatch, setError);
expect(init).toHaveBeenCalled();
expect(getDTSubfolders).not.toHaveBeenCalled();
expect(dispatch).toHaveBeenCalled();
});
it('fetches subfolders with error', async () => {
const gitlabInstance = mockGitlabInstance;
const dispatch = jest.fn();
const setError = jest.fn();
const init = jest.spyOn(mockGitlabInstance, 'init');
gitlabInstance.projectId = 1;
const getDTSubfolders = jest
.spyOn(mockGitlabInstance, 'getDTSubfolders')
.mockRejectedValue(new Error('error'));
await functions.fetchSubfolders(gitlabInstance, dispatch, setError);
expect(init).toHaveBeenCalled();
expect(getDTSubfolders).toHaveBeenCalledWith(1);
expect(dispatch).not.toHaveBeenCalled();
expect(setError).toHaveBeenCalledWith('An error occurred');
});
*/
});
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import * as React from 'react';
import ChangeFileNameDialog from 'preview/route/digitaltwins/create/ChangeFileNameDialog';
import { Provider } from 'react-redux';
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
import { act, fireEvent, render, screen, waitFor } from '@testing-library/react';
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import fileSlice from 'preview/store/file.slice';
import { act } from 'react';

const store = configureStore({
reducer: combineReducers({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react';
import ConfirmDeleteDialog from 'preview/route/digitaltwins/create/ConfirmDeleteDialog';
import { act } from 'react';
import { render, screen } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import { combineReducers, configureStore } from '@reduxjs/toolkit';
import { Provider } from 'react-redux';
import fileSlice, { addOrUpdateFile } from 'preview/store/file.slice';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ describe('CreatePage', () => {
jest.clearAllMocks();
});

/*
it('renders CreatePage', () => {
expect(screen.getByText('Please select a file to edit')).toBeInTheDocument();
});
*/

it('handles cancel when clicking on cancel button and confirm', () => {
act(() => {
screen.getByText('Cancel').click();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import AssetBoard from 'preview/components/asset/AssetBoard';
import { render, screen, waitFor } from '@testing-library/react';
import { act, render, screen, waitFor } from '@testing-library/react';
import { Provider } from 'react-redux';
import * as React from 'react';
import DigitalTwin from 'preview/util/digitalTwin';
Expand Down Expand Up @@ -28,7 +28,7 @@ describe('ReconfigureDialog', () => {

dispatchSpy = jest.spyOn(storeConfig, 'dispatch');

React.act(() => {
act(() => {
render(
<Provider store={storeConfig}>
<AssetBoard tab="Manage" />
Expand All @@ -46,17 +46,17 @@ describe('ReconfigureDialog', () => {
const reconfigureButton = screen.getByRole('button', {
name: /Reconfigure/i,
});
await React.act(async () => {
await act(async () => {
reconfigureButton.click();
});

const cancelButton = await screen.findByRole('button', { name: /Cancel/i });
await React.act(async () => {
await act(async () => {
cancelButton.click();
});

const noButton = await screen.findByRole('button', { name: /No/i });
await React.act(async () => {
await act(async () => {
noButton.click();
});

Expand All @@ -70,17 +70,17 @@ describe('ReconfigureDialog', () => {
const reconfigureButton = screen.getByRole('button', {
name: /Reconfigure/i,
});
await React.act(async () => {
await act(async () => {
reconfigureButton.click();
});

const cancelButton = await screen.findByRole('button', { name: /Cancel/i });
await React.act(async () => {
await act(async () => {
cancelButton.click();
});

const yesButton = await screen.findByRole('button', { name: /Yes/i });
await React.act(async () => {
await act(async () => {
yesButton.click();
});

Expand All @@ -102,24 +102,24 @@ describe('ReconfigureDialog', () => {
isModified: true,
};

React.act(() => {
act(() => {
storeConfig.dispatch(addOrUpdateFile(modifiedFile));
});

const reconfigureButton = screen.getByRole('button', {
name: /Reconfigure/i,
});
await React.act(async () => {
await act(async () => {
reconfigureButton.click();
});

const saveButton = await screen.findByRole('button', { name: /Save/i });
await React.act(async () => {
await act(async () => {
saveButton.click();
});

const yesButton = await screen.findByRole('button', { name: /Yes/i });
await React.act(async () => {
await act(async () => {
yesButton.click();
});

Expand Down Expand Up @@ -150,7 +150,7 @@ describe('ReconfigureDialog', () => {
.spyOn(digitalTwin.DTAssets, 'updateFileContent')
.mockRejectedValue(new Error('Mocked error'));

await React.act(async () => {
await act(async () => {
await ReconfigureDialog.handleFileUpdate(file, digitalTwin, dispatch);
});

Expand Down
File renamed without changes.
10 changes: 0 additions & 10 deletions client/test/preview/unit/util/init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,4 @@ describe('fetchAssets', () => {

expect(dispatch).toHaveBeenCalledWith(setAssets([]));
});

/*
it('should init gitlabinstance and return digital twin', async () => {
(mockGitlabInstance.init as jest.Mock).mockResolvedValue({});
const digitalTwin = await initDigitalTwin('testName');
expect(digitalTwin).toBe(mockDigitalTwin);
});
*/
});

0 comments on commit c433a39

Please sign in to comment.