Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#818] Integration tests added to CI #961

Merged
merged 5 commits into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/weak-snakes-tie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@cloud-carbon-footprint/app': patch
'@cloud-carbon-footprint/integration-tests': patch
---

Updates to get integration tests running locally and on CI
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ jobs:
bash <(curl -s https://codecov.io/bash) -f packages/aws/coverage/* -F aws
bash <(curl -s https://codecov.io/bash) -f packages/gcp/coverage/* -F gcp
bash <(curl -s https://codecov.io/bash) -f packages/azure/coverage/* -F azure
# - name: integration tests
# run: yarn test:integration
- name: integration tests
run: yarn test:integration
continue-on-error: true # Temporarily allow continue on failure till we've seen the tests consistently pass on CI
build:
needs: lint-test
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion packages/app/src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export default class App {
const AWS = config.AWS
const GCP = config.GCP
const AZURE = config.AZURE

if (process.env.TEST_MODE) {
return []
}
if (request.region) {
const estimatesForAccounts: EstimationResult[][] = []
for (const account of AWS.accounts) {
Expand Down
2 changes: 2 additions & 0 deletions packages/integration-tests/.testcaferc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"src": "tests/*test.js",
"browsers": ["chrome:headless"],
"concurrency": 3,
"selectorTimeout": 5000,
"assertionTimeout": 5000,
"appCommand": "yarn start",
"screenshots": {
"takeOnFails": true
Expand Down
8 changes: 5 additions & 3 deletions packages/integration-tests/tests/app.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import waitOn from 'wait-on'
import page from './page-model'

fixture`Cloud Carbon Footprint`.page`http://localhost:3000/`
fixture`Cloud Carbon Footprint`.page`http://127.0.0.1:3000/`
.before(async () => {
await waitOn({
resources: [
'http://localhost:3000/',
'http://localhost:4000/api/healthz',
'http://127.0.0.1:3000/',
'http://127.0.0.1:4000/api/healthz',
],
})
})
Expand Down Expand Up @@ -75,6 +75,7 @@ test('carbon equivalency component displays each option when clicked', async (t)
test('emissions breakdown component displays each bar chart when selected', async (t) => {
// Maximize the window in orde for all DOM elements to be visible.
// For some reason this stops this test failing, and can help with debugging.
// In headless mode, issues have been noted that can be resolved by resizing window: https://github.com/DevExpress/testcafe/issues/6739
await t.maximizeWindow()
//sort by account
await t.click(page.dropDownSelector)
Expand All @@ -87,6 +88,7 @@ test('emissions breakdown component displays each bar chart when selected', asyn
await t.expect(page.selected.withText('computeEngine').exists).ok() //todo: minimize dataset-specific selectors

//sort by region
await t.maximizeWindow()
await t.click(page.dropDownSelector)
await t.click(page.regionSelection)
await t.expect(page.selected.withText('us-east-1').exists).ok() //todo: minimize dataset-specific selectors
Expand Down
4 changes: 2 additions & 2 deletions packages/integration-tests/tests/recommendations.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import waitOn from 'wait-on'
import page from './page-model'
const getLocation = ClientFunction(() => document.location.href)

fixture`Cloud Carbon Footprint Recommendations`.page`http://localhost:3000/`
fixture`Cloud Carbon Footprint Recommendations`.page`http://127.0.0.1:3000/`
.before(async () => {
await waitOn({
resources: ['http://localhost:3000/'],
resources: ['http://127.0.0.1:3000/'],
})
})
.beforeEach(async (t) => {
Expand Down