sadpandajoe commented on code in PR #39534:
URL: https://github.com/apache/superset/pull/39534#discussion_r3198071188


##########
superset-frontend/playwright/tests/dashboard/fullscreen.spec.ts:
##########


Review Comment:
   I don't really think these tests are needed. There isn't really an e2e 
component for this and we aren't validating enough to make it e2e. The unit 
tests also have pretty good coverage, but if we wanted more tests we can do 
these in `Header.test.tsx`:
   
   **1. Enter fullscreen (mirror of the existing exit test)**
   Tests the other direction — entering fullscreen with a subdirectory prefix 
doesn't double it.
   
   ```typescript
   test('should not duplicate subdirectory prefix when entering fullscreen', 
async () => {
     const { useLocation } = jest.requireMock('react-router-dom');
     useLocation.mockReturnValue({
       pathname: '/dashboard',
       search: '',
       hash: '',
       state: undefined,
     });
     window.history.pushState({}, 'Test page', '/pcs/dashboard');
   
     setup();
     await openActionsDropdown();
     userEvent.click(screen.getByText('Enter fullscreen'));
   
     expect(mockHistoryReplace).toHaveBeenCalledWith(
       expect.not.stringMatching(/^\/pcs\//),
     );
     expect(mockHistoryReplace).toHaveBeenCalledWith(
       expect.stringMatching(/^\/dashboard\?standalone=1$/),
     );
   });
   ```
   
   **2. Share URL preserves the full browser path**
   Guards against someone "fixing" the share URL to also use `useLocation()`, 
which would break share links.
   
   ```typescript
   test('share URL should include subdirectory prefix for sharing', () => {
     const { useLocation } = jest.requireMock('react-router-dom');
     useLocation.mockReturnValue({
       pathname: '/dashboard',
       search: '',
       hash: '',
       state: undefined,
     });
     window.history.pushState({}, 'Test page', '/pcs/dashboard');
   
     const { container } = setup();
     // The share/embed URL rendered in the component should use the full 
browser path
     // so shared links work outside the React Router context
     const emailLink = container.querySelector('[data-test="share-by-email"]');
     if (emailLink) {
       expect(emailLink.getAttribute('href')).toMatch(/\/pcs\/dashboard/);
     }
   });
   ```
   
   Add this to `superset-frontend/src/dashboard/util/getDashboardUrl.test.ts`
   **3. `getDashboardUrl` pure function test**
   
   ```typescript
   import { getDashboardUrl } from 'src/dashboard/components/Header/utils';
   
   test('getDashboardUrl does not include subdirectory prefix in output', () => 
{
     const url = getDashboardUrl({
       pathname: '/dashboard/1/',
       filters: {},
       hash: '',
       standalone: 1,
     });
     expect(url).toBe('/dashboard/1/?standalone=1');
   });
   ```
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to