Skip to content

Commit

Permalink
test(FluidDropdown): add e2e, api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tw15egan committed Sep 22, 2022
1 parent 3d46fee commit f10956a
Show file tree
Hide file tree
Showing 4 changed files with 154 additions and 239 deletions.
37 changes: 37 additions & 0 deletions e2e/components/FluidDropdown/FluidDropdown-test.e2e.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright IBM Corp. 2022
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/

'use strict';

const { expect, test } = require('@playwright/test');
const { themes } = require('../../test-utils/env');
const { snapshotStory, visitStory } = require('../../test-utils/storybook');

test.describe('FluidDropdown', () => {
themes.forEach((theme) => {
test.describe(theme, () => {
test('fluid dropdown @vrt', async ({ page }) => {
await snapshotStory(page, {
component: 'FluidDropdown',
id: 'experimental-unstable-fluiddropdown--default',
theme,
});
});
});
});

test('accessibility-checker @avt', async ({ page }) => {
await visitStory(page, {
component: 'FluidDropdown',
id: 'experimental-unstable-fluiddropdown--default',
globals: {
theme: 'white',
},
});
await expect(page).toHaveNoACViolations('FluidDropdown');
});
});
9 changes: 6 additions & 3 deletions packages/react/src/components/FluidDropdown/FluidDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ import Dropdown from '../Dropdown';
import { usePrefix } from '../../internal/usePrefix';
import { FormContext } from '../FluidForm/FormContext';

function FluidDropdown({ className, isCondensed, ...other }) {
const FluidDropdown = React.forwardRef(function FluidDropdown(
{ className, isCondensed, ...other },
ref
) {
const prefix = usePrefix();
const classNames = classnames(
`${prefix}--dropdown__wrapper--fluid`,
Expand All @@ -22,10 +25,10 @@ function FluidDropdown({ className, isCondensed, ...other }) {

return (
<FormContext.Provider value={{ isFluid: true }}>
<Dropdown className={classNames} {...other} />
<Dropdown ref={ref} className={classNames} {...other} />
</FormContext.Provider>
);
}
});

FluidDropdown.propTypes = {
/**
Expand Down
Loading

0 comments on commit f10956a

Please sign in to comment.