Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
leagrdv committed Dec 27, 2024
1 parent d667c86 commit 21597e1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 36 deletions.
49 changes: 14 additions & 35 deletions packages/components/cypress/e2e/megadropdown.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ const MEGADROPDOWN_ID = '212efc4e-875b-4497-912d-d28c6baf32f5';

describe('megadropdown', () => {
describe('default', () => {
describe('mobile', () => {
describe('desktop', () => {
beforeEach(() => {
cy.viewport('iphone-6+');
cy.viewport(1920, 1080);
cy.getComponents(
MEGADROPDOWN_ID,
'tests',
Expand All @@ -24,33 +24,29 @@ describe('megadropdown', () => {
it('should open on trigger click', () => {
cy.get('@megadropdown-trigger').should('exist');
cy.get('@megadropdown-trigger').click();
cy.wait(500);
cy.get('@megadropdown').should(`be.visible`);
});

it('should show back button', () => {
it('should show close button', () => {
cy.get('@megadropdown-trigger').click();
cy.wait(500);
cy.get('@back-btn').should(`be.visible`);
cy.get('@close-btn').should(`be.visible`);
});

it('should not show close button', () => {
it('should not show back button', () => {
cy.get('@megadropdown-trigger').click();
cy.wait(500);
cy.get('@close-btn').should(`be.hidden`);
cy.get('@back-btn').should(`be.hidden`);
});

it('should close on back button click', () => {
it('should close on close button click', () => {
cy.get('@megadropdown-trigger').click();
cy.get('@back-btn').click();
cy.wait(500);
cy.get('@close-btn').click();
cy.get('@megadropdown').should(`be.hidden`);
});
});

describe('desktop', () => {
describe('mobile', () => {
beforeEach(() => {
cy.viewport(1920, 1080);
cy.viewport(500, 1200);
cy.getComponents(
MEGADROPDOWN_ID,
'tests',
Expand All @@ -61,36 +57,19 @@ describe('megadropdown', () => {
cy.get('@megadropdown').find('.close-button').as('close-btn');
});

it('should render', () => {
cy.get('@megadropdown').should('exist');
cy.get('@megadropdown-trigger').should('exist');
cy.get('@megadropdown').should(`be.hidden`);
});

it('should open on trigger click', () => {
cy.get('@megadropdown-trigger').should('exist');
cy.get('@megadropdown-trigger').click();
cy.wait(500);
cy.get('@megadropdown').should(`be.visible`);
});

it('should show close button', () => {
cy.get('@megadropdown-trigger').click();
cy.wait(500);
cy.get('@close-btn').should(`be.visible`);
});

it('should not show back button', () => {
it('should show back button', () => {
cy.get('@megadropdown-trigger').click();
cy.wait(500);
cy.get('@back-btn').should(`be.hidden`);
cy.get('@back-btn').should(`be.visible`);
});

it('should close on close button click', () => {
it('should not show close button', () => {
cy.get('@megadropdown-trigger').click();
cy.get('@close-btn').click();
cy.wait(500);
cy.get('@megadropdown').should(`be.hidden`);
cy.get('@close-btn').should(`be.hidden`);
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class PostMegadropdown {

private handleFocusout(event: FocusEvent) {
const relatedTarget = event.relatedTarget as HTMLElement;
const megadropdown= this.popoverRef.querySelector('.megadropdown');
const megadropdown = this.popoverRef.querySelector('.megadropdown');
if (!megadropdown.contains(relatedTarget)) {
this.hide();
}
Expand Down

0 comments on commit 21597e1

Please sign in to comment.