Skip to content

Commit

Permalink
Merge pull request #269 from dataswift/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Ddeak authored Mar 10, 2021
2 parents 7dea060 + 7c7acfb commit 3bbb837
Show file tree
Hide file tree
Showing 14 changed files with 1,369 additions and 243 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CI

on:
on:
workflow_dispatch:
push:
branches-ignore:
Expand All @@ -24,20 +24,23 @@ jobs:
- name: Setup NODEJS
uses: actions/setup-node@v1
with:
node-version: '12'
node-version: 12
registry-url: https://npm.pkg.github.com

- name: Cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install
run: yarn install --network-concurrency 1
env:
NODE_AUTH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

- name: Lint
run: yarn lint

- name: Test
run: yarn test

Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,21 @@ jobs:
- name: Setup NODEJS
uses: actions/setup-node@v1
with:
node-version: '12'
node-version: 12
registry-url: https://npm.pkg.github.com

- name: Cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install
run: yarn install --network-concurrency 1
env:
NODE_AUTH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

# TODO: ADD ENVIRONMENT UNIFICATION
# TODO: ADD ENVIRONMENT UNIFICATION
- name: Build deployment package
run: PUBLIC_URL=/assets yarn build:staging:internal
env:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/deploy-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ jobs:
- name: Setup NODEJS
uses: actions/setup-node@v1
with:
node-version: '12'
node-version: 12
registry-url: https://npm.pkg.github.com

- name: Cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install
run: yarn install --network-concurrency 1
env:
NODE_AUTH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

# TODO: ADD ENVIRONMENT UNIFICATION
# TODO: ADD ENVIRONMENT UNIFICATION
- name: Build deployment package
run: PUBLIC_URL=/assets yarn build:staging:external
env:
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/deploy-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,21 @@ jobs:
- name: Setup NODEJS
uses: actions/setup-node@v1
with:
node-version: '12'
node-version: 12
registry-url: https://npm.pkg.github.com

- name: Cache
uses: actions/cache@v2
with:
path: '**/node_modules'
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}

- name: Install
run: yarn install --network-concurrency 1
env:
NODE_AUTH_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}

# TODO: ADD ENVIRONMENT UNIFICATION
# TODO: ADD ENVIRONMENT UNIFICATION
- name: Build deployment package
run: PUBLIC_URL=/assets yarn build
env:
Expand Down
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@dataswift:registry=https://npm.pkg.github.com
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ module.exports = {
"tsconfig": 'tsconfig.test.json'
}
},
"transformIgnorePatterns": [
"/node_modules/(?!react-select-search).+\\.js$"
],
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
"moduleFileExtensions": [
"ts",
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
"private": true,
"dependencies": {
"@dataswift/hat-js": "^0.3.2",
"@dataswift/shared": "v0.0.3",
"@material-ui/core": "^4.11.3",
"@reduxjs/toolkit": "^1.3.5",
"@testing-library/jest-dom": "^5.11.6",
"@testing-library/react": "^11.2.2",
"date-fns": "^2.12.0",
"hmi": "git+ssh://[email protected]:dataswift/hmi-react.git#v0.3.4",
"js-cookie": "^2.2.1",
"lodash": "^4.17.19",
"lodash-es": "^4.17.20",
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"markdown-to-jsx": "^7.1.0",
"query-string": "^6.14.1",
"react": "^17.0.1",
Expand All @@ -22,7 +23,7 @@
"react-redux": "^7.2.2",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2",
"react-scripts": "^4.0.1",
"react-scripts": "^4.0.3",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"typescript": "^4.2.3"
Expand Down
14 changes: 8 additions & 6 deletions src/app/Root.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import React from 'react';
import { Provider } from 'react-redux';
import { store } from './store';
import { LanguageParamHandler } from "./LanguageParamHandler";
import { LanguageParamHandler } from './LanguageParamHandler';
import { RibbonProvider } from '@dataswift/shared';

type Props = {
children: React.ReactNode;
};

const Root: React.FC<Props> = props =>
const Root: React.FC<Props> = (props) => (
<Provider store={store}>
<LanguageParamHandler>
{props.children}
</LanguageParamHandler>
</Provider>;
<RibbonProvider>
<LanguageParamHandler>{props.children}</LanguageParamHandler>
</RibbonProvider>
</Provider>
);

export default Root;
28 changes: 24 additions & 4 deletions src/features/public-profile/PublicProfile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
min-height: 100vh !important;
background-color: $app-background-color-dashboard;


p {
font-size: 14px;
color: #9b9b9b;
Expand All @@ -34,7 +33,8 @@
position: relative;
top: -50px;

svg, img {
svg,
img {
width: 100%;
height: 100%;
border-radius: 50%;
Expand Down Expand Up @@ -66,7 +66,8 @@
margin-bottom: 15px;
text-align: center;

.hat-name, .hat-domain {
.hat-name,
.hat-domain {
display: inline-block;
font-size: 18px;
font-weight: bold;
Expand Down Expand Up @@ -135,7 +136,6 @@
line-height: 1.8;
letter-spacing: normal;
color: $ds-dusty-gray-color;

}
}
}
Expand All @@ -158,3 +158,23 @@
}
}
}

.ds-ribbon.custom {
display: flex;
justify-content: center;
background-color: $app-accent-color;
color: white;

.ds-ribbon-container {
position: relative;
justify-content: center;
flex: none;
width: 60%;
padding: 0;

.ds-ribbon-close {
position: absolute;
right: 0;
}
}
}
85 changes: 85 additions & 0 deletions src/features/public-profile/PublicProfile.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import React from 'react';
import { screen, render, waitFor, fireEvent } from '@testing-library/react';
import { Provider } from 'react-redux';
import { MemoryRouter as Router } from 'react-router-dom';

import { fetchNotification } from '../../services/NotificationService';
import { RibbonProvider } from '@dataswift/shared';
import { PublicProfile } from './PublicProfile';
import { configureStore } from '@reduxjs/toolkit';
import publicProfileSlice from './publicProfileSlice';
import authenticationSlice from '../authentication/authenticationSlice';

import TEST_PROFILE from '../../testData/Profile';

jest.mock('../../services/NotificationService');
const mockFetchNotification: jest.Mocked<any> = fetchNotification;

const STUB_DATE = '2021-01-01T00:00:00Z';

const store = configureStore({
reducer: {
authentication: authenticationSlice,
publicProfile: publicProfileSlice,
},
preloadedState: {
publicProfile: {
pending: false,
profile: TEST_PROFILE,
},
authentication: {
isAuthenticated: true,
},
},
});

const renderWithProviders = (ui: any) => {
return {
...render(
<Provider store={store}>
<RibbonProvider>
<Router>{ui}</Router>
</RibbonProvider>
</Provider>,
),
};
};

beforeEach(() => {
jest.resetAllMocks();
});

describe('Public Profile Page', () => {
test('renders without error', () => {
renderWithProviders(<PublicProfile />);

expect(screen.getByText('Public profile of')).toBeInTheDocument();
});

test('notification appears when landing on the screen', async () => {
window.open = jest.fn();
window.localStorage.clear();
mockFetchNotification.mockResolvedValueOnce({
title: 'ribbon notification',
link: 'testLink',
});
renderWithProviders(<PublicProfile />);

await waitFor(() => expect(screen.queryByText('ribbon notification')).toBeInTheDocument());
fireEvent.click(screen.getByText('ribbon notification'));
expect(window.open).toHaveBeenCalledTimes(1);
expect(window.open).toHaveBeenCalledWith('testLink');
});

test('notification does not appear is the date is the same as the curent day.', async () => {
jest.spyOn(global.Date, 'now').mockImplementation(() => new Date(STUB_DATE).valueOf());
window.localStorage.setItem('dataswift-notification', JSON.stringify(STUB_DATE));
mockFetchNotification.mockResolvedValueOnce({
title: 'ribbon notification',
});

renderWithProviders(<PublicProfile />);

await waitFor(() => expect(screen.queryByText('ribbon notification')).toBeNull());
});
});
Loading

0 comments on commit 3bbb837

Please sign in to comment.