Skip to content

Commit

Permalink
added new test to drop a pin on map
Browse files Browse the repository at this point in the history
  • Loading branch information
temi committed Dec 4, 2024
1 parent 72bfb63 commit a42a896
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/integration-test/resources/dataset1/loadDataSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var projectActivity = {
"alaAdminEnforcedEmbargo" : false,
"embargoOption" : "NONE"
},
"surveySiteOption" : "sitepick",
"surveySiteOption" : "sitepickcreate",
"sites" : [
"ab9ec9af-241b-49f7-adcf-ca40e474d119"
],
Expand Down
27 changes: 27 additions & 0 deletions src/test/js/integration/pageobjects/StubbedCasSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,33 @@ class StubbedCasSpec {
var body = await $("body");
await body.saveScreenshot(`./logs/${name}.png`);
}

/**
* Drop a pin on the map
* @returns {Promise<void>}
*/
async dropPin() {
// Select the marker draw button
const markerDraw = $('.leaflet-draw-draw-marker');
await markerDraw.waitForDisplayed();

// Move to the marker button and click it
await markerDraw.moveTo();
await markerDraw.click();

// Wait for the draw actions menu to appear
const drawActions = $('.leaflet-draw-actions'); // Get the first draw action
await drawActions.waitForDisplayed();

// click on the map pane to drop the pin
const mapPane = await $('.leaflet-map-pane');
await mapPane.moveTo();
await mapPane.click({x: 100, y: 100});

// wait for the point to be added to dropdown
const dropdown = $('.select2-selection__rendered');
await dropdown.waitForDisplayed();
}
}

module.exports = StubbedCasSpec;
74 changes: 73 additions & 1 deletion src/test/js/integration/specs/pwa/InstallationSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe("Application installation Spec", function () {
await stopServer();
});

it("open a project and take it offline", async function () {
it("submit record offline and publish it when network returns", async function () {
console.log(url);
await pwaAppPage.start();
await addBioActivityPage.takeScreenShot("openProjectAndTakeItOffline");
Expand Down Expand Up @@ -108,6 +108,78 @@ describe("Application installation Spec", function () {
await pwaAppPage.closeModal(null);
});

it("submit record offline, choose a site on map and publish it when network returns", async function () {
console.log(url);
let getStarted = await pwaAppPage.getStarted;
if (getStarted && (await getStarted.isDisplayed())) {
await pwaAppPage.start();
}
await addBioActivityPage.takeScreenShot("submitRecordOfflineAndChooseSiteOnMap");
await pwaAppPage.viewProject(project);
await pwaAppPage.downloadProjectActivity(pa);
await addBioActivityPage.takeScreenShot("submitRecordOfflineAndChooseSiteOnMapBeforeDownload");
await pwaAppPage.downloadComplete();
await stopServer();
await pwaAppPage.addRecord(pa);
await browser.pause(5000);
let iframe = await browser.findElement('tag name', 'iframe');
let contextId = await browser.switchFrame($("iframe"));
console.log("iframe context id- " +contextId);
await addBioActivityPage.dropPin();
await addBioActivityPage.uploadImage(`${addBioActivityPage.testConfig.resourceDir}/images/10_years.png`, true);
// Wait for all promises to resolve
await Promise.all(promises);
await addBioActivityPage.setDate('01/01/2020');
await addBioActivityPage.setSpecies('Acavomonidia', true)
// Save the activity
await addBioActivityPage.saveActivity();
await addBioActivityPage.takeScreenShot("submitRecordOfflineAndChooseSiteOnMapAfterSave");
contextId = await browser.switchFrame(null);
console.log("main frame context id- " +contextId);
await pwaAppPage.closeModal();
console.log("number of records checked again");

await startServer();
await pwaAppPage.open();
await pwaAppPage.viewProject(project);
await pwaAppPage.viewRecords(pa);
await pwaAppPage.viewUnpublishedRecords(pa);
await addBioActivityPage.takeScreenShot("submitRecordOfflineAndChooseSiteOnMapUnpublishedRecords");

contextId = await browser.switchFrame($('iframe'));
console.log("iframe context id- " +contextId);

offlineListPage = new OfflineListPage();
expect(await offlineListPage.at()).toEqual(true);
await expect(offlineListPage.uploadAllButton).toBeEnabled();
await expect(offlineListPage.firstUploadButton).toBeEnabled();
await offlineListPage.uploadRecords();
await addBioActivityPage.takeScreenShot("submitRecordOfflineAndChooseSiteOnMapPublishedRecords");
await browser.pause(5000);
await expect(offlineListPage.uploadAllButton).toBeDisabled();

await expect(await offlineListPage.alert).toHaveText("Unpublished records not found");
await browser.switchFrame(null);
await pwaAppPage.closeModal();

// check if the record is uploaded
await pwaAppPage.viewRecords(pa);
await pwaAppPage.viewFirstRecord();
await browser.pause(3000);
iframe = $("iframe");
contextId = await browser.switchFrame(iframe);
console.log("iframe context id- " +contextId);
let viewBioActivityPage = new ViewBioActivityPage();
var speciesEl = viewBioActivityPage.speciesSelector("Acavomonidia");
await addBioActivityPage.takeScreenShot("submitRecordOfflineAndChooseSiteOnMapViewPublishedRecord");
await speciesEl.scrollIntoView();
await expect(speciesEl).toBeDisplayed();
// map pin should be displayed
await expect($('.leaflet-marker-icon')).toBeDisplayed();
await browser.switchFrame(null);
await pwaAppPage.closeModal(null);
});

it("login with expired token", async function () {
await pwaAppPage.logout();
await pwaAppPage.atSignIn();
Expand Down
1 change: 1 addition & 0 deletions wdio.local.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config = {
'goog:chromeOptions': {
// args: ['--auto-open-devtools-for-tabs','disable-gpu']
args: ['headless', 'disable-gpu', '--window-size=1280,1024']
// args: ['disable-gpu', '--window-size=1280,1024']
},
'wdio:chromedriverOptions': {
binary: "./node_modules/chromedriver/lib/chromedriver/chromedriver"
Expand Down

0 comments on commit a42a896

Please sign in to comment.