Skip to content

Commit 73de096

Browse files
committed
update tests
1 parent 1e63dfe commit 73de096

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

packages/boxel-ui/addon/src/components/accordion/item/index.gts

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@ import type { TemplateOnlyComponent } from '@ember/component/template-only';
22
import { on } from '@ember/modifier';
33

44
import cn from '../../../helpers/cn.ts';
5+
import optional from '../../../helpers/optional.ts';
56
import DropdownArrowDown from '../../../icons/dropdown-arrow-down.gts';
67

78
export interface AccordionItemSignature {
89
Args: {
910
className?: string;
1011
contentClass?: string;
1112
isOpen: boolean;
12-
onClick: (event: MouseEvent) => void;
13+
onClick?: (event: MouseEvent) => void;
1314
};
1415
Blocks: {
1516
content: [];
@@ -20,7 +21,11 @@ export interface AccordionItemSignature {
2021

2122
const AccordionItem: TemplateOnlyComponent<AccordionItemSignature> = <template>
2223
<div class={{cn 'accordion-item' @className open=@isOpen}} ...attributes>
23-
<button class='title' {{on 'click' @onClick}}>
24+
<button
25+
class='title'
26+
{{on 'click' (optional @onClick)}}
27+
disabled={{if @onClick false true}}
28+
>
2429
<DropdownArrowDown class='caret' width='12' height='12' />
2530
{{yield to='title'}}
2631
</button>
@@ -62,13 +67,14 @@ const AccordionItem: TemplateOnlyComponent<AccordionItemSignature> = <template>
6267
align-items: center;
6368
gap: var(--boxel-sp-xxs);
6469
padding: var(--accordion-item-title-padding);
70+
color: inherit;
6571
font: var(--accordion-item-title-font);
6672
letter-spacing: var(--accordion-item-title-letter-spacing);
6773
background-color: transparent;
6874
border: none;
6975
text-align: left;
7076
}
71-
.title:hover {
77+
.title:hover:not(:disabled) {
7278
cursor: pointer;
7379
}
7480
.caret {

packages/host/app/components/operator-mode/code-submode.gts

+2-4
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,7 @@ export default class CodeSubmode extends Component<Signature> {
493493
}
494494

495495
get showSpecPreview() {
496-
return (
497-
this.selectedAccordionItem === 'spec-preview' &&
498-
Boolean(this.selectedCardOrField?.exportName)
499-
);
496+
return Boolean(this.selectedCardOrField?.exportName);
500497
}
501498

502499
private get itemToDeleteAsCard() {
@@ -1090,6 +1087,7 @@ export default class CodeSubmode extends Component<Signature> {
10901087
class='accordion-item'
10911088
@contentClass='accordion-item-content'
10921089
@isOpen={{true}}
1090+
data-test-module-error-panel
10931091
>
10941092
<:title>
10951093
<SchemaEditorTitle @hasModuleError={{true}} />

packages/host/tests/acceptance/code-submode-test.ts

+22-15
Original file line numberDiff line numberDiff line change
@@ -855,18 +855,16 @@ module('Acceptance | code submode tests', function (_hooks) {
855855
submode: 'code',
856856
codePath: `${testRealmURL}broken.gts`,
857857
})!;
858-
859858
await visit(
860859
`/?operatorModeEnabled=true&operatorModeState=${encodeURIComponent(
861860
operatorModeStateParam,
862861
)}`,
863862
);
864-
865863
await waitFor('[data-test-syntax-error]');
866-
867864
assert
868865
.dom('[data-test-syntax-error]')
869866
.includesText('/broken.gts: Missing semicolon. (1:4)');
867+
assert.dom('[data-test-module-error-panel] > button').isDisabled();
870868
});
871869

872870
test('it shows card preview errors', async function (assert) {
@@ -1790,41 +1788,50 @@ module('Acceptance | code submode tests', function (_hooks) {
17901788
assert
17911789
.dom('[data-test-selected-accordion-item="schema-editor"]')
17921790
.exists('defaults to schema-editor view');
1793-
await click('[data-test-accordion-item="spec-preview"] > button'); // select spec panel
1791+
await click('[data-test-accordion-item="playground"] > button');
1792+
assert.dom('[data-test-selected-accordion-item="playground"]').exists();
17941793

17951794
await click('[data-test-file-browser-toggle]');
17961795
await click('[data-test-file="address.gts"]');
17971796
assert.dom('[data-test-selected-accordion-item="spec-preview"]').exists();
17981797
assert.dom('[data-test-accordion-item="spec-preview"]').hasClass('open');
1798+
await click('[data-test-accordion-item="spec-preview"] > button');
1799+
assert
1800+
.dom('[data-test-selected-accordion-item="playground"]')
1801+
.exists('closing the final panel opens the previous panel');
17991802

18001803
await click('[data-test-file="country.gts"]');
18011804
assert.dom('[data-test-rhs-panel="card-or-field"]').exists();
1802-
assert.dom('[data-test-selected-accordion-item]').doesNotExist();
1803-
await click('[data-test-accordion-item="playground"] > button'); // open playground
1804-
assert.dom('[data-test-selected-accordion-item="playground"]').exists();
1805+
assert
1806+
.dom('[data-test-selected-accordion-item="schema-editor"]')
1807+
.exists();
1808+
await click('[data-test-accordion-item="spec-preview"] > button'); // open spec preview
1809+
assert.dom('[data-test-selected-accordion-item="spec-preview"]').exists();
18051810

18061811
await click('[data-test-file="person.gts"]');
18071812
assert
18081813
.dom('[data-test-selected-accordion-item="schema-editor"]')
18091814
.exists();
1810-
await click('[data-test-accordion-item="schema-editor"] > button'); // close schema-editor panel
1811-
assert.dom('[data-test-rhs-panel="card-or-field"]').exists();
1812-
assert.dom('[data-test-selected-accordion-item]').doesNotExist();
18131815

18141816
await click('[data-test-file="pet-person.gts"]');
18151817
assert.dom('[data-test-selected-accordion-item="playground"]').exists();
1818+
await click('[data-test-accordion-item="playground"] > button'); // toggle playground closed
1819+
assert.dom('[data-test-rhs-panel="card-or-field"]').exists();
1820+
assert
1821+
.dom('[data-test-selected-accordion-item="spec-preview"]')
1822+
.exists('closing panel toggles next panel open');
18161823

18171824
let currentSelections = window.localStorage.getItem(
18181825
CodeModePanelSelections,
18191826
);
18201827
assert.strictEqual(
18211828
currentSelections,
18221829
JSON.stringify({
1823-
[`${testRealmURL}address.gts`]: 'spec-preview',
1824-
[`${testRealmURL}country.gts`]: 'playground',
1825-
[`${testRealmURL}person.gts`]: null,
1826-
[`${testRealmURL}pet-person.gts`]: 'playground',
1827-
[`${testRealmURL}pet.gts`]: 'spec-preview',
1830+
[`${testRealmURL}address.gts`]: 'playground',
1831+
[`${testRealmURL}country.gts`]: 'spec-preview',
1832+
[`${testRealmURL}person.gts`]: 'schema-editor',
1833+
[`${testRealmURL}pet-person.gts`]: 'spec-preview',
1834+
[`${testRealmURL}pet.gts`]: 'playground',
18281835
}),
18291836
);
18301837
});

packages/host/tests/acceptance/code-submode/spec-test.gts

-2
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,6 @@ module('Acceptance | Spec preview', function (hooks) {
561561
});
562562
assert.dom('[data-test-accordion-item="spec-preview"]').exists();
563563
assert.dom('[data-test-create-spec-button]').exists();
564-
assert.dom('[data-test-create-spec-intent-message]').doesNotExist();
565-
await click('[data-test-accordion-item="spec-preview"] button');
566564
assert.dom('[data-test-create-spec-intent-message]').exists();
567565
await percySnapshot(assert);
568566
});

0 commit comments

Comments
 (0)