Skip to content

Commit

Permalink
chore: configure ESLint for tests (#247)
Browse files Browse the repository at this point in the history
This declares ESLint rules in reference to `oscal-react-library`,
including TypeScript.

Additional support to be added:
- [x] Add `tsconfig.json` and include `typescript` devDependency
- [x] Lint all files
- [x] Include linting workflow check

Closes #164

---------

Co-authored-by: Kyle Laker <klaker@easydynamics.com>
  • Loading branch information
Bronstrom and Kyle Laker authored May 5, 2023
1 parent d341dae commit 44b2246
Show file tree
Hide file tree
Showing 16 changed files with 16,772 additions and 3,259 deletions.
33 changes: 31 additions & 2 deletions .github/workflows/test-container-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,36 @@ env:
CONTAINER_NAME: test_container

jobs:
lint:
name: Lint the code base
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup NodeJS
uses: actions/setup-node@v3
with:
node-version: "lts/*"
cache: "npm"
cache-dependency-path: "end-to-end-tests/package.json"
- name: Globally update npm
run: npm install -g npm@latest
working-directory: end-to-end-tests
- name: Install dependencies
run: npm ci
working-directory: end-to-end-tests
- name: Install lint dependencies
run: |
npm install -g markdownlint-cli
pip install yamllint
working-directory: end-to-end-tests
- name: Lint code base
run: |
# Run built-in JavaScript/JSON linting
npm run lint
working-directory: end-to-end-tests
build_test:
name: Build and Test All-in-One Docker Image
runs-on: ubuntu-latest
Expand Down Expand Up @@ -84,5 +114,4 @@ jobs:
./end-to-end-tests/cypress/videos
- name: Stop Running Container
run:
docker stop ${CONTAINER_NAME}
run: docker stop ${CONTAINER_NAME}
1 change: 1 addition & 0 deletions end-to-end-tests/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
46 changes: 46 additions & 0 deletions end-to-end-tests/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"env": {
"browser": true,
"es2021": true
},
"parser": "@typescript-eslint/parser",
"extends": [
"plugin:json/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:import/typescript",
"prettier"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module",
"requireConfigFile": false
},
"plugins": ["prettier", "json", "import"],
"settings": {
"import/resolver": {
"node": {
"extensions": [".js", ".ts"]
}
}
},
"rules": {
"prettier/prettier": "error",
"import/no-anonymous-default-export": "off",
"import/no-extraneous-dependencies": [
"error",
{ "devDependencies": ["**/*.js", "**/*.ts", "cypress.config.ts"] }
],
"@typescript-eslint/no-unused-vars": [
"error",
{
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_",
"caughtErrorsIgnorePattern": "^_"
}
],
"@typescript-eslint/no-empty-function": "off"
}
}
7 changes: 7 additions & 0 deletions end-to-end-tests/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"printWidth": 100,
"singleQuote": false,
"trailingComma": "es5",
"tabWidth": 2,
"semi": true
}
15 changes: 0 additions & 15 deletions end-to-end-tests/cypress.config.js

This file was deleted.

14 changes: 14 additions & 0 deletions end-to-end-tests/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineConfig } from "cypress";

export default defineConfig({
env: {
base_url: "http://localhost:8080",
api_url: "http://localhost:8080/oscal/v1",
},
chromeWebSecurity: false,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
e2e: { setupNodeEvents(on: any, config: any) {} },
retries: 1,
video: false,
defaultCommandTimeout: 60000,
});
12 changes: 5 additions & 7 deletions end-to-end-tests/cypress/e2e/OSCAL/Drawer.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ const SSP_NAVIGATION = "Enterprise Logging and Auditing System Security Plan";
const CATALOG_NAVIGATION =
"Electronic Version of NIST SP 800-53 Rev 5 Controls and SP 800-53A Rev 5 Assessment Procedures";
const COMPONENT_NAVIGATION = "Test Component Definition";
const PROFILE_NAVIGATION_V4 =
"NIST Special Publication 800-53 Revision 4 MODERATE IMPACT BASELINE";
const PROFILE_NAVIGATION_V5 =
"NIST Special Publication 800-53 Revision 5 MODERATE IMPACT BASELINE";
const PROFILE_NAVIGATION_V4 = "NIST Special Publication 800-53 Revision 4 MODERATE IMPACT BASELINE";
const PROFILE_NAVIGATION_V5 = "NIST Special Publication 800-53 Revision 5 MODERATE IMPACT BASELINE";
const MONGODB_NAVIGATION = "MongoDB Component Definition Example";

describe("The Editor", () => {
Expand All @@ -22,19 +20,19 @@ describe("The Editor", () => {
});

it("loads test component editor", () => {
cy.navToCdefEditor(COMPONENT_NAVIGATION);
cy.navToCdefEditor(COMPONENT_NAVIGATION);
cy.waitForLoad();
cy.contains(COMPONENT_NAVIGATION);
});

it("loads v4 profile editor", () => {
cy.navToProfileEditor(PROFILE_NAVIGATION_V4);
cy.navToProfileEditor(PROFILE_NAVIGATION_V4);
cy.waitForLoad();
cy.contains(PROFILE_NAVIGATION_V4);
});

it("loads v5 profile editor", () => {
cy.navToProfileEditor(PROFILE_NAVIGATION_V5);
cy.navToProfileEditor(PROFILE_NAVIGATION_V5);
cy.waitForLoad();
cy.contains(PROFILE_NAVIGATION_V5);
});
Expand Down
Loading

0 comments on commit 44b2246

Please sign in to comment.