|
@@ -1,11 +1,5 @@
|
|
|
import {initializeOrg} from 'sentry-test/initializeOrg';
|
|
|
-import {
|
|
|
- render,
|
|
|
- screen,
|
|
|
- userEvent,
|
|
|
- waitFor,
|
|
|
- within,
|
|
|
-} from 'sentry-test/reactTestingLibrary';
|
|
|
+import {render, screen, userEvent, waitFor} from 'sentry-test/reactTestingLibrary';
|
|
|
import {textWithMarkupMatcher} from 'sentry-test/utils';
|
|
|
|
|
|
import {PRODUCT, ProductSelection} from 'sentry/components/onboarding/productSelection';
|
|
@@ -34,41 +28,30 @@ describe('Onboarding Product Selection', function () {
|
|
|
expect(screen.queryByText('Prefer to set up Sentry using')).not.toBeInTheDocument();
|
|
|
|
|
|
// Error monitoring shall be checked and disabled by default
|
|
|
- const errorMonitoring = screen.getByTestId(
|
|
|
- `product-${PRODUCT.ERROR_MONITORING}-${PRODUCT.PERFORMANCE_MONITORING}-${PRODUCT.SESSION_REPLAY}`
|
|
|
- );
|
|
|
- expect(within(errorMonitoring).getByText('Error Monitoring')).toBeInTheDocument();
|
|
|
- expect(within(errorMonitoring).getByRole('checkbox')).toBeChecked();
|
|
|
- expect(within(errorMonitoring).getByRole('checkbox')).toBeDisabled();
|
|
|
+ expect(screen.getByRole('checkbox', {name: 'Error Monitoring'})).toBeChecked();
|
|
|
|
|
|
// Tooltip with explanation shall be displayed on hover
|
|
|
- await userEvent.hover(errorMonitoring);
|
|
|
+ await userEvent.hover(screen.getByRole('checkbox', {name: 'Error Monitoring'}));
|
|
|
expect(
|
|
|
await screen.findByText(/Let's admit it, we all have errors/)
|
|
|
).toBeInTheDocument();
|
|
|
|
|
|
// Try to uncheck error monitoring
|
|
|
- await userEvent.click(errorMonitoring);
|
|
|
+ await userEvent.click(screen.getByRole('checkbox', {name: 'Error Monitoring'}));
|
|
|
await waitFor(() => expect(router.push).not.toHaveBeenCalled());
|
|
|
|
|
|
// Performance monitoring shall be checked and enabled by default
|
|
|
- const performanceMonitoring = screen.getByTestId(
|
|
|
- `product-${PRODUCT.PERFORMANCE_MONITORING}`
|
|
|
- );
|
|
|
- expect(
|
|
|
- within(performanceMonitoring).getByText('Performance Monitoring')
|
|
|
- ).toBeInTheDocument();
|
|
|
- expect(within(performanceMonitoring).getByRole('checkbox')).toBeChecked();
|
|
|
- expect(within(performanceMonitoring).getByRole('checkbox')).toBeEnabled();
|
|
|
+ expect(screen.getByRole('checkbox', {name: 'Performance Monitoring'})).toBeChecked();
|
|
|
+ expect(screen.getByRole('checkbox', {name: 'Performance Monitoring'})).toBeEnabled();
|
|
|
|
|
|
// Tooltip with explanation shall be displayed on hover
|
|
|
- await userEvent.hover(performanceMonitoring);
|
|
|
+ await userEvent.hover(screen.getByRole('checkbox', {name: 'Performance Monitoring'}));
|
|
|
expect(
|
|
|
await screen.findByText(/Automatic performance issue detection/)
|
|
|
).toBeInTheDocument();
|
|
|
|
|
|
// Uncheck performance monitoring
|
|
|
- await userEvent.click(performanceMonitoring);
|
|
|
+ await userEvent.click(screen.getByRole('checkbox', {name: 'Performance Monitoring'}));
|
|
|
await waitFor(() =>
|
|
|
expect(router.replace).toHaveBeenCalledWith({
|
|
|
pathname: undefined,
|
|
@@ -77,13 +60,11 @@ describe('Onboarding Product Selection', function () {
|
|
|
);
|
|
|
|
|
|
// Session replay shall be checked and enabled by default
|
|
|
- const sessionReplay = screen.getByTestId(`product-${PRODUCT.SESSION_REPLAY}`);
|
|
|
- expect(within(sessionReplay).getByText('Session Replay')).toBeInTheDocument();
|
|
|
- expect(within(sessionReplay).getByRole('checkbox')).toBeChecked();
|
|
|
- expect(within(sessionReplay).getByRole('checkbox')).toBeEnabled();
|
|
|
+ expect(screen.getByRole('checkbox', {name: 'Session Replay'})).toBeChecked();
|
|
|
+ expect(screen.getByRole('checkbox', {name: 'Session Replay'})).toBeEnabled();
|
|
|
|
|
|
// Uncheck sesseion replay
|
|
|
- await userEvent.click(sessionReplay);
|
|
|
+ await userEvent.click(screen.getByRole('checkbox', {name: 'Session Replay'}));
|
|
|
await waitFor(() =>
|
|
|
expect(router.replace).toHaveBeenCalledWith({
|
|
|
pathname: undefined,
|
|
@@ -92,7 +73,7 @@ describe('Onboarding Product Selection', function () {
|
|
|
);
|
|
|
|
|
|
// Tooltip with explanation shall be displayed on hover
|
|
|
- await userEvent.hover(sessionReplay);
|
|
|
+ await userEvent.hover(screen.getByRole('checkbox', {name: 'Session Replay'}));
|
|
|
expect(
|
|
|
await screen.findByText(/Video-like reproductions of user sessions/)
|
|
|
).toBeInTheDocument();
|
|
@@ -130,4 +111,40 @@ describe('Onboarding Product Selection', function () {
|
|
|
|
|
|
expect(skipLazyLoader).toHaveBeenCalledTimes(1);
|
|
|
});
|
|
|
+
|
|
|
+ it('renders disabled product', async function () {
|
|
|
+ const {router, routerContext} = initializeOrg({
|
|
|
+ router: {
|
|
|
+ location: {
|
|
|
+ query: {product: ['session-replay']},
|
|
|
+ },
|
|
|
+ params: {},
|
|
|
+ },
|
|
|
+ });
|
|
|
+
|
|
|
+ const disabledProducts = [
|
|
|
+ {
|
|
|
+ product: PRODUCT.PERFORMANCE_MONITORING,
|
|
|
+ reason: 'Product unavailable in this SDK version',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+
|
|
|
+ render(<ProductSelection disabledProducts={disabledProducts} />, {
|
|
|
+ context: routerContext,
|
|
|
+ });
|
|
|
+
|
|
|
+ // Performance Monitoring shall be unchecked and disabled by default
|
|
|
+ expect(screen.getByRole('checkbox', {name: 'Performance Monitoring'})).toBeDisabled();
|
|
|
+ expect(
|
|
|
+ screen.getByRole('checkbox', {name: 'Performance Monitoring'})
|
|
|
+ ).not.toBeChecked();
|
|
|
+ await userEvent.hover(screen.getByRole('checkbox', {name: 'Performance Monitoring'}));
|
|
|
+
|
|
|
+ // A tooltip with explanation why the option is disabled shall be displayed on hover
|
|
|
+ expect(await screen.findByText(disabledProducts[0].reason)).toBeInTheDocument();
|
|
|
+ await userEvent.click(screen.getByRole('checkbox', {name: 'Performance Monitoring'}));
|
|
|
+
|
|
|
+ // Try to uncheck performance monitoring
|
|
|
+ await waitFor(() => expect(router.push).not.toHaveBeenCalled());
|
|
|
+ });
|
|
|
});
|