Skip to content

Commit

Permalink
Merge pull request #2488 from glific/next
Browse files Browse the repository at this point in the history
New UI for Glific
  • Loading branch information
mdshamoon authored Mar 8, 2024
2 parents de02994 + 0a685a2 commit 7a7470c
Show file tree
Hide file tree
Showing 450 changed files with 8,112 additions and 5,103 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/cypress-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [master]
pull_request:
branches: [master]
branches: [master, next]

jobs:
glific:
Expand Down Expand Up @@ -95,6 +95,9 @@ jobs:
echo clone cypress repo
git clone https://github.com/glific/cypress-testing.git
echo done. go to dir.
cd cypress-testing
git checkout feature/next
cd ..
cp -r cypress-testing/cypress cypress
yarn add cypress
echo Create cypress.config.ts from example
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/netlify.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build and Deploy to Netlify
on:
pull_request:
branches: [master]
branches: [master, next]

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [master]
pull_request:
branches: [master]
branches: [master, next]

jobs:
test:
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/node_modules
/.pnp
.pnp.js
bun.lockb

# testing
/coverage
Expand All @@ -30,4 +31,7 @@ cypress.json
cypress/screenshots
cypress/videos

.tool-versions
.tool-versions

/priv
/.vscode
1 change: 1 addition & 0 deletions src/App.module.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.App {
position: relative;
display: flex;
overflow: hidden;
}
Expand Down
24 changes: 12 additions & 12 deletions src/App.test.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import 'mocks/matchMediaMock';
import { MemoryRouter } from 'react-router-dom';
import { MockedProvider } from '@apollo/client/testing';
import { waitFor, render } from '@testing-library/react';
import { waitFor, render, screen } from '@testing-library/react';
import { vi, describe, it } from 'vitest';

import { setAuthSession, setUserSession } from 'services/AuthService';
import App from 'App';
import { CONVERSATION_MOCKS } from 'mocks/Chat';
import { setAuthSession, setUserSession } from 'services/AuthService';

const mocks = CONVERSATION_MOCKS;
import axios from 'axios';
Expand All @@ -24,6 +23,11 @@ const app = (
</MockedProvider>
);

vi.mock('routes/AuthenticatedRoute/AuthenticatedRoute', () => ({
default: () => <div>Authenticated route subscription</div>,
AuthenticatedRoute: () => <div>Chat subscription</div>,
}));

describe('<App /> ', () => {
it('it should render <Login /> component by default', async () => {
mockedAxios.post.mockImplementation(() => Promise.resolve({}));
Expand All @@ -34,17 +38,15 @@ describe('<App /> ', () => {
});
});

it('it should render <App /> component correctly', async () => {
it('it should render <App /> component correctly in unauthenticated mode', async () => {
const { container } = render(app);
await waitFor(() => {
expect(container).toBeInTheDocument();
expect(screen.getByText('Login')).toBeInTheDocument();
});
});

it('it should render <Chat /> component if session is active', async () => {
// let's create token expiry date for tomorrow
mockedAxios.post.mockResolvedValue(() => Promise.resolve({}));

it('it should render <App /> component correctly in authenticated mode', async () => {
const tokenExpiryDate = new Date();
tokenExpiryDate.setDate(new Date().getDate() + 1);

Expand All @@ -55,11 +57,9 @@ describe('<App /> ', () => {
});

setUserSession(JSON.stringify({ organization: { id: '1' }, roles: ['Staff'] }));

const { getByTestId } = render(app);

render(app);
await waitFor(() => {
expect(getByTestId('navbar')).toBeInTheDocument();
expect(screen.getByText('Chat subscription')).toBeInTheDocument();
});
});
});
7 changes: 3 additions & 4 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,21 @@ import { checkAuthStatusService, getAuthSession } from 'services/AuthService';
import { UnauthenticatedRoute } from 'routes/UnauthenticatedRoute/UnauthenticatedRoute';
import { AuthenticatedRoute } from 'routes/AuthenticatedRoute/AuthenticatedRoute';
import { Logout } from 'containers/Auth/Logout/Logout';
import { isGreaterThanLgBreakpoint } from 'common/utils';

const App = () => {
const navigate = useNavigate();
// by default, do not assign any value to assume login or logout
// let's checkAuthStatusService allocate it on useEffect
const [authenticated, setAuthenticated] = useState<any>();
const [drawerOpen, setDrawerOpen] = useState(isGreaterThanLgBreakpoint());
const [drawerOpen, setDrawerOpen] = useState(true);

useEffect(() => {
const isAccessTokenPresent = getAuthSession('accessToken') !== null;
const isTokenExpired = checkAuthStatusService();
setAuthenticated(isTokenExpired || isAccessTokenPresent);
}, []);

const sideDraawerValues = useMemo(
const sideDrawerValues = useMemo(
() => ({
drawerOpen,
setDrawerOpen: (value: any) => {
Expand Down Expand Up @@ -68,7 +67,7 @@ const App = () => {
<SessionContext.Provider value={values}>
<ApolloProvider client={gqlClient(navigate)}>
<ErrorHandler />
<SideDrawerContext.Provider value={sideDraawerValues}>{routes}</SideDrawerContext.Provider>
<SideDrawerContext.Provider value={sideDrawerValues}>{routes}</SideDrawerContext.Provider>
</ApolloProvider>
</SessionContext.Provider>
);
Expand Down
5 changes: 5 additions & 0 deletions src/assets/images/DownIcon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions src/assets/images/add.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 10 additions & 13 deletions src/assets/images/icons/AdvancedSearch.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 0 additions & 10 deletions src/assets/images/icons/Alert/White.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/images/icons/Analytics/Selected.svg

This file was deleted.

14 changes: 0 additions & 14 deletions src/assets/images/icons/Audio/Light.svg

This file was deleted.

28 changes: 5 additions & 23 deletions src/assets/images/icons/Automations/Terminate.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions src/assets/images/icons/BackIconFlow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/assets/images/icons/Broadcast/Selected.svg

This file was deleted.

1 change: 0 additions & 1 deletion src/assets/images/icons/Broadcast/Unselected.svg

This file was deleted.

16 changes: 0 additions & 16 deletions src/assets/images/icons/BrownDropdown.svg

This file was deleted.

Loading

0 comments on commit 7a7470c

Please sign in to comment.