Skip to content

Commit 492ed68

Browse files
committed
fix tests not flushing all changes
1 parent ac41999 commit 492ed68

File tree

2 files changed

+33
-29
lines changed

2 files changed

+33
-29
lines changed

static/app/views/issueList/actions/index.spec.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,24 +108,24 @@ describe('IssueListActions', () => {
108108
expect(screen.queryByRole('button', {name: 'Archive'})).not.toBeInTheDocument();
109109
});
110110

111-
it('shows action buttons when any items are selected', () => {
111+
it('shows action buttons when any items are selected', async () => {
112112
render(<WrappedComponent selectedIds={['1']} />);
113113

114-
expect(screen.getByRole('button', {name: 'Resolve'})).toBeEnabled();
114+
expect(await screen.findByRole('button', {name: 'Resolve'})).toBeEnabled();
115115
expect(screen.getByRole('button', {name: 'Archive'})).toBeEnabled();
116116
});
117117

118-
it('shows select all checkbox as checked when all items are selected', () => {
118+
it('shows select all checkbox as checked when all items are selected', async () => {
119119
render(<WrappedComponent selectedIds={['1', '2', '3']} />);
120120

121121
// When all selected, label changes to "Deselect all"
122-
expect(screen.getByRole('checkbox', {name: 'Deselect all'})).toBeChecked();
122+
expect(await screen.findByRole('checkbox', {name: 'Deselect all'})).toBeChecked();
123123
});
124124

125-
it('shows select all checkbox as indeterminate when some items are selected', () => {
125+
it('shows select all checkbox as indeterminate when some items are selected', async () => {
126126
render(<WrappedComponent selectedIds={['1']} />);
127127

128-
const checkbox = screen.getByRole('checkbox', {name: 'Select all'});
128+
const checkbox = await screen.findByRole('checkbox', {name: 'Select all'});
129129
expect(checkbox).toBePartiallyChecked();
130130
});
131131
});

static/app/views/seerExplorer/explorerPanel.spec.tsx

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -125,15 +125,15 @@ describe('ExplorerPanel', () => {
125125
});
126126

127127
describe('Feature Flag and Organization Checks', () => {
128-
it('renders when feature flag and open membership are enabled', () => {
128+
it('renders when feature flag and open membership are enabled', async () => {
129129
renderWithPanelContext(<ExplorerPanel />, true, {organization});
130130

131131
expect(
132-
screen.getByText(/Ask Seer anything about your application./)
132+
await screen.findByText(/Ask Seer anything about your application./)
133133
).toBeInTheDocument();
134134
});
135135

136-
it('does not render when feature flag is disabled', () => {
136+
it('does not render when feature flag is disabled', async () => {
137137
const disabledOrg = OrganizationFixture({
138138
features: [],
139139
hideAiFeatures: false,
@@ -144,10 +144,10 @@ describe('ExplorerPanel', () => {
144144
organization: disabledOrg,
145145
});
146146

147-
expect(container).toBeEmptyDOMElement();
147+
await waitFor(() => expect(container).toBeEmptyDOMElement());
148148
});
149149

150-
it('does not render when AI features are hidden', () => {
150+
it('does not render when AI features are hidden', async () => {
151151
const disabledOrg = OrganizationFixture({
152152
features: ['seer-explorer'],
153153
hideAiFeatures: true,
@@ -158,10 +158,10 @@ describe('ExplorerPanel', () => {
158158
organization: disabledOrg,
159159
});
160160

161-
expect(container).toBeEmptyDOMElement();
161+
await waitFor(() => expect(container).toBeEmptyDOMElement());
162162
});
163163

164-
it('does not render when open membership is disabled', () => {
164+
it('does not render when open membership is disabled', async () => {
165165
const disabledOrg = OrganizationFixture({
166166
features: ['seer-explorer'],
167167
hideAiFeatures: false,
@@ -172,28 +172,30 @@ describe('ExplorerPanel', () => {
172172
organization: disabledOrg,
173173
});
174174

175-
expect(container).toBeEmptyDOMElement();
175+
await waitFor(() => expect(container).toBeEmptyDOMElement());
176176
});
177177
});
178178

179179
describe('Empty State', () => {
180-
it('shows empty state when no messages exist', () => {
180+
it('shows empty state when no messages exist', async () => {
181181
renderWithPanelContext(<ExplorerPanel />, true, {organization});
182182

183183
expect(
184-
screen.getByText(/Ask Seer anything about your application./)
184+
await screen.findByText(/Ask Seer anything about your application./)
185185
).toBeInTheDocument();
186186
});
187187

188-
it('shows input section in empty state', () => {
188+
it('shows input section in empty state', async () => {
189189
renderWithPanelContext(<ExplorerPanel />, true, {organization});
190190

191191
expect(
192-
screen.getByPlaceholderText('Type your message or / command and press Enter ↵')
192+
await screen.findByPlaceholderText(
193+
'Type your message or / command and press Enter ↵'
194+
)
193195
).toBeInTheDocument();
194196
});
195197

196-
it('shows error when hook returns isError=true', () => {
198+
it('shows error when hook returns isError=true', async () => {
197199
const useSeerExplorerSpy = jest
198200
.spyOn(useSeerExplorerModule, 'useSeerExplorer')
199201
.mockReturnValue({
@@ -220,7 +222,7 @@ describe('ExplorerPanel', () => {
220222
renderWithPanelContext(<ExplorerPanel />, true, {organization});
221223

222224
expect(
223-
screen.getByText('Error loading this session (ID=123).')
225+
await screen.findByText('Error loading this session (ID=123).')
224226
).toBeInTheDocument();
225227
expect(
226228
screen.queryByText(/Ask Seer anything about your application./)
@@ -231,7 +233,7 @@ describe('ExplorerPanel', () => {
231233
});
232234

233235
describe('Messages Display', () => {
234-
it('renders messages when session data exists', () => {
236+
it('renders messages when session data exists', async () => {
235237
const mockSessionData = {
236238
blocks: [
237239
{
@@ -283,7 +285,7 @@ describe('ExplorerPanel', () => {
283285

284286
renderWithPanelContext(<ExplorerPanel />, true, {organization});
285287

286-
expect(screen.getByText('What is this error?')).toBeInTheDocument();
288+
expect(await screen.findByText('What is this error?')).toBeInTheDocument();
287289
expect(
288290
screen.getByText('This error indicates a null pointer exception.')
289291
).toBeInTheDocument();
@@ -533,19 +535,21 @@ describe('ExplorerPanel', () => {
533535
openMembership: true,
534536
});
535537

536-
it('does not render the toggle when the feature flag is disabled', () => {
538+
it('does not render the toggle when the feature flag is disabled', async () => {
537539
renderWithPanelContext(<ExplorerPanel />, true, {organization});
538540

541+
// Wait for effects to settle before asserting absence
542+
await screen.findByTestId('seer-explorer-input');
539543
expect(
540544
screen.queryByRole('checkbox', {name: 'Toggle context engine'})
541545
).not.toBeInTheDocument();
542546
});
543547

544-
it('renders the toggle when the feature flag is enabled', () => {
548+
it('renders the toggle when the feature flag is enabled', async () => {
545549
renderWithPanelContext(<ExplorerPanel />, true, {organization: orgWithFlag});
546550

547551
expect(
548-
screen.getByRole('checkbox', {name: 'Toggle context engine'})
552+
await screen.findByRole('checkbox', {name: 'Toggle context engine'})
549553
).toBeInTheDocument();
550554
});
551555

@@ -623,20 +627,20 @@ describe('ExplorerPanel', () => {
623627
});
624628

625629
describe('Visibility Control', () => {
626-
it('renders when isVisible=true', () => {
630+
it('renders when isVisible=true', async () => {
627631
renderWithPanelContext(<ExplorerPanel />, true, {organization});
628632

629-
expect(screen.getByTestId('seer-explorer-input')).toBeInTheDocument();
633+
expect(await screen.findByTestId('seer-explorer-input')).toBeInTheDocument();
630634
});
631635

632-
it('can handle visibility changes', () => {
636+
it('can handle visibility changes', async () => {
633637
const {rerenderWithOpen} = renderWithPanelContext(<ExplorerPanel />, false, {
634638
organization,
635639
});
636640

637641
rerenderWithOpen(true);
638642

639-
expect(screen.getByTestId('seer-explorer-input')).toBeInTheDocument();
643+
expect(await screen.findByTestId('seer-explorer-input')).toBeInTheDocument();
640644
});
641645
});
642646
});

0 commit comments

Comments
 (0)