Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GEN-1927]: Cypress test for onboarding-flow (#1930) #1931

Merged
merged 3 commits into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions frontend/webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts

.DS_Store
*.pid
*.log
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
13 changes: 13 additions & 0 deletions frontend/webapp/cypress/e2e/01-connection.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
describe('Root Connection', () => {
it('Should fetch a config with GraphQL. A redirect of any kind confirms Frontend + Backend connections.', () => {
cy.intercept('/graphql').as('gql');
cy.visit('/');

cy.wait('@gql').then(() => {
cy.location().should((loc) => {
// If GraphQL failed to fetch the config, the app will remain on "/", thereby failing the test.
expect(loc.pathname).to.be.oneOf(['/choose-sources', '/overview']);
});
});
});
});
43 changes: 43 additions & 0 deletions frontend/webapp/cypress/e2e/02-onboarding.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ROUTES } from '../../utils/constants/routes';

describe('Onboarding', () => {
it('Should contain at least a "default" namespace', () => {
cy.intercept('/graphql').as('gql');
cy.visit(ROUTES.CHOOSE_SOURCES);

cy.wait('@gql').then(() => {
expect('#namespace-default').to.exist;
});
});

it('Should contain at least a "Jaeger" destination', () => {
cy.intercept('/graphql').as('gql');
cy.visit(ROUTES.CHOOSE_DESTINATION);

cy.wait('@gql').then(() => {
cy.contains('button', 'ADD DESTINATION').click();
expect('#destination-jaeger').to.exist;
});
});

it('Should autocomplete the "Jaeger" destination', () => {
BenElferink marked this conversation as resolved.
Show resolved Hide resolved
cy.intercept('/graphql').as('gql');
cy.visit(ROUTES.CHOOSE_DESTINATION);

cy.wait('@gql').then(() => {
cy.contains('button', 'ADD DESTINATION').click();
cy.get('#destination-jaeger').click();
expect('#JAEGER_URL').to.not.be.empty;
});
});

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

cy.contains('button', 'NEXT').click();
cy.location('pathname').should('eq', ROUTES.CHOOSE_DESTINATION);

cy.contains('button', 'DONE').click();
cy.location('pathname').should('eq', ROUTES.OVERVIEW);
});
});
7 changes: 0 additions & 7 deletions frontend/webapp/cypress/e2e/onboarding.cy.ts

This file was deleted.

11 changes: 3 additions & 8 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 All @@ -34,11 +30,10 @@
"@types/react-dom": "18.3.1",
"autoprefixer": "^10.4.20",
"babel-plugin-styled-components": "^2.1.4",
"cypress": "^13.16.0",
"cypress": "^13.16.1",
BenElferink marked this conversation as resolved.
Show resolved Hide resolved
"eslint": "9.15.0",
"eslint-config-next": "15.0.3",
"postcss": "^8.4.49",
"typescript": "5.6.3"
},
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
}
4 changes: 3 additions & 1 deletion frontend/webapp/reuseable-components/input/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ const Button = styled.button`

// Wrap Input with forwardRef to handle the ref prop
const Input = forwardRef<HTMLInputElement, InputProps>(
({ icon, buttonLabel, onButtonClick, hasError, errorMessage, title, tooltip, required, initialValue, onChange, type = 'text', ...props }, ref) => {
({ icon, buttonLabel, onButtonClick, hasError, errorMessage, title, tooltip, required, initialValue, onChange, type = 'text', name, ...props }, ref) => {
const isSecret = type === 'password';
const [revealSecret, setRevealSecret] = useState(false);
const [value, setValue] = useState<string>(initialValue || '');
Expand Down Expand Up @@ -144,6 +144,8 @@ const Input = forwardRef<HTMLInputElement, InputProps>(

<StyledInput
ref={ref} // Pass ref to the StyledInput
id={name}
name={name}
$hasIcon={!!icon || isSecret}
value={value}
onChange={handleInputChange}
Expand Down
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 (
BenElferink marked this conversation as resolved.
Show resolved Hide resolved
<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
4 changes: 3 additions & 1 deletion frontend/webapp/reuseable-components/textarea/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const StyledTextArea = styled.textarea`
}
`;

const TextArea: React.FC<TextAreaProps> = ({ errorMessage, title, tooltip, required, onChange, ...props }) => {
const TextArea: React.FC<TextAreaProps> = ({ errorMessage, title, tooltip, required, onChange, name, ...props }) => {
const ref = useRef<HTMLTextAreaElement>(null);

const resize = () => {
Expand All @@ -97,6 +97,8 @@ const TextArea: React.FC<TextAreaProps> = ({ errorMessage, title, tooltip, requi
<InputWrapper $disabled={props.disabled} $hasError={!!errorMessage} $isActive={!!props.autoFocus}>
<StyledTextArea
ref={ref}
id={name}
name={name}
onFocus={resize}
onBlur={resize}
onChange={(e) => {
Expand Down
8 changes: 4 additions & 4 deletions frontend/webapp/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3123,10 +3123,10 @@ csstype@3.1.3, csstype@^3.0.2, csstype@^3.1.2:
resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.3.tgz#d80ff294d114fb0e6ac500fbf85b60137d7eff81"
integrity sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==

cypress@^13.16.0:
version "13.16.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.16.0.tgz#7674ca33941f9da58f15fd4e3456856d87730970"
integrity sha512-g6XcwqnvzXrqiBQR/5gN+QsyRmKRhls1y5E42fyOvsmU7JuY+wM6uHJWj4ZPttjabzbnRvxcik2WemR8+xT6FA==
cypress@^13.16.1:
version "13.16.1"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-13.16.1.tgz#82e776f6ad2037ccce6b6feabed768615c476258"
integrity sha512-17FtCaz0cx7ssWYKXzGB0Vub8xHwpVPr+iPt2fHhLMDhVAPVrplD+rTQsZUsfb19LVBn5iwkEUFjQ1yVVJXsLA==
dependencies:
"@cypress/request" "^3.0.6"
"@cypress/xvfb" "^1.2.4"
Expand Down
2 changes: 0 additions & 2 deletions tests/common/.gitignore

This file was deleted.

125 changes: 0 additions & 125 deletions tests/common/odigos_ui.sh

This file was deleted.

Loading
Loading