Skip to content

Commit

Permalink
added one test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon committed Nov 27, 2023
1 parent 60115a3 commit 92327ca
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 29 deletions.
22 changes: 0 additions & 22 deletions .github/workflows/gpt-review.yml

This file was deleted.

46 changes: 39 additions & 7 deletions src/containers/InteractiveMessage/InteractiveMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ const renderInteractiveMessage = (id: string) => (
</MockedProvider>
);

const interactiveMessage = (
<MockedProvider mocks={mockData} addTypename={false}>
<MemoryRouter>
<InteractiveMessage />
</MemoryRouter>
</MockedProvider>
);

const fieldsMock = {
results: [{ key: 'key 1' }, { key: 'key 2' }],
};
Expand Down Expand Up @@ -80,13 +88,7 @@ vi.spyOn(axios, 'get').mockImplementation((url: string) => {
});

test('it renders empty interactive form', async () => {
render(
<MockedProvider mocks={mockData} addTypename={false}>
<MemoryRouter>
<InteractiveMessage />
</MemoryRouter>
</MockedProvider>
);
render(interactiveMessage);

// Adding another quick reply button
await waitFor(() => {
Expand Down Expand Up @@ -243,3 +245,33 @@ describe('copy interactive message', () => {
});
});
});

describe('location request message', () => {
test('it renders empty location request message', async () => {
render(interactiveMessage);

await waitFor(() => {
expect(screen.getAllByTestId('autocomplete-element')[0]).toBeInTheDocument();
});
const [interactiveType] = screen.getAllByTestId('autocomplete-element');

// Switiching to location request
interactiveType.focus();
fireEvent.keyDown(interactiveType, { key: 'ArrowDown' });
fireEvent.keyDown(interactiveType, { key: 'ArrowDown' });
fireEvent.keyDown(interactiveType, { key: 'ArrowDown' });
fireEvent.keyDown(interactiveType, { key: 'Enter' });
await waitFor(() => {
expect(interactiveType.querySelector('input')).toHaveValue('Location request');
});

fireEvent.change(screen.getAllByTestId('outlinedInput')[0]?.querySelector('input'), {
target: { value: 'Section 1' },
});

// have send location in simulator preview
await waitFor(() => {
expect(screen.getByText('Send Location')).toBeInTheDocument();
});
});
});

0 comments on commit 92327ca

Please sign in to comment.