-
Notifications
You must be signed in to change notification settings - Fork 46
Update UI deps pt. 1 #864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Update UI deps pt. 1 #864
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
22.12.0 | ||
22.17.0 | ||
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
// Copyright (C) 2022-2025 Intel Corporation | ||
// LIMITED EDGE SOFTWARE DISTRIBUTION LICENSE | ||
|
||
import { fireEvent, screen } from '@testing-library/react'; | ||
import { userEvent } from '@testing-library/user-event'; | ||
import { screen } from '@testing-library/react'; | ||
import { User } from '@react-aria/test-utils'; | ||
import { useNavigate } from 'react-router-dom'; | ||
|
||
import { DOMAIN } from '../../../../../../core/projects/core.interface'; | ||
import { createInMemoryProjectService } from '../../../../../../core/projects/services/in-memory-project-service'; | ||
import { getMockedDatasetIdentifier } from '../../../../../../test-utils/mocked-items-factory/mocked-identifiers'; | ||
import { getMockedProject } from '../../../../../../test-utils/mocked-items-factory/mocked-project'; | ||
import { getMockedTask } from '../../../../../../test-utils/mocked-items-factory/mocked-tasks'; | ||
import { simulateDesktop } from '../../../../../../test-utils/utils'; | ||
import { useDataset } from '../../../../providers/dataset-provider/dataset-provider.component'; | ||
import { annotatorRender } from '../../../../test-utils/annotator-render'; | ||
import { DatasetPicker } from './dataset-picker.component'; | ||
|
@@ -29,6 +30,16 @@ jest.mock('react-router-dom', () => ({ | |
})); | ||
|
||
describe('DatasetPicker', () => { | ||
const testUtilUser = new User(); | ||
|
||
beforeAll(() => { | ||
simulateDesktop(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function sets the view's height and width. It is required due to the picker's virtualization. |
||
}); | ||
|
||
afterAll(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
const mockUseDataset = (isInActiveMode = true) => { | ||
// @ts-expect-error We're only interested in mocking properties used by DatasetPicker | ||
jest.mocked(useDataset).mockImplementation(() => ({ | ||
|
@@ -49,12 +60,11 @@ describe('DatasetPicker', () => { | |
|
||
expect(screen.queryByRole('option', { hidden: true, name: 'Active set', selected: true })).toBeInTheDocument(); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: /Choose annotation dataset/ })); | ||
const picker = screen.getByRole('button', { name: /Choose annotation dataset/ }); | ||
const selectTester = testUtilUser.createTester('Select', { root: picker }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to the documentation, this is the recommended way to interact with the picker https://react-spectrum.adobe.com/react-spectrum/Picker.html#testing |
||
|
||
await userEvent.selectOptions( | ||
screen.getByRole('listbox'), | ||
screen.getByRole('option', { name: 'In memory dataset' }) | ||
); | ||
await selectTester.open(); | ||
await selectTester.selectOption({ option: 'In memory dataset' }); | ||
|
||
expect(mockPush).toHaveBeenCalledWith( | ||
'/organizations/organization-id/workspaces/workspace-id/projects/project-id/datasets/in-memory-dataset/annotator' | ||
|
@@ -68,9 +78,11 @@ describe('DatasetPicker', () => { | |
|
||
await annotatorRender(<DatasetPicker />, { datasetIdentifier }); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: /Choose annotation dataset/ })); | ||
const picker = screen.getByRole('button', { name: /Choose annotation dataset/ }); | ||
const selectTester = testUtilUser.createTester('Select', { root: picker }); | ||
|
||
await userEvent.selectOptions(screen.getByRole('listbox'), screen.getByRole('option', { name: 'Active set' })); | ||
await selectTester.open(); | ||
await selectTester.selectOption({ option: 'Active set' }); | ||
|
||
expect(mockPush).toHaveBeenCalledWith( | ||
'/organizations/organization-id/workspaces/workspace-id/projects/project-id/datasets/in-memory-dataset/annotator?active=true' | ||
|
@@ -89,9 +101,11 @@ describe('DatasetPicker', () => { | |
], | ||
}); | ||
|
||
fireEvent.click(screen.getByRole('button', { name: /Choose annotation dataset/ })); | ||
const picker = screen.getByRole('button', { name: /Choose annotation dataset/ }); | ||
const selectTester = testUtilUser.createTester('Select', { root: picker }); | ||
|
||
await userEvent.selectOptions(screen.getByRole('listbox'), screen.getByRole('option', { name: 'Active set' })); | ||
await selectTester.open(); | ||
await selectTester.selectOption({ option: 'Active set' }); | ||
|
||
expect(mockPush).toHaveBeenCalledWith( | ||
'/organizations/organization-id/workspaces/workspace-id/projects/project-id/datasets/in-memory-dataset/annotator?task_id=task&active=true' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: why this change?