Skip to content

Commit 7970826

Browse files
committed
Merge remote-tracking branch 'upstream/main' into add-auth-example-entra-id-saml
2 parents 205218b + 58be951 commit 7970826

File tree

259 files changed

+5384978
-2853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

259 files changed

+5384978
-2853
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ on:
33
pull_request:
44
branches: [main, next-release/main]
55
types: [opened, synchronize]
6+
env:
7+
BUILD_DIR: 'client/www/next-build'
68
jobs:
79
build:
810
name: Build
@@ -17,8 +19,14 @@ jobs:
1719
- name: Install Dependencies
1820
run: yarn
1921
- name: Run tests
20-
run: yarn prebuild && yarn test
22+
run: yarn prebuild && yarn test:unit
2123
- name: Run Build
2224
run: yarn build
2325
env:
2426
NODE_OPTIONS: --max_old_space_size=4096
27+
- name: Run site
28+
run: |
29+
python -m http.server 3000 -d ${{ env.BUILD_DIR }} &
30+
sleep 5
31+
- name: Run E2E Tests
32+
run: yarn test:e2e

.github/workflows/check_for_broken_links.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
role-to-assume: arn:aws:iam::464149486631:role/github_action_read_slack_webhook_url
3333
aws-region: us-west-2
3434
- name: Read secrets from AWS Secrets Manager into environment variables
35-
uses: aws-actions/aws-secretsmanager-get-secrets@ff26a0aa6bd4dd5e51326b5afb3f5f6874c958c7 # v2.0.3
35+
uses: aws-actions/aws-secretsmanager-get-secrets@98c2d6bf1dd67c2575fa2bb14294aa64103d426c # v2.0.5
3636
with:
3737
secret-ids: |
3838
SLACK_WEBHOOK_URL
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
module.exports = {
2+
invalidRedirects: () => {
3+
const Ajv = require('ajv');
4+
const redirects = require('../../../redirects.json');
5+
const ajv = new Ajv();
6+
7+
const schema = {
8+
type: 'array',
9+
items: {
10+
type: 'object',
11+
required: ['source', 'target', 'status'],
12+
properties: {
13+
source: {
14+
description: 'The address the user requested.',
15+
type: 'string',
16+
pattern: '^/'
17+
},
18+
target: {
19+
description:
20+
'The address that actually serves the content that the user sees',
21+
type: 'string',
22+
pattern: '^[(https)(/)]'
23+
},
24+
status: {
25+
description:
26+
'Types include a permanent redirect (301), a temporary redirect (302), a rewrite (200), or not found (404).',
27+
type: 'string',
28+
pattern: '^[0-5-]+$'
29+
}
30+
}
31+
}
32+
};
33+
34+
const errors = [];
35+
const validate = ajv.compile(schema);
36+
37+
const validateEntries = (redirects) => {
38+
const valid = validate(redirects);
39+
40+
if (!valid) {
41+
const error = validate.errors[0];
42+
const invalidEntry =
43+
JSON.stringify(redirects[error.instancePath.slice(1, -7)]);
44+
const loc = error.schemaPath.slice(error.schemaPath.indexOf('properties') + 11, -8);
45+
const errorMessage = '\n\n' + 'INVALID ENTRY: Please correct the error in the "' + loc +'" property of the following entry: \n' + invalidEntry + '\n' + 'ERROR MESSAGE: ' + error.message;
46+
errors.push(errorMessage);
47+
48+
validateEntries(redirects.splice(parseInt(error.instancePath.slice(1, -7)) + 1));
49+
50+
}
51+
}
52+
validateEntries(redirects);
53+
54+
return errors;
55+
}
56+
}
57+
58+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Receive repository dispatch event
2+
3+
on:
4+
# Listen to a repository dispatch event by the name of `dispatch-event`
5+
repository_dispatch:
6+
types: [update-references]
7+
workflow_dispatch:
8+
env:
9+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10+
11+
jobs:
12+
create-pull-request:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Repo
16+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
17+
18+
- name: Setup Node.js 20
19+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
20+
with:
21+
node-version: 20.x
22+
23+
- name: Set github commit user
24+
env:
25+
GITHUB_EMAIL: ${{ vars.GH_EMAIL }}
26+
GITHUB_USER: ${{ vars.GH_USER }}
27+
run: |
28+
git config --global user.email $GITHUB_EMAIL
29+
git config --global user.name $GITHUB_USER
30+
31+
# Set branch name to be used as environment variable
32+
- name: Set Branch Name
33+
run: echo "BRANCH_NAME=$(echo update-ref-$(date +%s))" >> $GITHUB_ENV
34+
35+
# Create new branch, download, and commit changes to the new branch
36+
- name: Create new branch
37+
run: |
38+
git checkout -b ${{ env.BRANCH_NAME }}
39+
curl -L -o ${{ vars.REF_LOC }} ${{ vars.REMOTE_REF }}
40+
node tasks/clean-references.mjs
41+
git add ${{ vars.REF_LOC }} ${{ vars.CLEAN_LOC }}
42+
git commit -m "updating references"
43+
git push -u origin ${{ env.BRANCH_NAME }}
44+
45+
# Open pull request
46+
- name: Create Pull Request
47+
run: gh pr create -B main -H ${{ env.BRANCH_NAME }} --title 'Merge ${{ env.BRANCH_NAME }} into main' --body 'Created by Github action'
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Validate Redirects
2+
on:
3+
pull_request:
4+
branches: [main]
5+
types: [opened, synchronize]
6+
env:
7+
BUILD_DIR: 'client/www/next-build'
8+
permissions:
9+
contents: read
10+
jobs:
11+
ValidateRedirects:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
16+
- name: Setup Node.js 20.x
17+
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
18+
with:
19+
node-version: 20.x
20+
- name: Install Dependencies
21+
run: yarn
22+
- name: Validate redirects
23+
id: redirects
24+
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
25+
with:
26+
result-encoding: string
27+
script: |
28+
const { invalidRedirects } = require('./.github/workflows/scripts/validate-redirects.js');
29+
return await invalidRedirects();
30+
- name: Fail if any invalid redirects have been found
31+
if: ${{ steps.redirects.outputs.result }}
32+
run: exit 1 && echo ${{ steps.redirects.outputs.result }}

Readme.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ When linking to other pages within the docs.amplify.aws site, do not use relativ
9191

9292
To incorporate new platform-specific content within a page, please use [Inline Filters](https://github.com/aws-amplify/docs/blob/main/Readme.md#inline-filters).
9393

94-
When editing content that hasn't been migrated, you may see the following pattern:
94+
Please note: we do allow fragments in some cases where content is intended to be reused and cannot be via InlineFilters
95+
96+
When editing content that hasn't been migrated to InlineFilters, you may see the following pattern:
9597

9698
```jsx
9799
import js from '/src/fragments/lib/datastore/js/conflict.mdx';
@@ -173,7 +175,7 @@ let mut a = String::from("a");
173175
Videos can be added using the `<Video />` component and referencing a path to the video file. The video should be an `.mp4` file and should exist in the `/public` directory
174176

175177
```jsx
176-
<Video src="/path/to/video.mp4" />
178+
<Video src="/path/to/video.mp4" description="Video - [video description]" />
177179
```
178180

179181
## Accessibility testing

cspell.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,12 @@
532532
"Didfinishlaunchingwithoptions",
533533
"displayMode",
534534
"displayOrder",
535+
"dists",
535536
"DocSet",
536537
"DocSets",
537538
"Donef",
538539
"Dont",
540+
"dotenvx",
539541
"downcasting",
540542
"dropdown",
541543
"dynamoDB",
@@ -593,6 +595,7 @@
593595
"Figma",
594596
"Figma's",
595597
"figma",
598+
"fileuploader",
596599
"architected",
597600
"newsfeeds",
598601
"textareas",
@@ -1242,7 +1245,6 @@
12421245
"Storage.put",
12431246
"storagebucketname",
12441247
"storagedemo",
1245-
"storagemanager",
12461248
"storageOptions",
12471249
"storagepath",
12481250
"StoragePath",
@@ -1394,6 +1396,7 @@
13941396
"validationData",
13951397
"vanillajs",
13961398
"varchar",
1399+
"vendedlogs",
13971400
"verify.js",
13981401
"VerifyAuthChallengeResponse",
13991402
"VeriSign",

e2e/homepage.test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
const { AxePuppeteer } = require('@axe-core/puppeteer');
3+
4+
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
5+
6+
describe('home page', () => {
7+
beforeAll(async () => {
8+
await page.goto(`http://localhost:3000/`);
9+
await page.waitForSelector('h1');
10+
});
11+
12+
it('should display the home page with no accessibility violations', async () => {
13+
const results = await new AxePuppeteer(page).analyze();
14+
expect(results.violations).toHaveLength(0);
15+
});
16+
17+
it('should display the home page with no accessibility violations in dark mode', async () => {
18+
await page.click('button[title="Dark mode"]');
19+
await sleep(300);
20+
const results = await new AxePuppeteer(page).analyze();
21+
expect(results.violations).toHaveLength(0);
22+
});
23+
});

e2e/jest.e2e.config.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
rootDir: './',
3+
preset: 'jest-puppeteer',
4+
testMatch: ['<rootDir>/*.test.js']
5+
};

jest.config.js

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,7 @@
11
module.exports = {
2-
preset: './preset.js',
32
rootDir: './',
4-
roots: ['<rootDir>/src', '<rootDir>/tasks'],
5-
testEnvironment: 'jsdom',
6-
transform: {
7-
'^.+\\.(ts|tsx|js|mjs)$': [
8-
'babel-jest',
9-
{
10-
presets: ['next/babel']
11-
}
12-
]
13-
},
14-
testPathIgnorePatterns: ['capi', '.next', 'client'],
15-
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
16-
moduleNameMapper: {
17-
'\\.(css|less|scss)$': '<rootDir>/src/__mocks__/styleMock.js',
18-
'@docsearch/css(.*)': '<rootDir>/src/__mocks__/styleMock.js',
19-
'@/components/(.*)': '<rootDir>/src/components/$1',
20-
'@/constants/(.*)': '<rootDir>/src/constants/$1',
21-
'@/utils/(.*)': '<rootDir>/src/utils/$1',
22-
'@/data/(.*)': '<rootDir>/src/data/$1',
23-
'@/directory/(.*)': '<rootDir>/src/directory/$1',
24-
'@/themes/(.*)': '<rootDir>/src/themes/$1'
25-
},
26-
transformIgnorePatterns: ['node_modules/(?!variables/.*)']
3+
projects: [
4+
'<rootDir>/jest.unit.config.js',
5+
'<rootDir>/e2e/jest.e2e.config.js'
6+
]
277
};

0 commit comments

Comments
 (0)