From 486e96cfad957ff49b6f06fd8c566f2e23e6d9b4 Mon Sep 17 00:00:00 2001 From: ronronscelestes Date: Wed, 8 Sep 2021 12:54:05 +0200 Subject: [PATCH] feedback fixes + improved tests --- .../admin/src/pages/Admin/Onboarding/index.js | 36 +++++---- .../Admin/Onboarding/tests/index.test.js | 77 ++++++++++++------- 2 files changed, 71 insertions(+), 42 deletions(-) diff --git a/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js b/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js index cf988913c1..d9bc1d5646 100644 --- a/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js +++ b/packages/core/admin/admin/src/pages/Admin/Onboarding/index.js @@ -8,18 +8,20 @@ import { Text } from '@strapi/parts/Text'; import { FocusTrap } from '@strapi/parts/FocusTrap'; import { useConfigurations } from '../../../hooks'; -const Wrapper = styled.button` +const OnboardingWrapper = styled(Box)` position: fixed; bottom: ${({ theme }) => theme.spaces[2]}; right: ${({ theme }) => theme.spaces[2]}; +`; + +const Button = styled.button` width: ${({ theme }) => theme.spaces[8]}; height: ${({ theme }) => theme.spaces[8]}; background: ${({ theme }) => theme.colors.primary600}; box-shadow: ${({ theme }) => theme.shadows.tableShadow}; border-radius: 50%; - svg { - color: white; + color: ${({ theme }) => theme.colors.neutral0}; } `; @@ -33,7 +35,6 @@ const LinksWrapper = styled(Box)` const StyledLink = styled.a` display: flex; align-items: center; - width: 100%; text-decoration: none; padding: ${({ theme }) => theme.spaces[2]}; padding-left: ${({ theme }) => theme.spaces[5]}; @@ -91,18 +92,21 @@ const Onboarding = () => { }; return ( - - {!isOpen && } - {isOpen && } + + + {/* FIX ME - replace with popover when overflow popover is fixed - + when v4 mockups for onboarding component are ready */} + + when v4 mockups for onboarding component are ready */} {isOpen && ( { )} - + ); }; diff --git a/packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js b/packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js index 97d4e05ea0..f0c744be18 100644 --- a/packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js +++ b/packages/core/admin/admin/src/pages/Admin/Onboarding/tests/index.test.js @@ -1,9 +1,15 @@ import React from 'react'; -import { render } from '@testing-library/react'; +import { render, screen, fireEvent } from '@testing-library/react'; import { IntlProvider } from 'react-intl'; import { ThemeProvider, lightTheme } from '@strapi/parts'; import Onboarding from '../index'; +jest.mock('../../../../hooks', () => ({ + useConfigurations: jest.fn(() => { + return { showTutorials: true }; + }), +})); + const App = ( @@ -13,43 +19,62 @@ const App = ( ); describe('Onboarding', () => { - it('renders and matches the snapshot', () => { + it('renders and matches the snapshot', async () => { const { container: { firstChild }, } = render(App); expect(firstChild).toMatchInlineSnapshot(` .c0 { - border: 0; - -webkit-clip: rect(0 0 0 0); - clip: rect(0 0 0 0); - height: 1px; - margin: -1px; - overflow: hidden; - padding: 0; - position: absolute; - width: 1px; + position: fixed; + bottom: 8px; + right: 8px; + } + + .c1 { + width: 40px; + height: 40px; + background: #4945ff; + box-shadow: 0px 1px 4px rgba(33,33,52,0.1); + border-radius: 50%; + } + + .c1 svg { + color: #ffffff; }
-

-

-

`); }); + + it('should open links when button is clicked', () => { + render(App); + + fireEvent.click(document.querySelector('#onboarding')); + expect(screen.getByText('Documentation')).toBeInTheDocument(); + }); });