field-options-popup.test.mjs 1.6 KB
/**
 * field-options-popup — 弹框打开是否 bypass 缓存
 */
import { describe, it } from 'node:test'
import assert from 'node:assert/strict'
import { createRequire } from 'node:module'

const require = createRequire(import.meta.url)
const {
	isRemoteFieldOptionsKey,
	shouldRefreshOptionsOnPopup,
	isEmployeeListPickerSearchable
} = require('../utils/field-options-popup.js')

describe('field-options-popup', () => {
	it('IT-FIELD-OPT-008: shouldRefreshOptionsOnPopup for remote select keys', () => {
		assert.equal(shouldRefreshOptionsOnPopup({ optionsKey: 'orderList' }), true)
		assert.equal(shouldRefreshOptionsOnPopup({ optionsKey: 'storeStaffList' }), true)
		assert.equal(shouldRefreshOptionsOnPopup({ optionsKey: '4sStaffList' }), true)
		assert.equal(shouldRefreshOptionsOnPopup({ optionsKey: 'unknownKey' }), false)
		assert.equal(shouldRefreshOptionsOnPopup({}), false)
	})

	it('IT-FIELD-OPT-008c: isEmployeeListPickerSearchable for staff list keys', () => {
		assert.equal(isEmployeeListPickerSearchable('storeStaffList'), true)
		assert.equal(isEmployeeListPickerSearchable('4sStaffList'), true)
		assert.equal(isEmployeeListPickerSearchable('orderList'), false)
		assert.equal(isEmployeeListPickerSearchable(''), false)
	})

	it("IT-FIELD-OPT-008d: optionsKey 'options' keeps template options local", () => {
		assert.equal(isRemoteFieldOptionsKey('orderList'), true)
		assert.equal(isRemoteFieldOptionsKey('storeStaffList'), true)
		assert.equal(isRemoteFieldOptionsKey('4sStaffList'), true)
		assert.equal(isRemoteFieldOptionsKey('options'), false)
		assert.equal(isRemoteFieldOptionsKey('unknownKey'), false)
	})
})