Skip to content
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

494910 deploy auto complete #690

Merged
merged 10 commits into from
Jan 15, 2025
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module.exports = {
rules: {
// Allow Jest to assert on mocked unbound methods
'@typescript-eslint/unbound-method': 'off',
'jest/unbound-method': 'error',
'jest/unbound-method': 'off',
// Allow custom expect functions in tests, that start with expect
'jest/expect-expect': [
'error',
Expand Down
58 changes: 0 additions & 58 deletions src/client/common/helpers/populate-autocomplete-suggestions.js

This file was deleted.

4 changes: 0 additions & 4 deletions src/client/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { initModule } from '~/src/client/common/helpers/init-module.js'
import { inputAssistant } from '~/src/server/common/components/input-assistant/input-assistant.js'
import { paramsToHiddenInputs } from '~/src/client/common/helpers/params-to-hidden-inputs.js'
import { poll } from '~/src/client/common/helpers/poll.js'
import { populateAutocompleteSuggestions } from '~/src/client/common/helpers/populate-autocomplete-suggestions.js'
import { populateSelectOptions } from '~/src/client/common/helpers/populate-select-options.js'
import { protectForm } from '~/src/client/common/helpers/protect-form/index.js'
import { search } from '~/src/server/common/components/search/search.js'
Expand Down Expand Up @@ -61,9 +60,6 @@ initModule('app-search', search)
initClass('app-autocomplete', Autocomplete)
initClass('app-autocomplete-advanced', AutocompleteAdvanced)

// Populate autocomplete from a separate controller input
initModule('app-autocomplete-controller', populateAutocompleteSuggestions)

// Xhr Container
initModule('app-xhr-subscriber', xhrSubscriber)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { renderTestComponent } from '~/test-helpers/component-helpers.js'
import { AutocompleteAdvanced } from '~/src/server/common/components/autocomplete/autocomplete-advanced.js'
import { publish } from '~/src/client/common/helpers/event-emitter.js'
import { defaultOption } from '~/src/server/common/helpers/options/default-option.js'
import { enterValue, pressEnter } from '~/test-helpers/keyboard.js'

describe('#autocomplete-advanced', () => {
let autocompleteInput
Expand Down Expand Up @@ -165,9 +166,7 @@ describe('#autocomplete-advanced', () => {
describe('When partial value', () => {
describe('Entered into input', () => {
beforeEach(() => {
autocompleteInput.focus()
autocompleteInput.value = 'abb'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'abb')
})

test('Should open suggestions', () => {
Expand All @@ -187,9 +186,7 @@ describe('#autocomplete-advanced', () => {

describe('That matches multiple suggestions is entered into input', () => {
beforeEach(() => {
autocompleteInput.focus()
autocompleteInput.value = 'ro'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'ro')
})

test('Should open suggestions', () => {
Expand Down Expand Up @@ -228,9 +225,7 @@ describe('#autocomplete-advanced', () => {

describe('With exact match entered into input', () => {
beforeEach(() => {
autocompleteInput.focus()
autocompleteInput.value = 'Barbie'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'Barbie')
})

test('Should show all suggestions', () => {
Expand All @@ -253,9 +248,7 @@ describe('#autocomplete-advanced', () => {

describe('With hint text entered into input', () => {
beforeEach(() => {
autocompleteInput.focus()
autocompleteInput.value = 'Id: 556'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'Id: 556')
suggestionsContainer.children[0].click()
})

Expand All @@ -282,15 +275,11 @@ describe('#autocomplete-advanced', () => {

describe('When value removed from input', () => {
beforeEach(() => {
autocompleteInput.focus()

// Add value to input
autocompleteInput.value = 'fro'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'fro')

// Remove value from input
autocompleteInput.value = ''
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, '')
})

test('Suggestions should be open', () => {
Expand All @@ -311,9 +300,7 @@ describe('#autocomplete-advanced', () => {

describe('When value without results entered into input', () => {
beforeEach(() => {
autocompleteInput.focus()
autocompleteInput.value = 'blah'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'blah')
})

test('Should open suggestions', () => {
Expand All @@ -331,9 +318,7 @@ describe('#autocomplete-advanced', () => {

describe('When no results message is clicked', () => {
beforeEach(() => {
autocompleteInput.focus()
autocompleteInput.value = 'ranDom'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'ranDom')
suggestionsContainer.children[0].click()
})

Expand Down Expand Up @@ -459,10 +444,7 @@ describe('#autocomplete-advanced', () => {
autocompleteInput.dispatchEvent(arrowDownKeyEvent)
autocompleteInput.dispatchEvent(arrowDownKeyEvent)

const enterKeyEvent = new KeyboardEvent('keydown', {
code: 'enter'
})
autocompleteInput.dispatchEvent(enterKeyEvent)
pressEnter(autocompleteInput)
})

test('Should provide expected suggestion value', () => {
Expand Down Expand Up @@ -604,16 +586,8 @@ describe('#autocomplete-advanced', () => {

describe('When keyboard "enter" key is pressed with input value', () => {
beforeEach(() => {
autocompleteInput.focus()

// Add value to input
autocompleteInput.value = 'fro'
autocompleteInput.dispatchEvent(new Event('input'))

const enterKeyEvent = new KeyboardEvent('keydown', {
code: 'enter'
})
autocompleteInput.dispatchEvent(enterKeyEvent)
enterValue(autocompleteInput, 'fro')
pressEnter(autocompleteInput)
})

test('Suggestions should be closed', () => {
Expand All @@ -624,16 +598,8 @@ describe('#autocomplete-advanced', () => {

describe('When keyboard "enter" key is pressed with matching input value', () => {
beforeEach(() => {
autocompleteInput.focus()

// Add value to input
autocompleteInput.value = 'RoboCop'
autocompleteInput.dispatchEvent(new Event('input'))

const enterKeyEvent = new KeyboardEvent('keydown', {
code: 'enter'
})
autocompleteInput.dispatchEvent(enterKeyEvent)
enterValue(autocompleteInput, 'RoboCop')
pressEnter(autocompleteInput)
})

test('Suggestions should be closed', () => {
Expand Down Expand Up @@ -701,10 +667,7 @@ describe('#autocomplete-advanced', () => {
})
autocompleteInput.dispatchEvent(escapeKeyEvent)

const enterKeyEvent = new KeyboardEvent('keydown', {
code: 'enter'
})
autocompleteInput.dispatchEvent(enterKeyEvent)
pressEnter(autocompleteInput)
})

test('Suggestions should be open', () => {
Expand Down Expand Up @@ -819,10 +782,7 @@ describe('#autocomplete-advanced', () => {

describe('With publish event', () => {
test('Should reset autocomplete', () => {
// enter value into autocomplete
autocompleteInput.focus()
autocompleteInput.value = 'Run get to the chopper'
autocompleteInput.dispatchEvent(new Event('input'))
enterValue(autocompleteInput, 'Run get to the chopper')

// select first suggestion
suggestionsContainer.children[0].click()
Expand Down
Loading
Loading