Skip to content

Commit

Permalink
[GEN-1927]: Cypress test for onboarding-flow (#1930)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenElferink authored Dec 5, 2024
1 parent 6e60978 commit 3199daf
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const DestinationListItem: React.FC<DestinationListItemProps> = ({ item,
};

return (
<ListItem onClick={() => onSelect(item)}>
<ListItem id={`destination-${item.type}`} onClick={() => onSelect(item)}>
<ListItemContent>
<DestinationIconWrapper>
<Image src={item.imageUrl} width={20} height={20} alt='destination' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const DestinationsList: React.FC<DestinationsListProps> = ({ items, setSelectedI
<ListsWrapper key={`category-${item.name}`}>
<SectionTitle size='small' title={capitalizeFirstLetter(item.name)} description={item.description} />
{item.items.map((categoryItem) => (
<DestinationListItem key={`destination-${categoryItem.displayName}`} item={categoryItem} onSelect={setSelectedItems} />
<DestinationListItem key={`destination-${categoryItem.type}`} item={categoryItem} onSelect={setSelectedItems} />
))}
</ListsWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const SourcesList: React.FC<Props> = ({
const hasFilteredSources = !!filtered.length;

return (
<Group key={`namespace-${namespace}`} $selected={isNamespaceAllSourcesSelected} $isOpen={isNamespaceSelected && hasFilteredSources}>
<Group id={`namespace-${namespace}`} key={`namespace-${namespace}`} $selected={isNamespaceAllSourcesSelected} $isOpen={isNamespaceSelected && hasFilteredSources}>
<NamespaceItem $selected={isNamespaceAllSourcesSelected} onClick={() => onSelectNamespace(namespace)}>
<FlexRow>
<Checkbox disabled={namespaceLoaded && !isNamespaceCanSelect} initialValue={isNamespaceAllSourcesSelected} onChange={(bool) => onSelectAll(bool, namespace)} />
Expand Down
6 changes: 4 additions & 2 deletions frontend/webapp/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import Cypress from 'cypress';

const PORT = 3000;
const BASE_URL = `http://localhost:${PORT}`;

const config: Cypress.ConfigOptions = {
e2e: {
// this uses the "production" build, if you want to use the "development" build, you can use "port=3000" instead
baseUrl: 'http://localhost:3001',
setupNodeEvents(on, config) {},
baseUrl: BASE_URL,
supportFile: false,
waitForAnimations: true,
},
Expand Down
10 changes: 10 additions & 0 deletions frontend/webapp/cypress/e2e/connection.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
describe('Root Connection', () => {
it('Should fetch a config with GraphQL. A redirect of any kind confirms Frontend + Backend connections.', () => {
cy.visit('/');

// If GraphQL failed to fetch the config, the app will remain on "/", thereby failing the test.
cy.location().should((loc) => {
expect(loc.pathname).to.be.oneOf(['/choose-sources', '/overview']);
});
});
});
29 changes: 25 additions & 4 deletions frontend/webapp/cypress/e2e/onboarding.cy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
describe('Onboarding', () => {
it('Visiting the root path fetches a config with GraphQL. A fresh install will result in a redirect to the start of onboarding, confirming Front + Back connections', () => {
cy.visit('/');
// If backend connection failed for any reason, teh default redirect would be "/overview"
cy.location('pathname').should('eq', '/choose-sources');
it('Should contain at least a "default" namespace', () => {
cy.visit('/choose-sources');

cy.get('#no-data').should('not.exist');
cy.get('#namespace-default').should('exist');
});

it('Should contain at least a "Jaeger" destination', () => {
cy.visit('/choose-destination');

cy.get('button').contains('ADD DESTINATION').click();
cy.get('#no-data').should('not.exist');

cy.get('input').should('have.attr', 'placeholder', 'Search...').type('Jaeger');
cy.get('#destination-jaeger').should('exist');
});

it('Should allow the user to pass every step, and end-up on the Overview page.', () => {
cy.visit('/choose-sources');

cy.get('button').contains('NEXT').click();
cy.location('pathname').should('eq', '/choose-destination');

cy.get('button').contains('DONE').click();
cy.location('pathname').should('eq', '/overview');
});
});
9 changes: 2 additions & 7 deletions frontend/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,11 @@
"version": "0.1.0",
"private": true,
"scripts": {
"back:build": "cd .. && go build -o ./odigos-backend",
"back:start": "cd .. && ./odigos-backend --port 8085 --debug --address 0.0.0.0",
"predev": "rm -rf .next",
"dev": "next dev",
"prebuild": "rm -rf out",
"build": "next build",
"start": "next start",
"lint": "next lint --fix",
"cy": "cypress run --e2e -q",
"cy:run": "cypress run --e2e -q",
"cy:open": "cypress open --e2e -b electron"
},
"dependencies": {
Expand Down Expand Up @@ -39,6 +35,5 @@
"eslint-config-next": "15.0.3",
"postcss": "^8.4.49",
"typescript": "5.6.3"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Container = styled.div`

const NoDataFound: React.FC<NoDataFoundProps> = ({ title = 'No data found', subTitle = 'Check your search phrase and try one more time' }) => {
return (
<Container>
<Container id='no-data'>
<TitleWrapper>
<Image src='/icons/common/no-data-found.svg' alt='no-found' width={16} height={16} />
<Title>{title}</Title>
Expand Down
125 changes: 0 additions & 125 deletions tests/common/odigos_ui.sh

This file was deleted.

53 changes: 43 additions & 10 deletions tests/e2e/ui/chainsaw-test.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,56 @@
apiVersion: chainsaw.kyverno.io/v1alpha1
kind: Test
metadata:
name: ui-cypress
name: ui
spec:
description: Run E2E tests against Odigos UI using Cypress
skipDelete: true
steps:
- name: Start the UI
- name: Install Odigos CLI
try:
- script:
timeout: 300s
content: ../../common/odigos_ui.sh start
- name: Test the UI
timeout: 60s
content: |
../../../cli/odigos install --version e2e-test
- name: Install App - Simple Demo
try:
- script:
timeout: 300s
content: ../../common/odigos_ui.sh test
- name: End the UI
timeout: 120s
content: |
kubectl apply -f https://raw.githubusercontent.com/odigos-io/simple-demo/main/kubernetes/deployment.yaml
kubectl wait --for=condition=available --timeout=120s deployment --all -n default
- name: Add Destination - Jaeger
try:
- script:
timeout: 60s
content: ../../common/odigos_ui.sh stop
timeout: 120s
content: |
kubectl apply -f https://raw.githubusercontent.com/odigos-io/simple-demo/main/kubernetes/jaeger.yaml
kubectl wait --for=condition=available --timeout=120s deployment/jaeger -n tracing
- name: Start UI from CLI
try:
- script:
timeout: 10s
content: |
nohup ../../../cli/odigos ui --beta > odigos-ui.log 2>&1 &
sleep 5
- name: Wait for UI
try:
- script:
timeout: 30s
content: |
for i in {1..10}; do
curl -s http://localhost:3000 && break || sleep 2
done
- name: Run Cypress tests
try:
- script:
timeout: 300s
content: |
cd ../../../frontend/webapp
yarn install
yarn cy:run

0 comments on commit 3199daf

Please sign in to comment.