Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
0c83d91
Update firestore-tools and firestore-functions
sufyanAbbasi Apr 3, 2024
d238a88
Revert back to ground-local-dev
sufyanAbbasi Apr 3, 2024
2dd6198
Configure Selenium WebDriver to create a survey with the local emulator
sufyanAbbasi Apr 3, 2024
829029b
Actually add files for end to end testing :)
sufyanAbbasi Apr 3, 2024
c82eb1a
Add --legacy-peer-deps to npm install
sufyanAbbasi Apr 3, 2024
7e3ea3d
Merge branch 'sufy/1696/emulator' into sufy/1699/e2e-testing
sufyanAbbasi Apr 3, 2024
2fed70e
Make option selection more resilient.
sufyanAbbasi Apr 4, 2024
601f13a
Instrument submission verification
sufyanAbbasi Apr 5, 2024
3eec934
Small fixes
sufyanAbbasi Apr 6, 2024
03cd2da
Fix licenses
sufyanAbbasi Apr 6, 2024
90585f7
Merge branch 'master' into sufy/1699/e2e-testing
sufyanAbbasi Apr 11, 2024
733ad14
Regenerate package lock
sufyanAbbasi Apr 11, 2024
a5a3a6b
Better submission wait logic
sufyanAbbasi Apr 12, 2024
8ac301b
Better submission wait logic (part 2)
sufyanAbbasi Apr 12, 2024
4754a10
Add new workflows for e2e tests
sufyanAbbasi Apr 12, 2024
425e087
Merge branch 'master' into sufy/1699/e2e-testing
sufyanAbbasi Apr 12, 2024
897326d
Update github workflow ref
sufyanAbbasi Apr 12, 2024
7cc25d3
Move Github actions to a new branch
sufyanAbbasi Apr 15, 2024
dc9713c
Split up web tests into two.
sufyanAbbasi Apr 24, 2024
427b84f
Add github actions
sufyanAbbasi Apr 24, 2024
f7ddd45
Change e2e test emulator data location from data/local to data/test
sufyanAbbasi Apr 25, 2024
554e686
Merge branch 'sufy/1699/e2e-testing' into sufy/1699/gh-actions
sufyanAbbasi Apr 25, 2024
551699a
Merge branch 'master' into sufy/1699/gh-actions
sufyanAbbasi May 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/e2e-dispatch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Copyright 2024 The Ground Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: End to End Test Dispatchers

on:
workflow_dispatch:

jobs:
createTest:
name: Create a new survey
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18"

- name: Install dependencies
run: npm run build:local

- name: Run create e2e tests
run: npm run test:e2e:create

- name: Store data/local
uses: actions/upload-artifact@v4
with:
name: data-test
path: data/test
retention-days: 1
overwrite: true

submitTest:
needs: createTest
name: Submit to survey
runs-on: ubuntu-latest
steps:
- name: Run submission action
run: |
gh workflow run --repo google/ground-android e2e-dispatch.yml

verifyTest:
needs: submitTest
name: Verify survey submissions
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v1

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: "18"

- name: Install dependencies
run: npm run build:local

- name: Copy Firebase emulator data
uses: actions/download-artifact@v4
with:
name: data-test
path: data/test

- name: Run create e2e tests
run: npm run test:e2e:verify
28 changes: 28 additions & 0 deletions .github/workflows/test-e2e.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Copyright 2024 The Ground Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: End to End Test

on:
issue_comment:
types: [created]

jobs:
e2eTest:
runs-on: ubuntu-latest
timeout-minutes: 5
if: github.event.issue.pull_request && contains(github.event.comment.body, '/e2eTest')
steps:
- name: Run End To End Tests
run: |
gh workflow run e2e-dispatch.yml
4 changes: 2 additions & 2 deletions .github/workflows/test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: ./precheck.sh

- name: Install dependencies
run: npm install
run: npm install --legacy-peer-deps

- name: Run Jasmine tests
run: npm run test-with-coverage
Expand All @@ -71,4 +71,4 @@ jobs:
node-version: "16"

- name: Run Jasmine tests
run: npm run test
run: npm run test
9 changes: 9 additions & 0 deletions e2e-tests/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Compiled JavaScript files
lib/**/*.js
lib/**/*.js.map

# TypeScript v1 declaration files
typings/

# Node.js dependency directory
node_modules/
37 changes: 37 additions & 0 deletions e2e-tests/ground-helpers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Copyright 2019 The Ground Authors.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

export enum LoiType {
DROP_PIN = 'pin',
DRAW_AREA = 'draw',
}

export enum TaskType {
TEXT = 'text',
SELECT_ONE = 'select one',
SELECT_MULTIPLE = 'select multiple',
NUMBER = 'number',
DATE = 'date',
TIME = 'time',
PHOTO = 'photo',
CAPTURE_LOCATION = 'capture location',
}

export enum Role {
DATA_COLLECTOR = 'data collector',
SURVEY_ORGANIZER = 'survey organizer',
VIEWER = 'viewer',
}
52 changes: 52 additions & 0 deletions e2e-tests/spec/create_survey.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright 2024 The Ground Authors.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import 'jasmine';

import {WebDriverHelper} from '../webdriver-helpers.js';
import {TestConfig} from '../test_config.js';

// Increase default timeout.
jasmine.DEFAULT_TIMEOUT_INTERVAL = TestConfig.TEST_TIME_OUT;

describe('ground-platform', () => {
let helper: WebDriverHelper;

beforeAll(async () => {
helper = new WebDriverHelper();
await helper.start(TestConfig.WEB_URL);
await helper.waitUntilPageReady();
});

afterAll(() => {
return helper.quit();
});

it('adds a new survey', async () => {
await helper.addNewSurvey();
await helper.setSurveyMetadata(
TestConfig.SURVEY_TITLE,
TestConfig.SURVEY_DESCRIPTION,
TestConfig.JOB_NAME,
TestConfig.ADHOC
);
await helper.addAllTasks(
TestConfig.ADHOC ? TestConfig.LOI_TASK_TYPE : null
);
await helper.shareSurvey(TestConfig.USER);
await helper.verifySurveyCreated();
});
});
46 changes: 46 additions & 0 deletions e2e-tests/spec/verify_submissions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* Copyright 2024 The Ground Authors.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import 'jasmine';

import {WebDriverHelper} from '../webdriver-helpers.js';
import {TestConfig} from '../test_config.js';

// Increase default timeout.
jasmine.DEFAULT_TIMEOUT_INTERVAL = TestConfig.TEST_TIME_OUT;

describe('ground-platform', () => {
let helper: WebDriverHelper;

beforeAll(async () => {
helper = new WebDriverHelper();
await helper.start(TestConfig.WEB_URL);
await helper.waitUntilPageReady();
});

afterAll(() => {
return helper.quit();
});

it('selects test survey', async () => {
await helper.selectTestSurvey();
});

it('displays submissions', async () => {
await helper.waitForSurveySubmissions();
await helper.verifySurveySubmissions();
});
});
34 changes: 34 additions & 0 deletions e2e-tests/test_config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright 2019 The Ground Authors.
*
* Licensed under the Apache License, Version 2.0 (the 'License');
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an 'AS IS' BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {LoiType} from './ground-helpers';

export class TestConfig {
static WEB_URL = 'http://localhost:5000';
static TEST_TIME_OUT = 5 * 60 * 1000; // 5m
static SHORT_TIME_OUT = 1000; // 1s
static LONG_TIME_OUT = TestConfig.SHORT_TIME_OUT * 5; // 5s
static SURVEY_TITLE = 'A test title';
static SURVEY_DESCRIPTION = 'A test description';
static JOB_NAME = 'A job name';
static ADHOC = true;
static LOI_TASK_TYPE = LoiType.DROP_PIN;
static MULTIPLE_CHOICE_COUNT = 3;
static MULTIPLE_CHOICE_ADD_OTHER = true;
static USER = '[email protected]';
static EXPECTED_SUBMISSION_COUNT = 2;
static WAIT_FOR_SUBMISSION_TRIES = 30;
}
Loading