Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
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 @@ -24,7 +24,7 @@ describe('AddStage', function () {
const button = screen.getByTestId('add-stage-icon-button');
expect(() => {
within(button).getByText('Add stage');
}).to.throw;
}).to.throw();
});

it('calls onAddStage with index when clicked', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('aggregation side panel', function () {

it('renders a search input', async function () {
await renderAggregationSidePanel();
expect(screen.getByRole('search')).to.not.throw;
expect(() => screen.getByRole('search')).to.not.throw();
});

it('renders all the usecases', async function () {
Expand All @@ -71,7 +71,7 @@ describe('aggregation side panel', function () {
.getByTestId('side-panel-content')
.querySelectorAll('[data-testid^="use-case-"]')
).to.have.lengthOf(1);
expect(screen.getByTestId('use-case-sort')).to.not.throw;
expect(() => screen.getByTestId('use-case-sort')).to.not.throw();
});

it('renders usecases filtered by search text matching the stage operator of the usecases', async function () {
Expand All @@ -83,7 +83,7 @@ describe('aggregation side panel', function () {
.getByTestId('side-panel-content')
.querySelectorAll('[data-testid^="use-case-"]')
).to.have.lengthOf(1);
expect(screen.getByTestId('use-case-lookup')).to.not.throw;
expect(() => screen.getByTestId('use-case-lookup')).to.not.throw();

userEvent.clear(searchBox);
userEvent.type(searchBox, '$lookup');
Expand All @@ -92,7 +92,7 @@ describe('aggregation side panel', function () {
.getByTestId('side-panel-content')
.querySelectorAll('[data-testid^="use-case-"]')
).to.have.lengthOf(1);
expect(screen.getByTestId('use-case-lookup')).to.not.throw;
expect(() => screen.getByTestId('use-case-lookup')).to.not.throw();
});

it('calls onSelectUseCase when a use case is clicked', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ describe('group with subset', function () {
);
});
it('renders number of records input', function () {
expect(screen.getByTestId('number-of-records-input')).to.throw;
expect(screen.queryByTestId('number-of-records-input')).to.exist;
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe('group', function () {
).to.exist;
expect(() =>
screen.getByTestId(TEST_IDS.removeGroupBtn(group.id))
).to.throw;
).to.throw();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('UseCaseCard', function () {
onSelect={Sinon.spy()}
/>
);
expect(screen.getByTestId(`use-case-${useCase.id}`)).to.not.throw;
expect(() => screen.getByTestId(`use-case-${useCase.id}`)).to.not.throw();
});

it('should call onSelect when a usecase is selected', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,8 @@ const renderFocusModeStageEditor = (
describe('FocusMode', function () {
it('does not render editor when stage index is -1', async function () {
await renderFocusModeStageEditor({ index: -1 });
expect(() => {
screen.getByTestId('stage-operator-combobox');
}).to.throw;
expect(() => {
screen.getByText(/open docs/i);
}).to.throw;
expect(screen.queryByTestId('stage-operator-combobox')).to.not.exist;
expect(screen.queryByText(/open docs/i)).to.not.exist;
});

context('when operator is not defined', function () {
Expand All @@ -41,10 +37,13 @@ describe('FocusMode', function () {
expect(dropdown).to.exist;
});

it('does not render docs link', function () {
expect(() => {
screen.getByText(/open docs/i);
}).to.throw;
it('renders docs link', function () {
const element = screen.getByText(/open docs/i);

expect(element.closest('a')).to.have.attribute(
'href',
'https://www.mongodb.com/docs/manual/reference/mql/aggregation-stages/'
);
});
});

Expand All @@ -62,7 +61,12 @@ describe('FocusMode', function () {
});

it('renders docs link', function () {
expect(screen.getByText(/open docs/i)).to.exist;
const element = screen.getByText(/open docs/i);

expect(element.closest('a')).to.have.attribute(
'href',
'https://www.mongodb.com/docs/manual/reference/operator/aggregation/limit/'
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe('FocusMode', function () {
await waitFor(() => {
expect(() => {
screen.getByTestId('focus-mode-modal');
}).to.throw;
}).to.throw();
});
});

Expand All @@ -42,8 +42,8 @@ describe('FocusMode', function () {
screen.getByLabelText(/close modal/i).click();
});

expect(() => {
screen.getByTestId('focus-mode-modal');
}).to.throw;
await waitFor(() => {
expect(screen.queryByTestId('focus-mode-modal')).to.not.exist;
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('PipelineBuilderWorkspace', function () {
const container = screen.getByTestId('pipeline-builder-workspace');
expect(() => {
within(container).getByTestId('aggregation-side-panel');
}).to.not.throw;
}).to.not.throw();
});

it('does not render side panel when enabled in as text mode', async function () {
Expand All @@ -47,6 +47,6 @@ describe('PipelineBuilderWorkspace', function () {
const container = screen.getByTestId('pipeline-builder-workspace');
expect(() => {
within(container).getByTestId('aggregation-side-panel');
}).to.throw;
}).to.throw();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ describe('PipelineAsTextWorkspace', function () {
await renderPipelineAsTextWorkspace({ isAutoPreview: false });
expect(() => {
screen.getByTestId('pipeline-as-text-preview');
}).to.throw;
}).to.throw();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ describe('PipelinePreview', function () {
// By default we don't expand nested props of a document
expect(within(docList).getByText(/_id/)).to.exist;
expect(within(docList).getByText(/score/)).to.exist;
expect(() => within(docList).getByText(/number/)).to.throw;
expect(() => within(docList).getByText(/another/)).to.throw;
expect(() => within(docList).getByText(/deep/)).to.throw;
expect(() => within(docList).getByText(/nested/)).to.throw;
expect(() => within(docList).getByText(/document/)).to.throw;
expect(() => within(docList).getByText(/number/)).to.throw();
expect(() => within(docList).getByText(/another/)).to.throw();
expect(() => within(docList).getByText(/deep/)).to.throw();
expect(() => within(docList).getByText(/nested/)).to.throw();
expect(() => within(docList).getByText(/document/)).to.throw();

// Expand the whole document
userEvent.click(
Expand Down Expand Up @@ -153,11 +153,11 @@ describe('PipelinePreview', function () {

expect(within(docList).getByText(/_id/)).to.exist;
expect(within(docList).getByText(/score/)).to.exist;
expect(() => within(docList).getByText(/number/)).to.throw;
expect(() => within(docList).getByText(/another/)).to.throw;
expect(() => within(docList).getByText(/deep/)).to.throw;
expect(() => within(docList).getByText(/nested/)).to.throw;
expect(() => within(docList).getByText(/document/)).to.throw;
expect(() => within(docList).getByText(/number/)).to.throw();
expect(() => within(docList).getByText(/another/)).to.throw();
expect(() => within(docList).getByText(/deep/)).to.throw();
expect(() => within(docList).getByText(/nested/)).to.throw();
expect(() => within(docList).getByText(/document/)).to.throw();
});

it('renders output stage preview', async function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('OutputStagePreview', function () {
screen.getByRole('button', {
name: /save documents/i,
});
}).to.throw;
}).to.throw();
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('PipelinePagination', function () {
const container = screen.getByTestId('pipeline-pagination');
expect(() => {
within(container).getByTestId('pipeline-pagination-desc');
}).to.throw;
}).to.throw();
});
it('renders paginate buttons as disabled when disabled', async function () {
await renderPipelinePagination({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('PipelineResultsList', function () {
);
expect(() => {
screen.getByTestId('document-list-item');
}).to.throw;
}).to.throw();
});

it('renders list view', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,6 @@ describe('PipelineToolbar', function () {
});
});

describe('renders with setting row - hidden', function () {
it('does not render toolbar settings', async function () {
await renderWithStore(
<PipelineToolbar
isBuilderView
showExplainButton
showExportButton
showRunButton
/>
);
const toolbar = screen.getByTestId('pipeline-toolbar');
expect(() => within(toolbar).getByTestId('pipeline-settings')).to.throw;
});
});

// @experiment Skills in Atlas | Jira Epic: CLOUDP-346311
describe('Atlas Skills Banner', function () {
let preferences: PreferencesAccess;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('PipelineStages', function () {
const container = renderPipelineStages({ showAddNewStage: false });
expect(() => {
within(container).getByTestId('pipeline-toolbar-add-stage-button');
}).to.throw;
}).to.throw();
});
it('renders add stage button', function () {
const onStageAddedSpy = spy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe('PipelineMenus', function () {
expect(screen.getByTestId('save-menu-saveAs-action')).to.exist;
expect(() => {
screen.getByTestId('save-menu-createView-action');
}).to.throw;
}).to.throw();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ describe('SavedPipelines', function () {
});

it('does not render empty state', function () {
expect(() => screen.getByTestId('saved-pipelines-empty-state')).to.throw;
expect(() =>
screen.getByTestId('saved-pipelines-empty-state')
).to.throw();
});

it('renders the pipeline names', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('UseCaseDroppableArea', function () {
</UseCaseDroppableArea>
);
expect(screen.queryByTestId('use-case-drop-marker-1')).to.be.null;
expect(screen.getByText('Hello')).to.not.throw;
expect(() => screen.getByText('Hello')).to.not.throw();
});

it('should render the drop marker when useDraggable reports isOver=true', function () {
Expand All @@ -27,7 +27,7 @@ describe('UseCaseDroppableArea', function () {
<p>Hello</p>
</UseCaseDroppableArea>
);
expect(screen.getByTestId('use-case-drop-marker-1')).to.not.throw;
expect(() => screen.getByTestId('use-case-drop-marker-1')).to.not.throw();
expect(screen.queryByText('Hello')).to.be.null;
sandbox.restore();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/compass-aggregations/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const MERGE_STAGE_PREVIEW_TEXT =
'the specified location.';

export const PIPELINE_HELP_URI =
'https://www.mongodb.com/docs/manual/reference/operator/aggregation-pipeline/';
'https://www.mongodb.com/docs/manual/reference/mql/aggregation-stages/';

export const STAGE_HELP_BASE_URL =
'https://www.mongodb.com/docs/manual/reference/operator/aggregation';
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,14 @@ describe('PipelineBuilder', function () {
mock.restore();
});

it('throws when previewing a pipeline with output stage and not fitlering it out', function () {
it('throws when previewing a pipeline with output stage and not fitlering it out', async function () {
const pipeline = `[{$match: {}}, {$unwind: "users"}, {$out: "test"}]`;
pipelineBuilder.reset(pipeline);

expect(async () => {
await pipelineBuilder.getPreviewForPipeline('airbnb.listings', {});
}).to.throw;
const error = await pipelineBuilder
.getPreviewForPipeline('airbnb.listings', {})
.catch((e) => e);
expect(error).to.be.instanceOf(Error);
});

it('should handle leading and trailing stages of the pipeline', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,11 @@ describe('PipelineParser', function () {
[``, '{}', 'hello', '20'].forEach((expression) => {
expect(() => {
PipelineParser.parse(expression);
}).to.throw;
}).to.throw();
});
expect(() => {
PipelineParser.parse(`[]`);
}).to.not.throw;
}).to.not.throw();
});
it('parses commented out pipeline', function () {
const pipeline = `[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ describe('PipelinePreviewManager', function () {
const pipeline = [{ $match: {} }, { $sort: {} }, { $out: 'test' }];
expect(() => {
createPreviewAggregation(pipeline);
}).to.throw;
}).to.throw();
});

it('should not throw when output stage is not at the end of pipeline', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('CreateViewStore [Store]', function () {
source: 'dataService.test',
pipeline: [{ $project: { a: 1 } }],
});
}).to.throw;
}).to.throw();
});
it('dispatches the open action and sets the correct state', function () {
appRegistry.emit(
Expand Down
8 changes: 4 additions & 4 deletions packages/compass-app-stores/src/instances-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ describe('InstancesManager', function () {
it('should be able return a MongoDBInstance if available', function () {
expect(() => {
instancesManager.getMongoDBInstanceForConnection('1234'); // non-existent
}).to.throw;
}).to.throw();
instancesManager.createMongoDBInstanceForConnection(
TEST_CONNECTION_INFO.id,
{
Expand All @@ -103,7 +103,7 @@ describe('InstancesManager', function () {
);
expect(() =>
instancesManager.getMongoDBInstanceForConnection(TEST_CONNECTION_INFO.id)
).to.not.throw;
).to.not.throw();
});

it('should be able to remove MongoDBInstance for a connection', function () {
Expand All @@ -123,13 +123,13 @@ describe('InstancesManager', function () {
);
expect(() =>
instancesManager.getMongoDBInstanceForConnection(TEST_CONNECTION_INFO.id)
).to.not.throw;
).to.not.throw();
instancesManager.removeMongoDBInstanceForConnection(
TEST_CONNECTION_INFO.id
);
expect(() =>
instancesManager.getMongoDBInstanceForConnection(TEST_CONNECTION_INFO.id)
).to.throw;
).to.throw();
});

it('should emit instances removed event when an instance is removed', function () {
Expand Down
Loading
Loading