Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/app-utils/src/components/AppBootstrap.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ it('should log in automatically when the anonymous handler is supported', async
expectMockChild().toBeNull();
expect(mockLogin).toHaveBeenCalled();
expect(screen.queryByTestId('auth-base-loading')).not.toBeNull();
expect(screen.queryByTestId('auth-base-loading-spinner')).not.toBeNull();

// Wait for login to complete
await act(async () => {
Expand All @@ -173,6 +174,9 @@ it('should log in automatically when the anonymous handler is supported', async

expect(screen.queryByTestId('auth-base-loading')).toBeNull();
expect(screen.queryByTestId('connection-bootstrap-loading')).not.toBeNull();
expect(
screen.queryByTestId('connection-bootstrap-loading-spinner')
).not.toBeNull();
expect(screen.queryByText(mockChildText)).toBeNull();
expect(mockChannel.postMessage).toHaveBeenCalledWith(
expect.objectContaining({
Expand Down
2 changes: 1 addition & 1 deletion packages/app-utils/src/components/ConnectionBootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export function ConnectionBootstrap({
return (
<LoadingOverlay
data-testid="connection-bootstrap-loading"
isLoading={false}
isLoading={error == null}
errorMessage={error != null ? `${error}` : undefined}
/>
);
Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/main/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AppMainContainer from './AppMainContainer';

function App(): ReactElement {
return (
<div className="app">
<div className="app" data-testid="app-loaded">
<AppMainContainer />
<ToastContainer />
</div>
Expand Down
36 changes: 36 additions & 0 deletions tests/app.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test, expect } from '@playwright/test';
import { gotoPage } from './utils';

test.describe('app loading tests', () => {
test.beforeEach(async ({ page }) => {
await gotoPage(page, '');
});

test('initial dashboard is immediately ready after `gotoPage` has completed', async ({
page,
}) => {
await page.goto('');

// Now poll every 5ms to see if the app has finished loading. Until it has finished loading, a loading spinner should be visible.
await expect
.poll(
async () => {
const isSpinnerVisible = await page
.getByRole('progressbar', { name: 'Loading...', exact: true })
.isVisible();
const isAppLoaded =
(await page.getByTestId('app-loaded').count()) === 1;
if (!isSpinnerVisible && !isAppLoaded) {
throw new Error(
'App is in an invalid state: no spinner and app not loaded'
);
}
return isAppLoaded;
},
{
intervals: [5],
}
)
.toBe(true);
});
});
Loading