-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix alignment on additional properties (#251)
# Pull Request ## 📖 Description Some fixes for the dictionary control (`additionalProperties` keyword): - Styling alignment fixes - Allow `true` to generate an un-typed control - Add tests for the dictionary control ### 🎫 Issues Closes #134 ## 👩💻 Reviewer Notes Currently I do not have access to a recent macos version so the snapshots check will fail. This will be updated in future. ## ✅ Checklist ### General <!--- Review the list and put an x in the boxes that apply. --> - [x] I have added tests for my changes. - [x] I have tested my changes. - [ ] I have updated the project documentation to reflect my changes.
- Loading branch information
Showing
17 changed files
with
197 additions
and
25 deletions.
There are no files selected for viewing
7 changes: 7 additions & 0 deletions
7
change/design-to-code-3c4419df-feac-4786-a2c8-4a78107af448.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Styling alignment fixes for the form additionalProperties keyword", | ||
"packageName": "design-to-code", | ||
"email": "7559015+janechu@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
7 changes: 7 additions & 0 deletions
7
change/design-to-code-react-c4fed146-d4f5-4af9-92f1-9e8e4f3b3e6b.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"type": "patch", | ||
"comment": "Styling alignment fixes for the form additionalProperties keyword", | ||
"packageName": "design-to-code-react", | ||
"email": "7559015+janechu@users.noreply.github.com", | ||
"dependentChangeType": "patch" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
...sign-to-code-react/src/__tests__/schemas/keyword.additional-properties.as-false.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
$schema: "http://json-schema.org/schema#", | ||
$id: "typeObjectAdditionalPropertiesAsFalse", | ||
title: "Object with additional properties", | ||
type: "object", | ||
additionalProperties: false | ||
}; |
10 changes: 10 additions & 0 deletions
10
...ign-to-code-react/src/__tests__/schemas/keyword.additional-properties.as-object.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export default { | ||
$schema: "http://json-schema.org/schema#", | ||
$id: "typeObjectAdditionalPropertiesAsObject", | ||
title: "Object with additional properties", | ||
type: "object", | ||
additionalProperties: { | ||
title: "Additional property", | ||
type: "boolean" | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
...esign-to-code-react/src/__tests__/schemas/keyword.additional-properties.as-true.schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default { | ||
$schema: "http://json-schema.org/schema#", | ||
$id: "typeObjectAdditionalPropertiesAsTrue", | ||
title: "Object with additional properties", | ||
type: "object", | ||
additionalProperties: true | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/design-to-code-react/src/form/controls/utilities/dictionary.spec.pw.snapshot.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { expect, test } from "../../../__tests__/base-fixtures.js"; | ||
|
||
test.describe("additionalProperties", () => { | ||
test.describe("snapshot", () => { | ||
test("object", async ({ page }) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsObject"); | ||
await expect(page).toHaveScreenshot(); | ||
}); | ||
test("true", async ({ page }) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsTrue"); | ||
await expect(page).toHaveScreenshot(); | ||
}); | ||
test("false", async ({ page }) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsFalse"); | ||
await expect(page).toHaveScreenshot(); | ||
}); | ||
}); | ||
}); |
77 changes: 77 additions & 0 deletions
77
packages/design-to-code-react/src/form/controls/utilities/dictionary.spec.pw.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import { expect, test } from "../../../__tests__/base-fixtures.js"; | ||
|
||
test.describe("KeywordAdditionalProperties", () => { | ||
test("should generate an add control if additionalProperties is an object with type is specified", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsObject"); | ||
|
||
await page.waitForSelector(".dtc-form .dtc-dictionary_control-region"); | ||
|
||
const dictionary = await page.locator(".dtc-form .dtc-dictionary_control-region"); | ||
|
||
await expect(await dictionary.count()).toEqual(1); | ||
|
||
await expect( | ||
await dictionary.locator("button.dtc-dictionary_control-add-trigger").count() | ||
).toEqual(1); | ||
}); | ||
test("should add a control if the object with type is specified", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsObject"); | ||
|
||
await page.waitForSelector(".dtc-form .dtc-dictionary_control-region"); | ||
|
||
const dictionaryItems = page.locator(".dtc-dictionary_item-control-region"); | ||
|
||
await expect(await dictionaryItems.count()).toEqual(0); | ||
|
||
await page.locator("button.dtc-dictionary_control-add-trigger").click(); | ||
|
||
await expect(await dictionaryItems.count()).toEqual(1); | ||
}); | ||
test("should generate an add control if additionalProperties is true", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsTrue"); | ||
|
||
await page.waitForSelector(".dtc-form .dtc-dictionary_control-region"); | ||
|
||
const dictionary = await page.locator(".dtc-form .dtc-dictionary_control-region"); | ||
|
||
await expect(await dictionary.count()).toEqual(1); | ||
|
||
await expect( | ||
await dictionary.locator("button.dtc-dictionary_control-add-trigger").count() | ||
).toEqual(1); | ||
}); | ||
test("should add an untyped control if additionalProperties is true", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsTrue"); | ||
|
||
await page.waitForSelector(".dtc-form .dtc-dictionary_control-region"); | ||
|
||
const dictionaryItems = page.locator(".dtc-dictionary_item-control-region"); | ||
|
||
await expect(await dictionaryItems.count()).toEqual(0); | ||
|
||
await page.locator("button.dtc-dictionary_control-add-trigger").click(); | ||
|
||
await expect(await dictionaryItems.count()).toEqual(1); | ||
|
||
await expect(await page.locator(".dtc-untyped-control").count()).toEqual(1); | ||
}); | ||
test("should not generate controls if additionalProperties is false", async ({ | ||
page, | ||
}) => { | ||
await page.goto("/form?schema=keywordAdditionalPropertiesAsFalse"); | ||
|
||
const dictionaryControl = await page.locator( | ||
".dtc-form .dtc-dictionary_control-region" | ||
); | ||
|
||
await expect(await dictionaryControl.count()).toEqual(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/design-to-code/src/web-components/style/common.add-item.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
.dtc-common-add-item { | ||
cursor: pointer; | ||
position: relative; | ||
appearance: none; | ||
background: none; | ||
|
1 change: 1 addition & 0 deletions
1
packages/design-to-code/src/web-components/style/common.label-region.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/design-to-code/src/web-components/style/common.remove-item.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters