Skip to content

Commit

Permalink
Merge pull request #142 from player-ui/sync/2fd68b7e55dbf6ee8019b6dc4…
Browse files Browse the repository at this point in the history
…7aa84bae84985f1

Sync/2fd68b7e55dbf6ee8019b6dc47aa84bae84985f1
  • Loading branch information
KetanReddy authored Aug 14, 2023
2 parents 766bb5a + 1aa77ab commit a664938
Show file tree
Hide file tree
Showing 110 changed files with 6,971 additions and 1,202 deletions.
22 changes: 22 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,28 @@
"contributions": [
"design"
]
},
{
"login": "lexfm",
"name": "Alejandro Fimbres",
"avatar_url": "https://avatars.githubusercontent.com/u/9345943?v=4",
"profile": "https://github.com/lexfm",
"contributions": [
"doc",
"test",
"code"
]
},
{
"login": "rafbcampos",
"name": "Rafael Campos",
"avatar_url": "https://avatars.githubusercontent.com/u/26394217?v=4",
"profile": "https://github.com/rafbcampos",
"contributions": [
"doc",
"test",
"code"
]
}
],
"contributorsPerLine": 6
Expand Down
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ jobs:
- run: cd xcode && bundle exec pod install
- run: bazel build --config=ci -- //:PlayerUI //:PlayerUI-Demo //:PlayerUI_Pod
# TODO: the timeout should be added to the test itself
- run: bazel test --test_env=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --test_env=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --test_env=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --test_timeout=600 --jobs=1 --verbose_failures --config=ci -- //:PlayerUI-Unit-Unit //:PlayerUI-UI-ViewInspectorTests //:PlayerUI-UI-XCUITests
- run: bazel test --test_env=APPLITOOLS_API_KEY=${APPLITOOLS_API_KEY} --test_env=APPLITOOLS_BATCH_ID=${CIRCLE_SHA1} --test_env=APPLITOOLS_PR_NUMBER=${CIRCLE_PULL_REQUEST##*/} --test_timeout=1200 --jobs=1 --verbose_failures --config=ci -- //:PlayerUI-Unit-Unit //:PlayerUI-UI-ViewInspectorTests //:PlayerUI-UI-XCUITests

- run:
when: always
Expand Down
1 change: 1 addition & 0 deletions core/player/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ javascript_pipeline(
],
test_data = [
"//core/make-flow:@player-ui/make-flow",
"//plugins/common-types/core:@player-ui/common-types-plugin",
],
library_name = "Player",
bundle_entry = 'bundle.entry.js'
Expand Down
40 changes: 30 additions & 10 deletions core/player/src/__tests__/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ describe('delete', () => {

controller.delete('foo.baz');

expect(controller.getTrash()).toStrictEqual(new Set());
expect(controller.get('')).toStrictEqual({
foo: { bar: 'Some Data' },
});
Expand All @@ -166,9 +165,6 @@ describe('delete', () => {

controller.delete('foo.bar');

expect(controller.getTrash()).toStrictEqual(
new Set([parser.parse('foo.bar')])
);
expect(controller.get('')).toStrictEqual({ foo: {} });
});

Expand All @@ -187,9 +183,6 @@ describe('delete', () => {

controller.delete('foo.0');

expect(controller.getTrash()).toStrictEqual(
new Set([parser.parse('foo.0')])
);
expect(controller.get('')).toStrictEqual({ foo: [] });
});

Expand All @@ -208,7 +201,6 @@ describe('delete', () => {

controller.delete('foo.1');

expect(controller.getTrash()).toStrictEqual(new Set());
expect(controller.get('')).toStrictEqual({ foo: ['Some Data'] });
});

Expand All @@ -230,7 +222,6 @@ describe('delete', () => {

controller.delete('foo');

expect(controller.getTrash()).toStrictEqual(new Set([parser.parse('foo')]));
expect(controller.get('')).toStrictEqual({ baz: 'Other data' });
});

Expand All @@ -251,7 +242,6 @@ describe('delete', () => {

controller.delete('');

expect(controller.getTrash()).toStrictEqual(new Set());
expect(controller.get('')).toStrictEqual({
foo: {
bar: 'Some Data',
Expand Down Expand Up @@ -295,6 +285,9 @@ describe('formatting', () => {

controller.set([['foo.baz', 'should-deformat']], { formatted: true });
expect(controller.get('foo.baz')).toBe('deformatted!');
expect(controller.get('foo.baz', { formatted: false })).toBe(
'deformatted!'
);
});
});

Expand Down Expand Up @@ -430,3 +423,30 @@ it('should not send update for deeply equal data', () => {

expect(onUpdateCallback).not.toBeCalled();
});

it('should handle deleting non-existent value + parent value', () => {
const model = {
user: {
name: 'frodo',
age: 3,
},
};

const localData = new LocalModel(model);

const parser = new BindingParser({
get: localData.get,
set: localData.set,
});
const controller = new DataController({}, { pathResolver: parser });
controller.hooks.resolveDataStages.tap('basic', () => [localData]);

controller.delete('user.email');

expect(controller.get('user')).toStrictEqual({
name: 'frodo',
age: 3,
});

controller.delete('foo.bar');
});
2 changes: 2 additions & 0 deletions core/player/src/__tests__/helpers/binding.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ export default class TrackBindingPlugin implements PlayerPlugin {
view.hooks.resolver.tap('test', (resolver) => {
resolver.hooks.resolve.tap('test', (val, node, options) => {
if (val?.binding) {
const currentValue = options?.data.model.get(val.binding);
options.validation?.track(val.binding);
const valObj = options.validation?.get(val.binding);

if (valObj) {
return {
...val,
value: currentValue,
validation: valObj,
allValidations: options.validation?.getAll(),
};
Expand Down
Loading

0 comments on commit a664938

Please sign in to comment.