Skip to content

Commit

Permalink
fix cypress
Browse files Browse the repository at this point in the history
  • Loading branch information
hervedombya committed Jan 6, 2025
1 parent ef32193 commit 2d9d7bb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 13 deletions.
7 changes: 3 additions & 4 deletions ui/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'cypress'
import { defineConfig } from 'cypress';

export default defineConfig({
env: {
Expand All @@ -20,14 +20,13 @@ export default defineConfig({
viewportWidth: 1440,
viewportHeight: 900,
defaultCommandTimeout: 30000,
experimentalNetworkStubbing: true,
experimentalFetchPolyfill: true,
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
return require('./cypress/plugins/index.js')(on, config)
return require('./cypress/plugins/index.js')(on, config);
},
baseUrl: 'http://localhost:8084',
},
})
});
16 changes: 10 additions & 6 deletions ui/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {
genValues,
} from './mockUtils';


Cypress.config({
retries: {
runMode: 2,
Expand Down Expand Up @@ -64,7 +63,9 @@ Cypress.Commands.add(
cy.intercept('GET', '/config.json', stubConfig);
}
if (stubUIDiscovery) {
cy.intercept('GET', '/shell/deployed-ui-apps.json', {...stubUIDiscovery });
cy.intercept('GET', '/shell/deployed-ui-apps.json', {
...stubUIDiscovery,
});
}

cy.intercept('GET', '**/.well-known/runtime-app-configuration*', {
Expand All @@ -89,7 +90,9 @@ Cypress.Commands.add(
statusCode: 500,
});
});
cy.intercept('POST', '**/api/salt/login', { fixture: 'salt-api/login.json' });
cy.intercept('POST', '**/api/salt/login', {
fixture: 'salt-api/login.json',
});
cy.intercept('GET', '**/api/salt/events*', (req) =>
req.reply(`data: ${JSON.stringify({})} \n\n`, {
'content-type': 'text/event-stream',
Expand All @@ -106,7 +109,9 @@ Cypress.Commands.add(
{ fixture: 'kubernetes/namespace-kube-system.json' },
);
cy.fixture('kubernetes/nodes.json').then((nodes) => {
cy.intercept('GET', '**/api/kubernetes/api/v1/nodes', { body: nodes });
cy.intercept('GET', '**/api/kubernetes/api/v1/nodes', { body: nodes }).as(
'getNodes',
);

cy.intercept(
'GET',
Expand Down Expand Up @@ -267,11 +272,10 @@ const NODE_NAME = 'bootstrap';
const VOLUME_SIZE = '1 GiB';

Cypress.Commands.add('fillVolumeCreationForm', (volume_type) => {
cy.wait('@getNodes');
// The following steps are to fill the required fields of create volume form
cy.get('input[name=name]').type(VOLUME_NAME);

cy.findByText(new RegExp(`${NODE_NAME}`, 'i'));

// Force click is because the input element is not visiable
cy.findByLabelText(/node \*/i)
.focus()
Expand Down
3 changes: 2 additions & 1 deletion ui/src/FederableApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
useBasenameRelativeNavigate,
useShellHooks,
} from './ShellHooksContext';
import { FederatedAppProps } from '../@mf-types/shell/App';

const composeEnhancers =
// @ts-expect-error - FIXME when you are working on it
Expand Down Expand Up @@ -116,7 +117,7 @@ export const AppConfigProvider = ({
);
};

export default function FederableApp(props) {
export default function FederableApp(props: FederatedAppProps) {
return (
<ShellHooksProvider
shellHooks={props.shellHooks}
Expand Down
6 changes: 5 additions & 1 deletion ui/src/containers/VolumePageContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const VolumePageContent = (props) => {
useEffect(() => {
if (volumeListData.length > 0) {
const firstVolumeName = volumeListData[0]?.name;
if (firstVolumeName && !location.pathname.includes(firstVolumeName)) {
if (
firstVolumeName &&
!location.pathname.includes(firstVolumeName) &&
location.pathname.endsWith('/volumes')
) {
navigate(`/volumes/${firstVolumeName}/overview`, { replace: true });
}
}
Expand Down
3 changes: 2 additions & 1 deletion ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,6 @@
"@testing-library/jest-dom",
"@scality/core-ui/types/styled.d.ts"
]
}
},
"exclude": ["cypress.config.ts", "cypress", "node_modules"]
}

0 comments on commit 2d9d7bb

Please sign in to comment.