Skip to content

Commit 02ab6fd

Browse files
authored
chore: Sync examples changes (#213)
1 parent a2708c2 commit 02ab6fd

File tree

8 files changed

+40
-24
lines changed

8 files changed

+40
-24
lines changed

jest.config.e2e.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: MIT-0
3+
4+
module.exports = {
5+
preset: 'ts-jest',
6+
testEnvironment: 'node',
7+
testMatch: ['<rootDir>/test/**/*.test.ts'],
8+
setupFilesAfterEnv: ['./setupJest.js'],
9+
globalSetup: './start-chromedriver.js',
10+
globalTeardown: './stop-chromedriver.js',
11+
};

jest.config.unit.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: MIT-0
3+
/** @type {import('jest').Config} */
4+
module.exports = {
5+
preset: 'ts-jest',
6+
testEnvironment: 'jsdom',
7+
testMatch: ['<rootDir>/src/**/__tests__/**/*.test.ts'],
8+
collectCoverage: true,
9+
// For cloudscape-design/demos, where all unit tests are excluded
10+
passWithNoTests: true,
11+
};

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
"start": "npm run start:theme",
1414
"start:theme": "cross-env NODE_ENV=development THEME=$npm_config_theme webpack-dev-server",
1515
"serve": "node ./scripts/dev-server.js",
16-
"jest": "node --experimental-vm-modules ./node_modules/.bin/jest ./test/**/*.test.ts",
16+
"jest": "node --experimental-vm-modules ./node_modules/.bin/jest -c jest.config.e2e.js",
1717
"serve-test": "run-p -r serve jest",
1818
"pretest": "npm-run-all -s clean lint typecheck build",
1919
"test": "npm run test-no-build",
20+
"test:unit": "node --experimental-vm-modules ./node_modules/.bin/jest -c jest.config.unit.js",
2021
"test-no-build": "run-s test:*",
2122
"test:default": "cross-env ALWAYS_VISUAL_REFRESH=true npm run serve-test"
2223
},
@@ -78,7 +79,7 @@
7879
"webpack": "^5.98.0",
7980
"webpack-cli": "^6.0.1",
8081
"webpack-dev-server": "^5.2.1",
81-
"zod": "^3.23.8"
82+
"zod": "^4.0.16"
8283
},
8384
"browserslist": [
8485
"last 3 Chrome major versions",

src/common/parse-property-filter.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,17 @@ import { PropertyFilterQuery } from '@cloudscape-design/collection-hooks';
77
const PropertyFilterOperation = z.enum(['and', 'or']);
88

99
const propertyFilterTokenSchema = z.object({
10-
// There's no other way to enforce this value as required. Using z.any() allows it to be optional, which breaks our types
11-
value: z.object({}).passthrough().or(z.array(z.any())).or(z.string()).or(z.number()).or(z.boolean()),
10+
value: z.any(),
1211
propertyKey: z.string().optional(),
1312
operator: z.string(),
1413
});
1514

16-
const propertyFilterQueryBaseSchema = z.object({
15+
const propertyFilterQuerySchema = z.object({
1716
tokens: z.array(propertyFilterTokenSchema),
1817
operation: PropertyFilterOperation,
19-
});
20-
21-
// workaround to validate recursive types: https://zod.dev/?id=recursive-types
22-
// fyi: same problem in yup and valibot
23-
type PropertyFilterQuerySchemaType = z.infer<typeof propertyFilterQueryBaseSchema> & {
24-
tokenGroups?: PropertyFilterQuery['tokenGroups'];
25-
};
26-
27-
const propertyFilterQuerySchema: z.ZodType<PropertyFilterQuerySchemaType> = propertyFilterQueryBaseSchema.extend({
28-
tokenGroups: z.lazy(() => z.array(z.union([propertyFilterTokenSchema, propertyFilterQuerySchema])).optional()),
18+
get tokenGroups() {
19+
return z.array(z.union([propertyFilterTokenSchema, propertyFilterQuerySchema])).optional();
20+
},
2921
});
3022

3123
export const parsePropertyFilterQuery = (stringifiedPropertyFilter: string): PropertyFilterQuery => {

src/pages/chat/chat.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ export default function Chat() {
186186

187187
<FittedContainer>
188188
<Container
189+
data-testid="chat-container"
189190
header={<Header variant="h3">Generative AI chat</Header>}
190191
fitHeight
191192
disableContentPaddings

test/e2e/page/edit-form-page-object.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export default class Page extends AppLayoutPage {
1414
}
1515
async openAdditionalTools() {
1616
await this.scrollIntoViewAndClick(
17-
page.findContainer().findFooter().findExpandableSection().findHeader().toSelector(),
17+
page.findContainer().findFooter().findExpandableSection().findExpandButton().toSelector(),
1818
);
1919
}
2020
async openMainInfoLink() {

test/e2e/page/form-template-page-object.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ function expandableSectionItems(index: number) {
1111
return page.findSideNavigation().findItemByIndex(index).findItems().toSelector();
1212
}
1313

14-
function formExpandableSectionHeader(id: string) {
15-
return page.findContainer(id).findFooter().findExpandableSection().findHeader().toSelector();
14+
function formExpandableSectionExpandButton(id: string) {
15+
return page.findContainer(id).findFooter().findExpandableSection().findExpandButton().toSelector();
1616
}
1717
function formExpandableSection(id: string) {
1818
return page.findContainer(id).findFooter().findExpandableSection().findContent().toSelector();
1919
}
2020
export default class Page extends FormPage {
2121
async expandChangeBehaviorPanel() {
22-
await this.scrollIntoViewAndClick(formExpandableSectionHeader('#cache-behavior-panel'));
22+
await this.scrollIntoViewAndClick(formExpandableSectionExpandButton('#cache-behavior-panel'));
2323
}
2424
async expandDistributionPanel() {
25-
await this.scrollIntoViewAndClick(formExpandableSectionHeader('#distribution-panel'));
25+
await this.scrollIntoViewAndClick(formExpandableSectionExpandButton('#distribution-panel'));
2626
}
2727
isExpandChangeBehaviorContentVisible() {
2828
return this.isDisplayed(formExpandableSection('#cache-behavior-panel'));

0 commit comments

Comments
 (0)