Skip to content

Commit

Permalink
Update failing end-to-end tests
Browse files Browse the repository at this point in the history
Fix `TimeSeriesLineChart.test.jsx`
  • Loading branch information
jamie-suse committed Aug 29, 2024
1 parent 86d350d commit 5b669a2
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ describe('ApiKeySettingsModal', () => {
await user.click(screen.getByRole('button', { name: 'months' }));
await user.click(screen.getByRole('button', { name: 'months' }));


await user.click(await waitFor(() => screen.findByText('Generate')));
await user.click(screen.getByRole('button', { name: 'Generate' }));

const [{ apiKeyExpiration: generatedApiKeyExpiration }] =
onGenerate.mock.lastCall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import { render } from '@testing-library/react';
import TimeSeriesLineChart from './TimeSeriesLineChart';
import '@testing-library/jest-dom';

jest.mock('react-chartjs-2', () => ({
Line: () => <canvas />,
}));

describe('TimeSeriesLineChart component', () => {
it('should raise an error if the datasets are more then 5', () => {
const datasets = [
Expand Down Expand Up @@ -92,7 +96,6 @@ describe('TimeSeriesLineChart component', () => {
</div>
);

const canvas = container.querySelector('canvas');
expect(canvas).toBeDefined();
expect(container.querySelector('canvas')).toBeDefined();
});
});
10 changes: 4 additions & 6 deletions test/e2e/cypress/e2e/host_details.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,12 +459,10 @@ context('Host Details', () => {

cy.get('#headlessui-portal-root').as('modal');

cy.get('@modal')
.find('.w-full')
.should(
'contain.text',
`Clean up data discovered by agent on host ${selectedHost.hostName}`
);
cy.get('@modal').should(
'contain.text',
`Clean up data discovered by agent on host ${selectedHost.hostName}`
);
cy.get('@modal').contains('button', 'Clean up').click();

cy.get('@modal').should('not.exist');
Expand Down
10 changes: 4 additions & 6 deletions test/e2e/cypress/e2e/hosts_overview.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,10 @@ context('Hosts Overview', () => {

cy.get('#headlessui-portal-root').as('modal');

cy.get('@modal')
.find('.w-full')
.should(
'contain.text',
`Clean up data discovered by agent on host ${hostToDeregister.name}`
);
cy.get('@modal').should(
'contain.text',
`Clean up data discovered by agent on host ${hostToDeregister.name}`
);

cy.get('@modal').contains('button', 'Clean up').click();

Expand Down
6 changes: 4 additions & 2 deletions test/e2e/cypress/e2e/users.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ describe('Users', () => {

cy.get('button.totp-selection-dropdown').click();

cy.get('li:contains("Disabled")').click();
cy.contains('div', 'Disabled').click();
cy.contains('button', 'Save').click();

cy.get('div').contains('User edited successfully');
Expand All @@ -397,7 +397,9 @@ describe('Users', () => {

cy.get('button.totp-selection-dropdown').click();

cy.get('ul > li:nth-child(1)')
cy.get(
'div[role="listbox"][data-headlessui-state="open"] > div:nth-child(1)'
)
.invoke('attr', 'aria-disabled')
.should('eq', 'true');
});
Expand Down

0 comments on commit 5b669a2

Please sign in to comment.