Skip to content

Commit

Permalink
Merge branch 'dev' into km_AJ-1003_success_notification
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmarete authored Oct 5, 2024
2 parents 6efceb6 + ef5e3e5 commit 3653e53
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 126 deletions.
6 changes: 3 additions & 3 deletions integration-tests/tests/run-analysis-azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const {
getAnimatedDrawer,
input,
noSpinnersAfter,
waitForNoModal,
waitForNoModalDrawer,
waitForNoSpinners,
} = require('../utils/integration-utils');
const { registerTest } = require('../utils/jest-utils');
Expand Down Expand Up @@ -51,7 +51,7 @@ const testRunAnalysisAzure = _.flowRight(
timeout: Millis.ofMinute,
});
await click(page, clickable({ textContains: 'Close' }), { timeout: Millis.ofMinute });
await waitForNoModal(page);
await waitForNoModalDrawer(page);

// Navigate to analysis launcher
await click(page, clickable({ textContains: `${notebookName}.ipynb` }));
Expand All @@ -63,7 +63,7 @@ const testRunAnalysisAzure = _.flowRight(
await click(page, clickable({ textContains: 'Open' }));
await findText(page, 'Azure Cloud Environment');
await click(page, clickable({ textContains: 'Create' }));
await waitForNoModal(page);
await waitForNoModalDrawer(page);

// Wait for env to begin creating
await findElement(page, clickable({ textContains: 'JupyterLab Environment' }));
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/tests/run-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
getAnimatedDrawer,
input,
noSpinnersAfter,
waitForNoModal,
waitForNoModalDrawer,
waitForNoSpinners,
} = require('../utils/integration-utils');
const { registerTest } = require('../utils/jest-utils');
Expand Down Expand Up @@ -47,7 +47,7 @@ const testRunAnalysisFn = _.flowRight(
timeout: Millis.ofMinute,
});
await click(page, clickable({ textContains: 'Close' }), { timeout: Millis.ofMinute });
await waitForNoModal(page);
await waitForNoModalDrawer(page);

// Navigate to analysis launcher
await click(page, clickable({ textContains: `${notebookName}.ipynb` }));
Expand All @@ -61,7 +61,7 @@ const testRunAnalysisFn = _.flowRight(
});
await findText(page, 'Jupyter Cloud Environment');
await click(page, clickable({ text: 'Create' }));
await waitForNoModal(page);
await waitForNoModalDrawer(page);

// Wait for env to begin creating
await findElement(page, clickable({ textContains: 'Jupyter Environment' }), { timeout: Millis.ofSeconds(40) });
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/tests/run-rstudio.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {
getAnimatedDrawer,
input,
noSpinnersAfter,
waitForNoModal,
waitForNoModalDrawer,
waitForNoSpinners,
} = require('../utils/integration-utils');
const { registerTest } = require('../utils/jest-utils');
Expand Down Expand Up @@ -50,7 +50,7 @@ const testRunRStudioFn = _.flowRight(
timeout: Millis.ofMinute,
});
await click(page, clickable({ textContains: 'Close' }), { timeout: Millis.ofMinute });
await waitForNoModal(page);
await waitForNoModalDrawer(page);

// Navigate to analysis launcher
await click(page, clickable({ textContains: `${rFileName}.Rmd` }));
Expand All @@ -63,7 +63,7 @@ const testRunRStudioFn = _.flowRight(
action: () => click(page, clickable({ textContains: 'Open' })),
});
await click(page, clickable({ text: 'Create' }));
await waitForNoModal(page);
await waitForNoModalDrawer(page);

// Wait for env to begin creating
await findElement(page, clickable({ textContains: 'RStudio Environment' }), { timeout: Millis.ofMinutes(2) });
Expand Down
7 changes: 7 additions & 0 deletions integration-tests/utils/integration-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ const waitForModal = (page, { timeout = 30000 } = {}) => {
return page.waitForSelector('.ReactModal__Overlay', { hidden: false, timeout });
};

const waitForNoModalDrawer = async (page) => {
await waitForNoModal(page);
// Matches the animation transition time
await delay(200);
};

// Puppeteer works by internally using MutationObserver. We are setting up the listener before
// the action to ensure that the spinner rendering is captured by the observer, followed by
// waiting for the spinner to be removed
Expand Down Expand Up @@ -631,6 +637,7 @@ module.exports = {
waitForNoModal,
waitForMenu,
waitForModal,
waitForNoModalDrawer,
waitForNoSpinners,
withPageLogging,
withScreenshot,
Expand Down
31 changes: 31 additions & 0 deletions src/libs/notifications.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,37 @@ describe('notify', () => {
// Assert
screen.getByText('Things went BOOM!');
});

it('renders navigation buttons if needed', () => {
// Arrange
notify('error', 'Test notification', {
id: 'test-notification',
message: 'first message',
});
notify('error', 'Test notification', {
id: 'test-notification',
message: 'second message',
});
render(<div>{notificationContent}</div>);

// Act and Assert
screen.getByText('first message');
screen.getByText('1/2');
const nextButton = screen.getByLabelText('Next notification');
const previousButton = screen.getByLabelText('Previous notification');
expect(nextButton).toHaveAttribute('aria-disabled', 'false');
expect(previousButton).toHaveAttribute('aria-disabled', 'true');

fireEvent.click(nextButton);
screen.getByText('second message');
screen.getByText('2/2');
expect(nextButton).toHaveAttribute('aria-disabled', 'true');
expect(previousButton).toHaveAttribute('aria-disabled', 'false');

fireEvent.click(previousButton);
screen.getByText('first message');
screen.getByText('1/2');
});
});

describe('clearNotification', () => {
Expand Down
Loading

0 comments on commit 3653e53

Please sign in to comment.