Skip to content

test: Update cypress config and fix failing tests #161

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

Merged
merged 1 commit into from
Feb 21, 2025
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
1 change: 1 addition & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export default defineConfig({
bundler: "webpack",
},
specPattern: "**/*.test.cypress.{js,ts,jsx,tsx}",
excludeSpecPattern: "**/*.plugin-dev.*",
},

e2e: {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
"build": "cross-env DISABLE_NEW_JSX_TRANSFORM=true react-scripts build",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"test": "cypress open-ct",
"test": "cypress open --component",
"test:ci": "cypress run --component --config watchForFileChanges=false",
"test:pluginapi": "cypress open-ct --config-file ./cypress.plugin-api.config.ts",
"test:pluginapi": "cypress open --component --config-file ./cypress.plugin-api.config.ts",
"test:pluginapi:ci": "cypress run --component --config-file ./cypress.plugin-api.config.ts",
"lint": "eslint \"./src/**/*.{ts,tsx}\"",
"eject": "react-scripts eject",
"format": "prettier --write src",
"dev:plugin": "concurrently --kill-others --names \"PLUGIN-SERVE,DEV\" -c \"bgBlue.bold,bgMagenta.bold\" \"npm:dev-plugin-serve\" \"npm:dev-plugin-cypress\"",
"dev-plugin-serve": "serve ./plugin-api -p 5000",
"dev-plugin-cypress": "cypress open-ct --config-file ./cypress.plugin-dev.config.ts",
"dev-plugin-cypress": "cypress open --component --config-file ./cypress.plugin-dev.config.ts",
"init-mocks": "msw init ./public --save"
},
"browserslist": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,13 @@ describe('ConnectionStatus test', () => {

// check that the connectionStatus is rendered correctly when the connection is ok
cy.waitUntil(() => connected).then(() => {
cy.get('[data-testid="connection-status-wrapper"]').children().eq(0).contains('connection.connected');
cy.get('[data-testid="connection-status-wrapper"]')
.children()
.eq(1)
.should('have.css', 'background-color', 'rgb(32, 175, 46)');
cy.get('[data-testid="Connected"]');

// check that the connectionStatus is rendered correctly when the connection is closed
cy.wait(10).then(() => {
server.close();
cy.waitUntil(() => !connected).then(() => {
cy.get('[data-testid="connection-status-wrapper"]')
.children()
.eq(0)
.contains('connection.waiting-for-connection');
cy.get('[data-testid="connection-status-wrapper"]')
.children()
.eq(1)
.should('have.css', 'background-color', 'rgb(235, 52, 40)');
cy.get('[data-testid="Disconnected"]');
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/components/ConnectionStatus/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const ConnectionStatus: React.FC = () => {
}
}}
>
<Text status={status}>
<Text status={status} data-testid={status}>
{status === 'Stale'
? t('connection.data-might-be-stale')
: status === 'Connected'
Expand Down
14 changes: 6 additions & 8 deletions src/components/DataHeader/__tests__/DataHeader.test.cypress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ describe('DataHeader test', () => {
<DataHeader items={itemsList} wide={false} />
</TestWrapper>,
);
cy.get('[data-testid="data-header-container"]').should('not.have.css', 'width', '984px');

mount(
<TestWrapper>
<DataHeader items={itemsList} wide={true} />
</TestWrapper>,
);
cy.get('[data-testid="data-header-container"]').should('have.css', 'width', '984px');
cy.get('[data-testid="data-header-element"]').eq(0).contains('Test 1');
cy.get('[data-testid="data-header-element"]').eq(0).contains('test_1');
cy.get('[data-testid="data-header-element"]').eq(1).contains('Test 2');
cy.get('[data-testid="data-header-element"]').eq(1).contains('test_2');
cy.get('[data-testid="data-header-element"]').eq(2).contains('Test 3');
cy.get('[data-testid="data-header-element"]').eq(2).contains('test_3');
});
});
2 changes: 1 addition & 1 deletion src/components/DataHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const DataHeader: React.FC<Props> = ({ items, wide = false }) => {
};

const DataHeaderItem: React.FC<{ label: string; value: React.ReactNode }> = ({ label, value }) => (
<DataHeaderItemContainer>
<DataHeaderItemContainer data-testid="data-header-element">
<DataHeaderItemLabel>{label}</DataHeaderItemLabel>
<div>{value}</div>
</DataHeaderItemContainer>
Expand Down
16 changes: 12 additions & 4 deletions src/components/Timeline/__tests__/TimelineRow.test.cypress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ describe('TimelineRow component', () => {

mount(
<TestWrapper>
<LineElement {...props} />
<div style={{ width: '484px' }}>
<LineElement {...props} />
</div>
</TestWrapper>,
);
// Values of container and boxgraphic should be weird since we are extending timeline over selected value
Expand All @@ -116,7 +118,9 @@ describe('TimelineRow component', () => {
// rendered quite a lot to the left (translateX -100%)
mount(
<TestWrapper>
<LineElement {...props} timeline={createTimelineMetrics({ visibleStartTime: 300, visibleEndTime: 500 })} />
<div style={{ width: '484px' }}>
<LineElement {...props} timeline={createTimelineMetrics({ visibleStartTime: 300, visibleEndTime: 500 })} />
</div>
</TestWrapper>,
);

Expand All @@ -127,7 +131,9 @@ describe('TimelineRow component', () => {
// Same as default graph but alignment is from left so every element should start from left
mount(
<TestWrapper>
<LineElement {...props} timeline={createTimelineMetrics({ sortBy: 'duration' })} />
<div style={{ width: '484px' }}>
<LineElement {...props} timeline={createTimelineMetrics({ sortBy: 'duration' })} />
</div>
</TestWrapper>,
);

Expand All @@ -138,7 +144,9 @@ describe('TimelineRow component', () => {
// Try with unfinished item. No label since bar takes so wide space
mount(
<TestWrapper>
<LineElement {...props} timeline={createTimelineMetrics({})} duration={null} />
<div style={{ width: '484px' }}>
<LineElement {...props} timeline={createTimelineMetrics({})} duration={null} />
</div>
</TestWrapper>,
);

Expand Down
Loading