Skip to content

Commit

Permalink
Globus link display update (#3)
Browse files Browse the repository at this point in the history
* Added a warning case for when a transfer request returns no failures or successes in the backend response. No successes indicates no transfer occurred although there wasn't any specified errors provided. Added new test for the added warning case.

* Fix pre-commit prerequisites
  • Loading branch information
downiec authored Jan 22, 2025
1 parent f42953a commit a296fbe
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 15 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ on:
branches: [master]

jobs:
pre-commit-hooks:
pre-commit:
runs-on: ubuntu-latest
steps:
- name: Checkout Code Repository
- name: Checkout code
uses: actions/checkout@v4

# Required to run the local ESLint hook
- name: Use Node.js 23.x
- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: "23.x"
node-version: '22.x'

- name: Cache node modules
uses: actions/cache@v4
Expand All @@ -36,12 +36,12 @@ jobs:
yarn install --frozen-lockfile
- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: 3.11
python-version: '3.11'

# Run all pre-commit hooks on all the files.
# Getting only staged files can be tricky in case a new PR is opened
# since the action is run on a branch in detached head state
- name: Install and Run Pre-commit
uses: pre-commit/[email protected]
- name: Install requirements
run: pip install -r backend/requirements/local.txt

- name: Run pre-commit
run: pre-commit run --all-files
20 changes: 20 additions & 0 deletions frontend/src/components/Globus/DatasetDownload.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,26 @@ describe('DatasetDownload form tests', () => {
expect(globusTransferPopup).toBeTruthy();
});

it('shows a warning message when Globus transfer response has no data in successes or failures', async () => {
server.use(
rest.post(apiRoutes.globusTransfer.path, (_req, res, ctx) =>
res(ctx.status(200), ctx.json({ status: 200, successes: [], failures: [] }))
)
);

await initializeComponentForTest();

// Click Transfer button
const globusTransferBtn = await screen.findByTestId('downloadDatasetBtn');
expect(globusTransferBtn).toBeTruthy();
await user.click(globusTransferBtn);

const warningMessage = await screen.findByText(
'Globus download requested, however no transfer occurred.'
);
expect(warningMessage).toBeInTheDocument();
});

it('If endpoint URL is available, process it and continue with sign-in', async () => {
await initializeComponentForTest({
...defaultTestConfig,
Expand Down
23 changes: 19 additions & 4 deletions frontend/src/components/Globus/DatasetDownload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,20 @@ const DatasetDownloadForm: React.FC<React.PropsWithChildren<unknown>> = () => {

switch (resp.status) {
case 200:
await showNotice(messageApi, 'Globus download initiated successfully!', {
type: 'success',
});
if (resp.successes.length === 0) {
await showNotice(
messageApi,
'Globus download requested, however no transfer occurred.',
{
type: 'warning',
}
);
} else {
await showNotice(messageApi, 'Globus download initiated successfully!', {
type: 'success',
});
}

break;

case 207:
Expand Down Expand Up @@ -731,7 +742,11 @@ const DatasetDownloadForm: React.FC<React.PropsWithChildren<unknown>> = () => {
// Check chosen endpoint path is ready
if (chosenEndpoint.path) {
setCurrentGoal(GlobusGoals.None);
handleGlobusDownload(transferToken, accessToken, chosenEndpoint);
handleGlobusDownload(
transferToken as GlobusTokenResponse,
accessToken as string,
chosenEndpoint
);
} else {
// Setting endpoint path
setLoadingPage(false);
Expand Down

0 comments on commit a296fbe

Please sign in to comment.