1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import axios from 'axios';
7 import { DownloadAction } from './download-action';
8 import { ThemeProvider } from '@mui/material';
9 import { CustomTheme } from 'common/custom-theme';
11 describe('<DownloadAction />', () => {
19 it('should return null if missing href or kind of file in props', () => {
22 <ThemeProvider theme={CustomTheme}>
23 <DownloadAction {...props} />
27 cy.get('[data-cy-root]').children().should('have.length', 0);
30 it('should return a element', () => {
36 <ThemeProvider theme={CustomTheme}>
37 <DownloadAction {...props} />
41 cy.get('[data-cy-root]').children().should('have.length.greaterThan', 0);
44 it('should handle download', () => {
50 currentCollectionUuid: '123412-123123'
53 Cypress.on('uncaught:exception', (err, runnable) => {
54 // Returning false here prevents Cypress from failing the test when axios returns 404
55 if (err.message.includes('Request failed with status code 404')) {
58 // Otherwise, let the error fail the test
62 cy.intercept('GET', '*', (req) => {
65 body: { message: 'Mocked response' },
69 cy.spy(axios, 'get').as('get');
72 <ThemeProvider theme={CustomTheme}>
73 <DownloadAction {...props} />
77 cy.get('span').contains('Download selected').click();
80 cy.get('@get').should('be.calledWith', props.href[0]);