Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
18 changes: 18 additions & 0 deletions .github/workflows/mynah-ui-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Mynah UI CI
on:
push:
branches:
- main
paths:
- 'mynah-ui/**'
pull_request:
paths:
- 'mynah-ui/**'

jobs:
lint:
uses: ./.github/workflows/mynah-ui-lint.yml
unit-tests:
uses: ./.github/workflows/mynah-ui-unit-tests.yml
e2e-linux:
uses: ./.github/workflows/mynah-ui-e2e-linux.yml
78 changes: 78 additions & 0 deletions .github/workflows/mynah-ui-e2e-linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Mynah UI - E2E Tests (Linux)
on:
workflow_call:
push:
branches:
- main
paths:
- 'mynah-ui/**'
pull_request:
paths:
- 'mynah-ui/**'

jobs:
e2e-linux:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' }}
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build E2E tests Docker Image (with cache)
if: ${{ github.event.pull_request.head.repo.full_name == github.repository || github.event_name == 'push' }}
uses: docker/build-push-action@v5
with:
context: ./mynah-ui
push: false
load: true
tags: mynah-ui-e2e:latest
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/mynah-ui-e2e:buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/mynah-ui-e2e:buildcache,mode=max

- name: Build E2E tests Docker Image (no cache - fork PRs)
if: ${{ github.event.pull_request.head.repo.full_name != github.repository && github.event_name != 'push' }}
uses: docker/build-push-action@v5
with:
context: ./mynah-ui
push: false
load: true
tags: mynah-ui-e2e:latest

- name: Run E2E tests Docker Container
run: npm run docker:run
working-directory: ./mynah-ui
env:
WEBKIT_FORCE_COMPLEX_TEXT: 0
WEBKIT_DISABLE_COMPOSITING_MODE: 1
PLAYWRIGHT_BROWSERS_PATH: 0

- name: Extract test results from Docker container
if: always()
run: npm run docker:extract
working-directory: ./mynah-ui

- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: mynah-ui-test-results
path: ./mynah-ui/ui-tests/__results__
retention-days: 30

report:
needs: e2e-linux
if: always()
uses: ./.github/workflows/mynah-ui-test-report.yml
35 changes: 35 additions & 0 deletions .github/workflows/mynah-ui-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Mynah UI - Lint
on:
workflow_call:
push:
branches:
- main
paths:
- 'mynah-ui/**'
pull_request:
paths:
- 'mynah-ui/**'

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build && cd ./ui-tests && npm install && cd ..
working-directory: ./mynah-ui

- name: Run linter
run: npm run lint
working-directory: ./mynah-ui
22 changes: 22 additions & 0 deletions .github/workflows/mynah-ui-test-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Mynah UI - Test Report
on: workflow_call

permissions:
contents: read
actions: read
checks: write

jobs:
report:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- uses: dorny/test-reporter@v2.0.0
with:
name: Mynah UI E2E Tests Report
artifact: mynah-ui-test-results
path: ./__reports__/junit.xml
reporter: jest-junit
fail-on-error: false
41 changes: 41 additions & 0 deletions .github/workflows/mynah-ui-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Mynah UI - Unit Tests
on:
workflow_call:
push:
branches:
- main
paths:
- 'mynah-ui/**'
pull_request:
paths:
- 'mynah-ui/**'

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: '24.x'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build
working-directory: ./mynah-ui

- name: Run Unit tests
run: npm run test:unit
working-directory: ./mynah-ui

- name: Upload coverage reports
uses: actions/upload-artifact@v4
with:
name: mynah-ui-coverage-report
path: ./mynah-ui/coverage
8 changes: 6 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ build
*.tsbuildinfo
app/aws-lsp-partiql-*

# Mynah
!mynah-ui/dist
# Mynah UI
mynah-ui/__results__/
mynah-ui/e2e-results/
mynah-ui/ui-tests/__results__/
mynah-ui/ui-tests/__snapshots__/
mynah-ui/**api-docs

# Coverage (C8)
**/coverage/
2 changes: 1 addition & 1 deletion chat-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@aws/chat-client-ui-types": "0.1.68",
"@aws/language-server-runtimes": "^0.3.12",
"@aws/language-server-runtimes-types": "^0.1.63",
"@aws/mynah-ui": "^4.38.0"
"@aws/mynah-ui": "*"
},
"devDependencies": {
"@types/jsdom": "^21.1.6",
Expand Down
19 changes: 9 additions & 10 deletions chat-client/src/client/chat.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ describe('Chat', () => {

before(() => {
// Mock global observers for test environment
// @ts-expect-error: mock implementation for testing
global.ResizeObserver = null
// @ts-expect-error: mock implementation for testing
global.IntersectionObserver = null
// @ts-expect-error: mock implementation for testing
global.MutationObserver = null
/* eslint-disable @typescript-eslint/no-explicit-any */
;(global as any).ResizeObserver = null
;(global as any).IntersectionObserver = null
;(global as any).MutationObserver = null
/* eslint-enable @typescript-eslint/no-explicit-any */
})

beforeEach(() => {
Expand All @@ -65,10 +64,10 @@ describe('Chat', () => {
})

after(() => {
// @ts-expect-error: mock implementation for testing
global.ResizeObserver = undefined
// @ts-expect-error: mock implementation for testing
global.MutationObserver = undefined
/* eslint-disable @typescript-eslint/no-explicit-any */
;(global as any).ResizeObserver = undefined
;(global as any).MutationObserver = undefined
/* eslint-enable @typescript-eslint/no-explicit-any */
})

it('publishes ready event when initialized', () => {
Expand Down
2 changes: 1 addition & 1 deletion chat-client/src/client/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const getDefaultTabConfig = (agenticMode?: boolean) => {
}
}

type ChatClientConfig = Pick<MynahUIDataModel, 'quickActionCommands'> & {
type ChatClientConfig = Partial<Pick<MynahUIDataModel, 'quickActionCommands'>> & {
disclaimerAcknowledged?: boolean
pairProgrammingAcknowledged?: boolean
agenticMode?: boolean
Expand Down
6 changes: 2 additions & 4 deletions chat-client/src/client/mynahUi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,10 +405,9 @@ describe('MynahUI', () => {
const getTabDataStub = sinon.stub(mynahUi, 'getTabData')
getTabDataStub.returns({
getStore: () => ({
// @ts-expect-error partial object
promptInputOptions: [{ id: 'pair-programmer-mode', value: 'false' }],
}),
})
} as any)

handlePromptInputChange(mynahUi, tabId, { 'pair-programmer-mode': 'true' })

Expand All @@ -420,10 +419,9 @@ describe('MynahUI', () => {
const getTabDataStub = sinon.stub(mynahUi, 'getTabData')
getTabDataStub.returns({
getStore: () => ({
// @ts-expect-error partial object
promptInputOptions: [{ id: 'pair-programmer-mode', value: 'true' }],
}),
})
} as any)

handlePromptInputChange(mynahUi, tabId, { 'pair-programmer-mode': 'false' })

Expand Down
25 changes: 25 additions & 0 deletions mynah-ui/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
*.js
*.json
*.md
*.css
*.ttf
*.scss
*.svg
*.png
*.map
*.html
*.xml
*.zip
.github
.husky
example
api-docs
dist
docs
out
LICENSE
THIRD-PARTY-LICENSES
NOTICE
Dockerfile
e2e-results
coverage/
33 changes: 33 additions & 0 deletions mynah-ui/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
node: true,
},
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir: __dirname,
ecmaVersion: 'latest',
sourceType: 'module',
project: ['./tsconfig.json', './tsconfig.test.json'],
},
plugins: ['@typescript-eslint', 'unused-imports'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended'],
ignorePatterns: ['ui-tests/**', 'dist/**', 'coverage/**', 'node_modules/**', '*.js'],
rules: {
semi: ['error', 'never'],
'no-constant-condition': ['error', { checkLoops: false }],
'no-case-declarations': 'off',
'no-empty': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-floating-promises': 'off',
'@typescript-eslint/no-explicit-any': 0,
'@typescript-eslint/explicit-module-boundary-types': 0,
'@typescript-eslint/no-non-null-assertion': 0,
'@typescript-eslint/no-unused-vars': 0,
'@typescript-eslint/no-unused-expressions': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
'unused-imports/no-unused-imports': 'error',
},
}
49 changes: 49 additions & 0 deletions mynah-ui/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Version-agnostic Dockerfile for Mynah UI E2E Tests
# Supports dynamic Playwright version detection
ARG PLAYWRIGHT_VERSION=latest
FROM mcr.microsoft.com/playwright:${PLAYWRIGHT_VERSION}

# Set working directory
WORKDIR /app

# Copy the src from the mynah-ui package
COPY ./src /app/src

# Copy config files from mynah-ui root
COPY ./package.json /app
COPY ./webpack.config.js /app
COPY ./tsconfig.json /app

# Copy scripts directory for version-agnostic setup
COPY ./scripts /app/scripts

# Copy required files from ui-tests
COPY ./ui-tests/package.json /app/ui-tests/
COPY ./ui-tests/playwright.config.ts /app/ui-tests/
COPY ./ui-tests/tsconfig.json /app/ui-tests/
COPY ./ui-tests/webpack.config.js /app/ui-tests/

# Copy the directories from ui-tests
COPY ./ui-tests/__test__ /app/ui-tests/__test__
COPY ./ui-tests/src /app/ui-tests/src
COPY ./ui-tests/__snapshots__ /app/ui-tests/__snapshots__

# Install dependencies and build MynahUI
RUN npm install
RUN npm run build

# Setup Playwright with version-agnostic approach
RUN cd ./ui-tests && node ../scripts/setup-playwright.js && npm run prepare

# Ensure all browsers are installed with dependencies
RUN cd ./ui-tests && npx playwright install --with-deps

# Run health check to verify installation
RUN cd ./ui-tests && node ../scripts/docker-health-check.js

# Set environment variables for WebKit
ENV WEBKIT_FORCE_COMPLEX_TEXT=0
ENV WEBKIT_DISABLE_COMPOSITING_MODE=1

# Default command to run the tests
CMD ["sh", "-c", "cd ./ui-tests && npm run e2e${BROWSER:+:$BROWSER}"]
Loading
Loading