diff --git a/.changeset/weak-snakes-tie.md b/.changeset/weak-snakes-tie.md new file mode 100644 index 000000000..5ab612b4d --- /dev/null +++ b/.changeset/weak-snakes-tie.md @@ -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 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 878c32b5c..016ad40a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/packages/app/src/App.ts b/packages/app/src/App.ts index 2fb7617dc..3e61d41a2 100644 --- a/packages/app/src/App.ts +++ b/packages/app/src/App.ts @@ -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) { diff --git a/packages/integration-tests/.testcaferc.json b/packages/integration-tests/.testcaferc.json index 3407bb199..69913dbbe 100644 --- a/packages/integration-tests/.testcaferc.json +++ b/packages/integration-tests/.testcaferc.json @@ -5,6 +5,8 @@ "src": "tests/*test.js", "browsers": ["chrome:headless"], "concurrency": 3, + "selectorTimeout": 5000, + "assertionTimeout": 5000, "appCommand": "yarn start", "screenshots": { "takeOnFails": true diff --git a/packages/integration-tests/tests/app.test.js b/packages/integration-tests/tests/app.test.js index d7dcfd2ec..c669a1ed2 100644 --- a/packages/integration-tests/tests/app.test.js +++ b/packages/integration-tests/tests/app.test.js @@ -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', ], }) }) @@ -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) @@ -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 diff --git a/packages/integration-tests/tests/recommendations.test.js b/packages/integration-tests/tests/recommendations.test.js index 6162ce7a7..945fcb724 100644 --- a/packages/integration-tests/tests/recommendations.test.js +++ b/packages/integration-tests/tests/recommendations.test.js @@ -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) => {