Skip to content

Commit

Permalink
Merge pull request #23 from no10ds/fix/v7-ui
Browse files Browse the repository at this point in the history
Fix UI v7.0.0
  • Loading branch information
TobyDrane authored Sep 1, 2023
2 parents 65abc86 + c1fcdbc commit 65c39e8
Show file tree
Hide file tree
Showing 13 changed files with 531 additions and 394 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ui-tests.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
name: rAPId Integration Tests

on:

workflow_dispatch:

pull_request:
types:
- opened

jobs:

run-ui-test:
runs-on: self-hosted

Expand All @@ -30,11 +28,9 @@ jobs:
cd ui
npm install @playwright/test -D
- name: run playwright tests
run: |
cd ui
npx playwright test ui/playwright
- name: Run playwright tests
run: make ui-test-e2e
env:
DOMAIN: "https://${{ secrets.DOMAIN_NAME }}"
DOMAIN_NAME: "https://${{ secrets.DOMAIN_NAME }}"
RESOURCE_PREFIX: ${{ secrets.RESOURCE_PREFIX }}
AWS_REGION: ${{ secrets.AWS_REGION }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,5 @@ docs/_build/
.terraform.lock.hcl

ui/playwright/.auth
ui/playwright/.downloads
ui/playwright/.downloads
ui/test-results/
69 changes: 37 additions & 32 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,70 +1,75 @@
exclude: '^ui'
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: check-yaml
- id: check-json
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/bandit
- id: check-yaml
- id: check-json
- id: check-merge-conflict
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
hooks:
- id: bandit
- id: bandit
exclude: '(test|docs)/*'
- repo: https://github.com/psf/black
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
- repo: https://github.com/Yelp/detect-secrets
- id: black
- repo: https://github.com/Yelp/detect-secrets
rev: v1.3.0
hooks:
- id: detect-secrets
- id: detect-secrets
exclude: docs/
- repo: https://github.com/asottile/blacken-docs
- repo: https://github.com/asottile/blacken-docs
rev: v1.12.1
hooks:
- id: blacken-docs
- repo: https://github.com/PyCQA/flake8
- id: blacken-docs
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
hooks:
- id: flake8
- id: flake8
args: ['--config', 'api/.flake8']
exclude: (docs/|get_latest_release_changelog.py)
# - repo: https://github.com/PyCQA/pylint
# rev: v2.15.5
# hooks:
# - id: pylint
# exclude: (docs/|get_latest_release_changelog.py)
- repo: https://github.com/antonbabenko/pre-commit-terraform
# - repo: https://github.com/PyCQA/pylint
# rev: v2.15.5
# hooks:
# - id: pylint
# exclude: (docs/|get_latest_release_changelog.py)
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.81.0
hooks:
- id: terraform_fmt
- id: terraform_fmt
exclude: '^(?!infrastructure/).*'
- id: terraform_validate
- id: terraform_validate
exclude: '^(?!infrastructure/).*'
- id: terraform_docs
- id: terraform_docs
args:
- markdown table --recursive --output-file README.md .
- markdown table --recursive --output-file README.md .
exclude: '^(?!infrastructure/).*'
- repo: https://github.com/bridgecrewio/checkov.git
- repo: https://github.com/bridgecrewio/checkov.git
rev: 2.3.261
hooks:
- id: checkov
- id: checkov
args: [--quiet, --compact]
exclude: '^(?!infrastructure/).*'
- repo: local
- repo: local
hooks:
- id: sdk_test
- id: sdk_test
name: sdk_test
language: system
entry: bash -c 'make sdk-test'
files: sdk/*.
pass_filenames: false
- repo: local
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: ui_test
- id: prettier
args: ['--config', 'ui/.prettierrc.json', './ui']
- repo: local
hooks:
- id: ui_test
name: ui_test
language: system
entry: bash -c 'cd ./ui; npm run test:all'
Expand Down
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ ui-run-dev: ## Run the ui application with hot reload
ui-test: ## Test ui site
@cd ui/; npm run test:all

ui-test-e2e:
@cd ui/; npx playwright test ui/playwright

ui-test-e2e-headed:
@cd ui/; npx playwright test ui/playwright --ui

# UI Release --------------------
##
ui-create-static-out:
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/modules/app-cluster/cloudtrail.tf
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ resource "aws_kms_key" "access_logs_key" {
description = "This key is used to encrypt the access log objects"
policy = data.aws_iam_policy_document.access_logs_key_policy.json
tags = var.tags
enable_key_rotation = false
enable_key_rotation = true
}

resource "aws_cloudwatch_log_group" "access_logs_log_group" {
Expand Down
9 changes: 4 additions & 5 deletions infrastructure/modules/data-workflow/dynamodb.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
resource "aws_dynamodb_table" "schema_table" {
# checkov:skip=CKV_AWS_119:No need for customer managed keys
name = "${var.resource-name-prefix}_schema_table"
hash_key = "PK"
range_key = "SK"
billing_mode = "PAY_PER_REQUEST"
stream_enabled = true
name = "${var.resource-name-prefix}_schema_table"
hash_key = "PK"
range_key = "SK"
billing_mode = "PAY_PER_REQUEST"
attribute {
name = "PK"
type = "S"
Expand Down
52 changes: 17 additions & 35 deletions ui/playwright/auth.setup.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
import { test as setup, expect } from '@playwright/test';
import { SecretsManager } from 'aws-sdk'
import { test as setup, expect } from '@playwright/test'
import { domain, getSecretValue } from './utils'

const client = new SecretsManager({ region: process.env.AWS_REGION })
const authFile = 'playwright/.auth/user.json';
const domain = process.env.DOMAIN;
const authFile = 'playwright/.auth/user.json'
const secretName = `${process.env.RESOURCE_PREFIX}_UI_TEST_USER`


export async function getSecretValue(
secretName: string
): Promise<string | void> {
return new Promise((resolve, reject) => {
client.getSecretValue({ SecretId: secretName }, function (err, data) {
if (err) {
reject(err)
} else {
resolve(data.SecretString)
}
})
})
}


setup('authenticate', async ({ page }) => {
const secret = JSON.parse(await getSecretValue(secretName) as string)
await page.goto(domain);
await page.goto(`${domain}/login`);
const secret = JSON.parse((await getSecretValue(secretName)) as string)
await page.goto(domain)
await page.goto(`${domain}/login`)

await page.locator('[data-testid="login-link"]').click();
await page.locator('[data-testid="login-link"]').click()

await page.locator('[placeholder="Username"]').nth(1).click();
await page.locator('[placeholder="Username"]').nth(1).click()

await page.locator('[placeholder="Password"]').nth(1).click();
await page.locator('[placeholder="Password"]').nth(1).click()

await page.locator('[placeholder="Password"]').nth(1).fill(`${secret['password']}`);
await page.locator('[placeholder="Password"]').nth(1).fill(`${secret['password']}`)

await page.locator('[placeholder="Username"]').nth(1).click();
await page.locator('[placeholder="Username"]').nth(1).click()

await page.locator('[placeholder="Username"]').nth(1).click();
await page.locator('[placeholder="Username"]').nth(1).click()

await page.locator('[placeholder="Username"]').nth(1).fill(`${secret['username']}`);
await page.locator('[placeholder="Username"]').nth(1).fill(`${secret['username']}`)

await page.locator('text=Sign in').nth(3).click();
await expect(page).toHaveURL(domain);
await page.locator('text=Sign in').nth(3).click()
await expect(page).toHaveURL(domain)

await page.context().storageState({ path: authFile });
});
await page.context().storageState({ path: authFile })
})
Loading

0 comments on commit 65c39e8

Please sign in to comment.