Skip to content

Commit

Permalink
Fix skipped test - new child element fails to be added. (#125)
Browse files Browse the repository at this point in the history
* bf: ADO# 1442586 - use package.json from core-common as example

* run the lint:fix command

* wip: fix remaining lint issues - duplicate import statements

* wip: add interface ConnectorAuthenticationManagerParams to reduce constructor parameters to one

* wip: update package version

* wip: move dependencies ahead to 4.7.0-dev.15

* wip: npm install w --legacy-peer-deps switch

* wip: install typdoc to attempt to fix error in build pipeline

* wip: in spirit of test first development, remove 'skip' to produce failing test. Also fix duplicate and missing imports to remove lint errors

* wip: add script test:larger-source-set

* bf: handle mixed bag of children with and without ids

* wip: update version and changelog

* wip: remove npm install switch inadvertently reintroduced by branching and merging
  • Loading branch information
jchick-bentley authored Jun 25, 2024
1 parent 02622b9 commit 217483d
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 8 deletions.
13 changes: 13 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"configurations": [



{
"name": "Documentation",
"request": "launch",
Expand Down Expand Up @@ -83,6 +84,18 @@
"test:integration"
]
},
{
"name": "iTwinConnectorFwk Tests (larger-source-set)",
"cwd": "${workspaceFolder}",
"type": "node",
"request": "launch",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run",
"test:larger-source-set"
]
},

{
"name": "pretest",
"cwd": "${workspaceFolder}",
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log - @itwin/connector-framework

## 2.2.2

- fixed bug in synchronizer for updating mixed bag of new and changed child elements. New element(s) would be skipped.

## 2.2.0-dev.1

- move access token handling to synchronizer
Expand Down
42 changes: 42 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@itwin/connector-framework",
"version": "2.2.1",
"version": "2.2.2",
"description": "iTwin Connector Framework",
"main": "lib/src/connector-framework.js",
"typings": "lib/src/connector-framework.d.ts",
Expand Down Expand Up @@ -28,6 +28,7 @@
"test:filebased": "npm run build && nyc mocha --grep file-based",
"test:trimming": "npm run build && nyc mocha --grep trimming",
"test:unmap": "npm run build && nyc mocha --grep unmap",
"test:larger-source-set":"npm run build && nyc mocha --grep larger-source-set",
"test:connector": "node lib/test/TestConnector/Main.js test/assets/TestArgs.json",
"documentation": "cross-env RUSHSTACK_FILE_ERROR_BASE_FOLDER=$npm_config_local_prefix betools docs --source=./src --out=./documentation --json=./documentation/file.json --tsIndexFile=./connector-framework.ts --onlyJson"
},
Expand Down
4 changes: 4 additions & 0 deletions src/Synchronizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ export class Synchronizer {
if (stat !== IModelStatus.Success) {
return stat;
}
} else if (childRes.itemState === ItemState.New) {
const stat = this.insertResultsIntoIModel(childRes, parentAspectProps);
if (stat !== IModelStatus.Success)
return stat;
}
}
return IModelStatus.Success;
Expand Down
12 changes: 5 additions & 7 deletions test/standalone/Synchronizer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,16 @@
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/

import type { ExternalSourceAspectProps, RepositoryLinkProps } from "@itwin/core-common";
import { Code, IModelError, IModelStatus } from "@itwin/core-common";
import type { Subject } from "@itwin/core-backend";
import { DefinitionGroup, ExternalSourceAspect, RepositoryLink, SnapshotDb } from "@itwin/core-backend";
import { Code, ExternalSourceAspectProps, IModelError, IModelStatus, RepositoryLinkProps } from "@itwin/core-common";
import { DefinitionGroup, ExternalSourceAspect, RepositoryLink, SnapshotDb, Subject } from "@itwin/core-backend";
import { assert } from "chai";
import { join } from "path";
import * as fs from "fs";
import * as utils from "../ConnectorTestUtils";
import { KnownTestLocations } from "../KnownTestLocations";
import type { SourceItem } from "../../src/Synchronizer";
import { ItemState, Synchronizer } from "../../src/Synchronizer";
import { ItemState, SourceItem, Synchronizer } from "../../src/Synchronizer";
import { berryGroups } from "./toys";
import {after, before} from "mocha";

describe("synchronizer #standalone", () => {
const name = "my-fruits";
Expand Down Expand Up @@ -300,7 +298,7 @@ describe("synchronizer #standalone", () => {
// TODO: This one fails, skipping so that it passes CI. Need to fix, it's a bug in the
// synchronizer!
// vvvv
it.skip("update modified root element with children, larger source set", () => {
it("update modified root element with children, larger-source-set", () => {
const synchronizer = new Synchronizer(imodel, false);
const { model, berryTree, berryTreeMeta } = berryGroups(synchronizer);

Expand Down
6 changes: 6 additions & 0 deletions test/standalone/toys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,12 @@ interface BerryGroups {
berryTreeMeta: SourceItem;
}

/**
* Creates and returns a set of berry groups for synchronization.
*
* @param sync - The synchronizer used for synchronization.
* @returns The berry groups for synchronization.
*/
export function berryGroups(sync: Synchronizer): BerryGroups {
// o - subject
// |
Expand Down

0 comments on commit 217483d

Please sign in to comment.