Skip to content

Commit

Permalink
Fix failing Cypress test
Browse files Browse the repository at this point in the history
- was off by 2.5px on headless vs headed, so tweak widths so it stops doing that

+ explicitly set viewport width (in case the default changes in the future)
  • Loading branch information
cee-chen committed Aug 14, 2023
1 parent 7bacd72 commit 6961e64
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/components/popover/input_popover.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ import { EuiFieldText, EuiTextArea } from '../../components';
import { EuiInputPopover } from './input_popover';

describe('EuiPopover', () => {
// The viewport width matters for position assertions, so ensure it's explicitly defined
beforeEach(() => {
cy.viewport(500, 300);
});

const props = {
input: <EuiFieldText />,
closePopover: () => {},
Expand Down Expand Up @@ -62,13 +67,15 @@ describe('EuiPopover', () => {
<EuiInputPopover
{...props}
display="inline-block"
input={<EuiTextArea rows={1} resize="horizontal" />}
input={
<EuiTextArea rows={1} resize="horizontal" style={{ width: 150 }} />
}
>
Popover content
</EuiInputPopover>
</div>
);
cy.get('[data-popover-panel]').should('have.css', 'left', '155.5px');
cy.get('[data-popover-panel]').should('have.css', 'left', '175px');
cy.wait(100); // Wait a tick, otherwise Cypress returns a false positive

// Cypress doesn't seem to have a way to mimic manual dragging/resizing, so we'll do it programmatically
Expand Down

0 comments on commit 6961e64

Please sign in to comment.