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

ISW - Copy and UI improvements #21348

Merged
merged 7 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -180,98 +180,139 @@ describe('InputSetupWizard Setup Routing', () => {
it('should render the Setup Routing step', async () => {
renderWizard();

const routingStepText = await screen.findByText(/Choose a Destination Stream to route Messages from this Input to./i);
const routingStepText = await screen.findByText(/Select a destination Stream to route messages from this input to./i);

expect(routingStepText).toBeInTheDocument();
});

it('should only show editable existing streams', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true },
{ id: 'moraid', title: 'Mora', is_editable: false },
],
));
describe('Stream Selection', () => {
it('should show the stream select when clicking on choose stream', async () => {
renderWizard();
const selectStreamButton = await screen.findByRole('button', {
name: /Select Stream/i,
hidden: true,
});

renderWizard();
fireEvent.click(selectStreamButton);

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);
await screen.findByLabelText(/All messages \(Default\)/i);
});

await selectEvent.openMenu(streamSelect);
it('should only show editable existing streams', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true },
{ id: 'moraid', title: 'Mora', is_editable: false },
],
));

const alohoOption = await screen.findByText(/Aloho/i);
const moraOption = screen.queryByText(/Mora/i);
renderWizard();
const selectStreamButton = await screen.findByRole('button', {
name: /Select Stream/i,
hidden: true,
});

expect(alohoOption).toBeInTheDocument();
expect(moraOption).not.toBeInTheDocument();
});
fireEvent.click(selectStreamButton);

it('should not show existing default stream in select', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true, is_default: true },
{ id: 'moraid', title: 'Mora', is_editable: true },
],
));
const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

renderWizard();
await selectEvent.openMenu(streamSelect);

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);
const alohoOption = await screen.findByText(/Aloho/i);
const moraOption = screen.queryByText(/Mora/i);

await selectEvent.openMenu(streamSelect);
expect(alohoOption).toBeInTheDocument();
expect(moraOption).not.toBeInTheDocument();
});

const moraOption = await screen.findByText(/Mora/i);
const alohoOption = screen.queryByText(/Aloho/i);
it('should not show existing default stream in select', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true, is_default: true },
{ id: 'moraid', title: 'Mora', is_editable: true },
],
));

expect(moraOption).toBeInTheDocument();
expect(alohoOption).not.toBeInTheDocument();
});
renderWizard();

it('should allow the user to select a stream', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true },
{ id: 'moraid', title: 'Mora', is_editable: true },
],
));
const selectStreamButton = await screen.findByRole('button', {
name: /Select Stream/i,
hidden: true,
});

renderWizard();
fireEvent.click(selectStreamButton);

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);
const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

await selectEvent.openMenu(streamSelect);
await selectEvent.openMenu(streamSelect);

await selectEvent.select(streamSelect, 'Aloho');
});
const moraOption = await screen.findByText(/Mora/i);
const alohoOption = screen.queryByText(/Aloho/i);

it('should show a warning if the selected stream has connected pipelines', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true },
{ id: 'moraid', title: 'Mora', is_editable: true },
],
));
expect(moraOption).toBeInTheDocument();
expect(alohoOption).not.toBeInTheDocument();
});

asMock(usePipelinesConnectedStream).mockReturnValue(pipelinesConnectedMock([
{ id: 'pipeline1', title: 'Pipeline1' },
{ id: 'pipeline2', title: 'Pipeline2' },
]));
it('should allow the user to select a stream', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true },
{ id: 'moraid', title: 'Mora', is_editable: true },
],
));

renderWizard();
renderWizard();

const selectStreamButton = await screen.findByRole('button', {
name: /Select Stream/i,
hidden: true,
});

fireEvent.click(selectStreamButton);

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

await selectEvent.openMenu(streamSelect);

await selectEvent.select(streamSelect, 'Aloho');
});

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);
it('should show a warning if the selected stream has connected pipelines', async () => {
asMock(useStreams).mockReturnValue(useStreamsResult(
[
{ id: 'alohoid', title: 'Aloho', is_editable: true },
{ id: 'moraid', title: 'Mora', is_editable: true },
],
));

await selectEvent.openMenu(streamSelect);
asMock(usePipelinesConnectedStream).mockReturnValue(pipelinesConnectedMock([
{ id: 'pipeline1', title: 'Pipeline1' },
{ id: 'pipeline2', title: 'Pipeline2' },
]));

await selectEvent.select(streamSelect, 'Aloho');
renderWizard();

const selectStreamButton = await screen.findByRole('button', {
name: /Select Stream/i,
hidden: true,
});

fireEvent.click(selectStreamButton);

const warning = await screen.findByText(/The selected stream has existing pipelines/i);
const warningPipeline1 = await screen.findByText(/Pipeline1/i);
const warningPipeline2 = await screen.findByText(/Pipeline2/i);
const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

expect(warning).toBeInTheDocument();
expect(warningPipeline1).toBeInTheDocument();
expect(warningPipeline2).toBeInTheDocument();
await selectEvent.openMenu(streamSelect);

await selectEvent.select(streamSelect, 'Aloho');

const warning = await screen.findByText(/Pipelines connected to target Stream/i);
const warningPipeline1 = await screen.findByText(/Pipeline1/i);
const warningPipeline2 = await screen.findByText(/Pipeline2/i);

expect(warning).toBeInTheDocument();
expect(warningPipeline1).toBeInTheDocument();
expect(warningPipeline2).toBeInTheDocument();
});
});

describe('Stream creation', () => {
Expand Down Expand Up @@ -323,7 +364,7 @@ describe('InputSetupWizard Setup Routing', () => {
});

const nextStepButton = await screen.findByRole('button', {
name: /Finish & Start Input/i,
name: /Skip & Start Input/i,
hidden: true,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ const newPipelineConfig = {
};

const goToStartInputStep = async () => {
const nextButton = await screen.findByRole('button', { name: /Finish & Start Input/i, hidden: true });
const nextButton = await screen.findByRole('button', { name: /& Start Input/i, hidden: true });

fireEvent.click(nextButton);
};
Expand Down Expand Up @@ -265,6 +265,13 @@ describe('InputSetupWizard Start Input', () => {
it('should start input when an existing stream is selected', async () => {
renderWizard();

const selectStreamButton = await screen.findByRole('button', {
name: /Select Stream/i,
hidden: true,
});

fireEvent.click(selectStreamButton);

const streamSelect = await screen.findByLabelText(/All messages \(Default\)/i);

await selectEvent.openMenu(streamSelect);
Expand Down
Loading
Loading