Skip to content

Commit

Permalink
fix(tooltip): remove useless test and fix closeSurface call
Browse files Browse the repository at this point in the history
  • Loading branch information
dpellier committed Dec 21, 2023
1 parent 9cc4afe commit f15f4d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ describe('e2e:osds-tooltip', () => {

async function isTooltipVisible(): Promise<boolean> {
return page.evaluate(() => {
return !! document.querySelector('osds-tooltip')?.shadowRoot?.querySelector('.ocdk-surface--open');
return !!document.querySelector('osds-tooltip')?.shadowRoot?.querySelector('.ocdk-surface--open');
});
}

Expand Down Expand Up @@ -47,14 +47,13 @@ describe('e2e:osds-tooltip', () => {
it('should close the tooltip', async() => {
await setup();

await el.click();
await page.waitForChanges();
await page.mouse.move(5, 5);
await page.waitForTimeout(500); // wait for debounce to resolve
expect(await isTooltipVisible()).toBe(true);

await el.callMethod('closeSurface');
await page.waitForChanges();

expect(await isTooltipVisible()).toBe(true);
expect(await isTooltipVisible()).toBe(false);
});
});

Expand Down Expand Up @@ -106,15 +105,4 @@ describe('e2e:osds-tooltip', () => {

expect(await isTooltipVisible()).toBe(false);
});

it('should close the tooltip on outside click', async() => {
await setup({ extraContent: '<button>Outside element</button>' });
const outsideElement = await page.find('button');

await el.click();
expect(await isTooltipVisible()).toBe(true);

await outsideElement.click();
expect(await isTooltipVisible()).toBe(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ import type { ODS_TOOLTIP_VARIANT } from './constants/tooltip-variant';
import type { OdsTooltipAttribute } from './interfaces/attributes';
import type { OdsTooltipMethod } from './interfaces/methods';
import type { HTMLStencilElement } from '@stencil/core/internal';

import { OcdkSurface, ocdkDefineCustomElements, ocdkIsSurface } from '@ovhcloud/ods-cdk';
import { odsDebounce } from '@ovhcloud/ods-common-core';
import { Component, Element, Host, Listen, State, h } from '@stencil/core';
import { Method, Prop } from '@stencil/core/internal';

import { DEFAULT_ATTRIBUTE } from './constants/default-attributes';
import { OdsTooltipController } from './core/controller';



// define custom elements from CDK
ocdkDefineCustomElements();

/**
Expand Down
11 changes: 5 additions & 6 deletions packages/components/src/tooltip/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<body>

<div>
<p>Default</p>
<h1>Default</h1>

<osds-tooltip>
<osds-tooltip-content slot="tooltip-content">
Expand All @@ -28,7 +28,8 @@
</div>

<div>
<p>osds-text and osds-icon</p>
<h1>osds-text and osds-icon</h1>

<osds-tooltip>
<osds-tooltip-content slot="tooltip-content">
<osds-text color="text" size="400">Lorem ispum...</osds-text>
Expand All @@ -40,7 +41,7 @@
</div>

<div>
<p>Variant tip</p>
<h1>Variant tip</h1>

<osds-tooltip variant="tip">
<osds-tooltip-content slot="tooltip-content">
Expand All @@ -52,16 +53,14 @@
</div>

<div>
<p>No Slot</p>
<h1>No Slot</h1>

<osds-tooltip id="tooltip-slot">
not slot
</osds-tooltip>
<button id="add-slot">click to add slot</button>

</div>


<script>
const button = document.querySelector('#add-slot');
const tooltip = document.querySelector('#tooltip-slot');
Expand Down

0 comments on commit f15f4d6

Please sign in to comment.