2024-01-31 14:35:41 +03:00
|
|
|
/** @file Test the search bar and its suggestions. */
|
|
|
|
import * as test from '@playwright/test'
|
|
|
|
|
|
|
|
import * as backend from '#/services/Backend'
|
|
|
|
|
|
|
|
import * as actions from './actions'
|
|
|
|
|
|
|
|
test.test('tags', async ({ page }) => {
|
|
|
|
await actions.mockAllAndLogin({ page })
|
|
|
|
const searchBarInput = actions.locateSearchBarInput(page)
|
|
|
|
const tags = actions.locateSearchBarTags(page)
|
|
|
|
|
|
|
|
await searchBarInput.click()
|
|
|
|
for (const positiveTag of await tags.all()) {
|
|
|
|
await searchBarInput.selectText()
|
|
|
|
await searchBarInput.press('Backspace')
|
|
|
|
const text = (await positiveTag.textContent()) ?? ''
|
|
|
|
test.expect(text.length).toBeGreaterThan(0)
|
|
|
|
await positiveTag.click()
|
|
|
|
await test.expect(searchBarInput).toHaveValue(text)
|
|
|
|
}
|
|
|
|
|
|
|
|
await page.keyboard.down('Shift')
|
|
|
|
for (const negativeTag of await tags.all()) {
|
|
|
|
await searchBarInput.selectText()
|
|
|
|
await searchBarInput.press('Backspace')
|
|
|
|
const text = (await negativeTag.textContent()) ?? ''
|
|
|
|
test.expect(text.length).toBeGreaterThan(0)
|
|
|
|
await negativeTag.click()
|
|
|
|
await test.expect(searchBarInput).toHaveValue(text)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
test.test('labels', async ({ page }) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
await actions.mockAllAndLogin({
|
|
|
|
page,
|
2024-07-26 09:34:51 +03:00
|
|
|
setupAPI: (api) => {
|
2024-07-16 12:55:45 +03:00
|
|
|
api.addLabel('aaaa', backend.COLORS[0])
|
2024-08-08 15:12:05 +03:00
|
|
|
api.addLabel('bbbb', backend.COLORS[1])
|
|
|
|
api.addLabel('cccc', backend.COLORS[2])
|
|
|
|
api.addLabel('dddd', backend.COLORS[3])
|
2024-07-16 12:55:45 +03:00
|
|
|
},
|
|
|
|
})
|
2024-01-31 14:35:41 +03:00
|
|
|
const searchBarInput = actions.locateSearchBarInput(page)
|
|
|
|
const labels = actions.locateSearchBarLabels(page)
|
|
|
|
|
|
|
|
await searchBarInput.click()
|
|
|
|
for (const label of await labels.all()) {
|
|
|
|
const name = (await label.textContent()) ?? ''
|
|
|
|
test.expect(name.length).toBeGreaterThan(0)
|
|
|
|
await label.click()
|
|
|
|
await test.expect(searchBarInput).toHaveValue('label:' + name)
|
|
|
|
await label.click()
|
|
|
|
await test.expect(searchBarInput).toHaveValue('-label:' + name)
|
|
|
|
await label.click()
|
|
|
|
await test.expect(searchBarInput).toHaveValue('')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
test.test('suggestions', async ({ page }) => {
|
2024-06-25 19:56:14 +03:00
|
|
|
await actions.mockAllAndLogin({
|
|
|
|
page,
|
2024-07-26 09:34:51 +03:00
|
|
|
setupAPI: (api) => {
|
2024-06-25 19:56:14 +03:00
|
|
|
api.addDirectory('foo')
|
|
|
|
api.addProject('bar')
|
|
|
|
api.addSecret('baz')
|
|
|
|
api.addSecret('quux')
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2024-01-31 14:35:41 +03:00
|
|
|
const searchBarInput = actions.locateSearchBarInput(page)
|
|
|
|
const suggestions = actions.locateSearchBarSuggestions(page)
|
|
|
|
|
|
|
|
await searchBarInput.click()
|
2024-06-25 19:56:14 +03:00
|
|
|
|
2024-01-31 14:35:41 +03:00
|
|
|
for (const suggestion of await suggestions.all()) {
|
|
|
|
const name = (await suggestion.textContent()) ?? ''
|
|
|
|
test.expect(name.length).toBeGreaterThan(0)
|
|
|
|
await suggestion.click()
|
|
|
|
await test.expect(searchBarInput).toHaveValue('name:' + name)
|
|
|
|
await searchBarInput.selectText()
|
|
|
|
await searchBarInput.press('Backspace')
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
test.test('suggestions (keyboard)', async ({ page }) => {
|
2024-06-25 19:56:14 +03:00
|
|
|
await actions.mockAllAndLogin({
|
|
|
|
page,
|
2024-07-26 09:34:51 +03:00
|
|
|
setupAPI: (api) => {
|
2024-06-25 19:56:14 +03:00
|
|
|
api.addDirectory('foo')
|
|
|
|
api.addProject('bar')
|
|
|
|
api.addSecret('baz')
|
|
|
|
api.addSecret('quux')
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2024-01-31 14:35:41 +03:00
|
|
|
const searchBarInput = actions.locateSearchBarInput(page)
|
|
|
|
const suggestions = actions.locateSearchBarSuggestions(page)
|
|
|
|
|
|
|
|
await searchBarInput.click()
|
|
|
|
for (const suggestion of await suggestions.all()) {
|
|
|
|
const name = (await suggestion.textContent()) ?? ''
|
|
|
|
test.expect(name.length).toBeGreaterThan(0)
|
Keyboard navigation between components (#9499)
- Close https://github.com/enso-org/cloud-v2/issues/982
- Add keyboard navigation via arrows between different components
- This is achieved by a `Navigator2D` class which keeps track of the closest adjacent elements.
Other changes:
- Switch much of the codebase to use `react-aria-components`
- This *should* (but does not necessarily) give us improved accessibility for free.
- Refactor various common styles into styled components
- `FocusArea` to perform automatic registration with `Navigator2D`
- `Button` and `UnstyledButton` to let buttons participate in keyboard navigation
- `HorizontalMenuBar` - used for buttons below the titles in the Drive page, Keyboard Shortcuts settings page, and Members List settings page
- `SettingsPage` in the settings pages
- `SettingsSection` in the settings page to wrap around `FocusArea` and the heading for each section
- Add debugging utilities
- Add debugging when `body` has the `data-debug` attribute: `document.body.dataset.debug = ''`
- This adds rings around elements (all with different colors):
- That are `FocusArea`s. `FocusArea` is a wrapper component that makes an element participate in `Navigator2D`.
- That are `:focus`ed, and that are `:focus-visible`
- That are `.focus-child`. This is because keyboard navigation via arrows ***ignores*** all focusable elements that are not `.focus-child`.
- Debug `Navigator2D` neighbors when `body` has the `debug-navigator2d` attribute: `document.body.dataset.debugNavigator2d = ''`
- This highlights neighbors of the currently focused element. This is a separate debug option because computing neighbors is potentially quite expensive.
# Important Notes
- :warning: Modals and the authentication flow are not yet fully tested.
- Up+Down to navigate through suggestions has been disabled to improve UX when accidentally navigating upwards to the assets search bar.
- There are a number of *known* issues with keyboard navigation. For the most part it's because a proper solution will be quite difficult.
- Focus is lost when a column (from the extra columns selector) is toggled - because the button stops existing
- It's not possible to navigate to the icons on the assets table - so it's current not possible to *hide* columns via the keyboard
- Neighbors of the extra columns selector are not ideal (both when it is being navigated from, and when it is being navigated to)
- The suggestions in the `AssetSearchBar` aren't *quite* fully integrated with arrow keyboard navigation.
- This is *semi*-intentional. I think it makes a lot more sense to integrate them in, *however* it stays like this for now largely because I think pressing `ArrowUp` then `ArrowDown` from the assets table should return to the assets table
- Likewise for the assets table. The reason here, however, is because we want multi-select. While `react-aria-components` has lists which support multi-select, it doesn't allow programmatic focus control, making it not particularly ideal, as we want to focus the topmost element when navigating in from above.
- Clicking on the "New Folder" icon (and the like) do not focus on the newly created child. This one should be pretty easy to do, but I'm not sure whether it's the right thing to do.
2024-04-05 10:21:02 +03:00
|
|
|
await page.press('body', 'ArrowDown')
|
2024-01-31 14:35:41 +03:00
|
|
|
await test.expect(searchBarInput).toHaveValue('name:' + name)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
test.test('complex flows', async ({ page }) => {
|
|
|
|
const firstName = 'foo'
|
2024-06-25 19:56:14 +03:00
|
|
|
|
|
|
|
await actions.mockAllAndLogin({
|
|
|
|
page,
|
2024-07-26 09:34:51 +03:00
|
|
|
setupAPI: (api) => {
|
2024-06-25 19:56:14 +03:00
|
|
|
api.addDirectory(firstName)
|
|
|
|
api.addProject('bar')
|
|
|
|
api.addSecret('baz')
|
|
|
|
api.addSecret('quux')
|
|
|
|
},
|
|
|
|
})
|
|
|
|
const searchBarInput = actions.locateSearchBarInput(page)
|
2024-01-31 14:35:41 +03:00
|
|
|
|
|
|
|
await searchBarInput.click()
|
Keyboard navigation between components (#9499)
- Close https://github.com/enso-org/cloud-v2/issues/982
- Add keyboard navigation via arrows between different components
- This is achieved by a `Navigator2D` class which keeps track of the closest adjacent elements.
Other changes:
- Switch much of the codebase to use `react-aria-components`
- This *should* (but does not necessarily) give us improved accessibility for free.
- Refactor various common styles into styled components
- `FocusArea` to perform automatic registration with `Navigator2D`
- `Button` and `UnstyledButton` to let buttons participate in keyboard navigation
- `HorizontalMenuBar` - used for buttons below the titles in the Drive page, Keyboard Shortcuts settings page, and Members List settings page
- `SettingsPage` in the settings pages
- `SettingsSection` in the settings page to wrap around `FocusArea` and the heading for each section
- Add debugging utilities
- Add debugging when `body` has the `data-debug` attribute: `document.body.dataset.debug = ''`
- This adds rings around elements (all with different colors):
- That are `FocusArea`s. `FocusArea` is a wrapper component that makes an element participate in `Navigator2D`.
- That are `:focus`ed, and that are `:focus-visible`
- That are `.focus-child`. This is because keyboard navigation via arrows ***ignores*** all focusable elements that are not `.focus-child`.
- Debug `Navigator2D` neighbors when `body` has the `debug-navigator2d` attribute: `document.body.dataset.debugNavigator2d = ''`
- This highlights neighbors of the currently focused element. This is a separate debug option because computing neighbors is potentially quite expensive.
# Important Notes
- :warning: Modals and the authentication flow are not yet fully tested.
- Up+Down to navigate through suggestions has been disabled to improve UX when accidentally navigating upwards to the assets search bar.
- There are a number of *known* issues with keyboard navigation. For the most part it's because a proper solution will be quite difficult.
- Focus is lost when a column (from the extra columns selector) is toggled - because the button stops existing
- It's not possible to navigate to the icons on the assets table - so it's current not possible to *hide* columns via the keyboard
- Neighbors of the extra columns selector are not ideal (both when it is being navigated from, and when it is being navigated to)
- The suggestions in the `AssetSearchBar` aren't *quite* fully integrated with arrow keyboard navigation.
- This is *semi*-intentional. I think it makes a lot more sense to integrate them in, *however* it stays like this for now largely because I think pressing `ArrowUp` then `ArrowDown` from the assets table should return to the assets table
- Likewise for the assets table. The reason here, however, is because we want multi-select. While `react-aria-components` has lists which support multi-select, it doesn't allow programmatic focus control, making it not particularly ideal, as we want to focus the topmost element when navigating in from above.
- Clicking on the "New Folder" icon (and the like) do not focus on the newly created child. This one should be pretty easy to do, but I'm not sure whether it's the right thing to do.
2024-04-05 10:21:02 +03:00
|
|
|
await page.press('body', 'ArrowDown')
|
2024-01-31 14:35:41 +03:00
|
|
|
await test.expect(searchBarInput).toHaveValue('name:' + firstName)
|
|
|
|
await searchBarInput.selectText()
|
|
|
|
await searchBarInput.press('Backspace')
|
|
|
|
await test.expect(searchBarInput).toHaveValue('')
|
Keyboard navigation between components (#9499)
- Close https://github.com/enso-org/cloud-v2/issues/982
- Add keyboard navigation via arrows between different components
- This is achieved by a `Navigator2D` class which keeps track of the closest adjacent elements.
Other changes:
- Switch much of the codebase to use `react-aria-components`
- This *should* (but does not necessarily) give us improved accessibility for free.
- Refactor various common styles into styled components
- `FocusArea` to perform automatic registration with `Navigator2D`
- `Button` and `UnstyledButton` to let buttons participate in keyboard navigation
- `HorizontalMenuBar` - used for buttons below the titles in the Drive page, Keyboard Shortcuts settings page, and Members List settings page
- `SettingsPage` in the settings pages
- `SettingsSection` in the settings page to wrap around `FocusArea` and the heading for each section
- Add debugging utilities
- Add debugging when `body` has the `data-debug` attribute: `document.body.dataset.debug = ''`
- This adds rings around elements (all with different colors):
- That are `FocusArea`s. `FocusArea` is a wrapper component that makes an element participate in `Navigator2D`.
- That are `:focus`ed, and that are `:focus-visible`
- That are `.focus-child`. This is because keyboard navigation via arrows ***ignores*** all focusable elements that are not `.focus-child`.
- Debug `Navigator2D` neighbors when `body` has the `debug-navigator2d` attribute: `document.body.dataset.debugNavigator2d = ''`
- This highlights neighbors of the currently focused element. This is a separate debug option because computing neighbors is potentially quite expensive.
# Important Notes
- :warning: Modals and the authentication flow are not yet fully tested.
- Up+Down to navigate through suggestions has been disabled to improve UX when accidentally navigating upwards to the assets search bar.
- There are a number of *known* issues with keyboard navigation. For the most part it's because a proper solution will be quite difficult.
- Focus is lost when a column (from the extra columns selector) is toggled - because the button stops existing
- It's not possible to navigate to the icons on the assets table - so it's current not possible to *hide* columns via the keyboard
- Neighbors of the extra columns selector are not ideal (both when it is being navigated from, and when it is being navigated to)
- The suggestions in the `AssetSearchBar` aren't *quite* fully integrated with arrow keyboard navigation.
- This is *semi*-intentional. I think it makes a lot more sense to integrate them in, *however* it stays like this for now largely because I think pressing `ArrowUp` then `ArrowDown` from the assets table should return to the assets table
- Likewise for the assets table. The reason here, however, is because we want multi-select. While `react-aria-components` has lists which support multi-select, it doesn't allow programmatic focus control, making it not particularly ideal, as we want to focus the topmost element when navigating in from above.
- Clicking on the "New Folder" icon (and the like) do not focus on the newly created child. This one should be pretty easy to do, but I'm not sure whether it's the right thing to do.
2024-04-05 10:21:02 +03:00
|
|
|
await page.press('body', 'ArrowDown')
|
2024-01-31 14:35:41 +03:00
|
|
|
await test.expect(searchBarInput).toHaveValue('name:' + firstName)
|
|
|
|
})
|