Skip to content

Commit

Permalink
Fix failing test and add unit tests to PR checks (ansible#182)
Browse files Browse the repository at this point in the history
* root element

* Add unit testing to PR checks

* increased timeout for checking that react has loaded

* updated config

* fix for prepush failure

* update prettierignore
  • Loading branch information
vidyanambiar authored Jan 20, 2023
1 parent e3eee46 commit 0835d18
Show file tree
Hide file tree
Showing 7 changed files with 902 additions and 878 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ jobs:
key: modules-${{ hashFiles('package-lock-copy.json') }}
- run: npm run cypress

cypress-unit:
name: Cypress Unit Tests
runs-on: ubuntu-latest
needs: packages
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '18'
- name: PreCache
run: cat package-lock.json | jq '.version = "0.0.0"' | jq '.packages."".version = "0.0.0"' > package-lock-copy.json
- name: Cache dependencies
id: cache
uses: actions/cache@v3
with:
path: |
./node_modules
/home/runner/.cache/Cypress
key: modules-${{ hashFiles('package-lock-copy.json') }}
- run: npm run test:unit

eslint:
name: ESLint
runs-on: ubuntu-latest
Expand Down
9 changes: 8 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Ignore generated interfaces
frontend/controller/interfaces/generated-from-swagger
frontend/controller/interfaces/generated-from-swagger

.dockerignore
.gitignore
Dockerfile
*.png
*.svg
*.sh
5 changes: 0 additions & 5 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ export default defineConfig({
},
},
},
env: {
'cypress-react-selector': {
root: '#__cy_root',
},
},
specPattern: 'frontend/controller/**/*.cy.tsx',
supportFile: 'cypress/support/component.ts',
},
Expand Down
8 changes: 6 additions & 2 deletions frontend/controller/views/jobs/hooks/useJobFilters.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ function TestInner(props: { filters: IToolbarFilter[] }) {

function Test() {
const jobFilters = useJobsFilters();
return <TestInner filters={jobFilters} />;
return (
<div id="root">
<TestInner filters={jobFilters} />
</div>
);
}

describe('useJobsFilters', () => {
it('Returns expected number of filters', () => {
cy.mount(<Test />);
cy.waitForReact();
cy.waitForReact(10000, '#root');
cy.getReact('TestInner').getProps('filters').should('have.length', 7);
});
});
1,662 changes: 831 additions & 831 deletions locales/fr/translation.json

Large diffs are not rendered by default.

66 changes: 33 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"tsc": "tsc -v && tsc --noEmit",
"eslint": "eslint --max-warnings=0 frontend proxy framework cypress",
"eslint:fix": "eslint --fix frontend proxy framework cypress",
"eslint:changed": "eslint --max-warnings=0 $(git diff --name-only origin/main -- '*.ts' '*.tsx' '*.jsx' '*.js'| xargs)",
"eslint:changed": "eslint --max-warnings=0 $(git diff --name-only --diff-filter=M origin/main -- '*.ts' '*.tsx' '*.jsx' '*.js'| xargs)",
"prettier": "prettier --check !**/*.scss frontend proxy framework cypress",
"prettier:fix": "prettier --write frontend proxy framework cypress",
"prettier:changed": "prettier --check $(git diff --name-only origin/main | xargs)",
"prettier:changed:fix": "prettier --write $(git diff --name-only origin/main | xargs)",
"prettier:changed": "prettier --check $(git diff --name-only --diff-filter=M origin/main | xargs)",
"prettier:changed:fix": "prettier --write $(git diff --name-only --diff-filter=M origin/main | xargs)",
"upgrade": "npx npm-check-updates '/^@patternfly.*$/' --upgrade --target latest --doctor && npx npm-check-updates '/^(?!@patternfly).*$/' --upgrade --target minor --doctor && npm audit fix || true && npm dedup || true ",
"docker:build": "docker build --tag ansible/console .",
"docker:run": "npm run docker:build && docker run --rm -e LOG_LEVEL=debug -p 3001:3001 -e PORT=3001 -v $PWD/certs:/home/node/certs ansible/console| pino-zen",
Expand Down Expand Up @@ -169,8 +169,5 @@
"../frontend/src/**/*.ts",
"../frontend/src/**/*.tsx"
]
},
"overrides": {
"resq": "^1.11.0"
}
}

0 comments on commit 0835d18

Please sign in to comment.