<commit_before>var mapPage = require('./map.page');
var resourcePage = require('../resources/resources.page');


describe('idai field app', function() {

    function setPolygon() {
        return mapPage.clickMap(100,100)
            .then(function(){return mapPage.clickMap(200,200)})
            .then(function(){return mapPage.clickMap(100,200)})
            .then(function(){return mapPage.clickMap(100,100)});
    }

    function beginCreateDocWithGeometry(geometry, mapClickCallback) {
        return resourcePage.clickCreateObject()
            .then(resourcePage.selectResourceType)
            .then(function(){return resourcePage.selectGeometryType(geometry)})
            .then(mapClickCallback);
    }
    
    function createDocWithGeometry(identifier,geometry, mapClickCallback) {
        return beginCreateDocWithGeometry(geometry, mapClickCallback)
            .then(function(){return mapPage.clickMapOption('ok')})
            .then(function(){return resourcePage.typeInIdentifier(identifier)})
            .then(resourcePage.scrollUp)
            .then(resourcePage.clickSaveDocument);
    }
    
    
    function createDoc(identifier,geometryType, mapClickCallback) {
        if (geometryType == 'point') {
            return createDocWithGeometry(identifier, geometryType, mapClickCallback)
        } else if (geometryType == 'polygon') {
            return createDocWithGeometry(identifier, geometryType, mapClickCallback)
        } else {
            return resourcePage.createResource(identifier);
        }
    }
    
    function createDocThenReedit(identifier,geometryType, mapClickCallback) {
        return createDoc(identifier, geometryType, mapClickCallback)
            .then(resourcePage.clickBackToDocumentView)
            .then(resourcePage.clickReeditGeometry);
    }
    
    beforeEach(function(done){
        resourcePage.get().then(function(){
           done();
        });
    });

    it('should create a new item with point geometry ', function(done) {
        createDoc('33','point', function(){return mapPage.setMarker(100, 100)})
            .then(function () {
                return resourcePage.clickBackToDocumentView();
            })
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Punkt');
                done();
            });
    });

    it('should create a new item with polygon geometry ', function(done) {
        createDoc('34', 'polygon', setPolygon)
            .then(function () {
                return resourcePage.clickBackToDocumentView();
            })
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Polygon');
                done();
            });
    });

    it('should delete a point geometry ', function(done) {
        createDocThenReedit('37', 'point', function(){mapPage.setMarker(100, 100)})
            .then(function(){return mapPage.clickMapOption('delete')})
            .then(function(){return mapPage.clickMapOption('ok')})
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Keine');
                done();
            })
    });

    it('should delete a polygon geometry ', function(done) {
        createDocThenReedit('36' ,'polygon', setPolygon)
            .then(function(){return mapPage.clickMapOption('delete')})
            .then(function(){return mapPage.clickMapOption('ok')})
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Keine');
                done();
            })
    });

    it('should create a point geometry later', function(done) {
        resourcePage.createResource('39')
            .then(resourcePage.clickBackToDocumentView)
            .then(function(){return resourcePage.clickCreateGeometry('point')})
            .then(function(){return mapPage.setMarker(100, 100)})
            .then(function(){return mapPage.clickMapOption('ok')})<commit_msg>Add missing return.<commit_after>var mapPage = require('./map.page');
var resourcePage = require('../resources/resources.page');


describe('idai field app', function() {

    function setPolygon() {
        return mapPage.clickMap(100,100)
            .then(function(){return mapPage.clickMap(200,200)})
            .then(function(){return mapPage.clickMap(100,200)})
            .then(function(){return mapPage.clickMap(100,100)});
    }

    function beginCreateDocWithGeometry(geometry, mapClickCallback) {
        return resourcePage.clickCreateObject()
            .then(resourcePage.selectResourceType)
            .then(function(){return resourcePage.selectGeometryType(geometry)})
            .then(mapClickCallback);
    }
    
    function createDocWithGeometry(identifier,geometry, mapClickCallback) {
        return beginCreateDocWithGeometry(geometry, mapClickCallback)
            .then(function(){return mapPage.clickMapOption('ok')})
            .then(function(){return resourcePage.typeInIdentifier(identifier)})
            .then(resourcePage.scrollUp)
            .then(resourcePage.clickSaveDocument);
    }
    
    
    function createDoc(identifier,geometryType, mapClickCallback) {
        if (geometryType == 'point') {
            return createDocWithGeometry(identifier, geometryType, mapClickCallback)
        } else if (geometryType == 'polygon') {
            return createDocWithGeometry(identifier, geometryType, mapClickCallback)
        } else {
            return resourcePage.createResource(identifier);
        }
    }
    
    function createDocThenReedit(identifier,geometryType, mapClickCallback) {
        return createDoc(identifier, geometryType, mapClickCallback)
            .then(resourcePage.clickBackToDocumentView)
            .then(resourcePage.clickReeditGeometry);
    }
    
    beforeEach(function(done){
        resourcePage.get().then(function(){
           done();
        });
    });

    it('should create a new item with point geometry ', function(done) {
        createDoc('33','point', function(){return mapPage.setMarker(100, 100)})
            .then(function () {
                return resourcePage.clickBackToDocumentView();
            })
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Punkt');
                done();
            });
    });

    it('should create a new item with polygon geometry ', function(done) {
        createDoc('34', 'polygon', setPolygon)
            .then(function () {
                return resourcePage.clickBackToDocumentView();
            })
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Polygon');
                done();
            });
    });

    it('should delete a point geometry ', function(done) {
        createDocThenReedit('37', 'point', function(){return mapPage.setMarker(100, 100)})
            .then(function(){return mapPage.clickMapOption('delete')})
            .then(function(){return mapPage.clickMapOption('ok')})
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Keine');
                done();
            })
    });

    it('should delete a polygon geometry ', function(done) {
        createDocThenReedit('36' ,'polygon', setPolygon)
            .then(function(){return mapPage.clickMapOption('delete')})
            .then(function(){return mapPage.clickMapOption('ok')})
            .then(function() {
                expect(resourcePage.getTypeOfSelectedGeometry()).toEqual('Keine');
                done();
            })
    });

    it('should create a point geometry later', function(done) {
        resourcePage.createResource('39')
            .then(resourcePage.clickBackToDocumentView)
            .then(function(){return resourcePage.clickCreateGeometry('point')})
            .then(function(){return mapPage.setMarker(100, 100)})
            .then(function(){return mapPage.clickMapOption('ok')})
{'fraction_non_alphanumeric': 0.12729544034978138, 'fraction_numerical': 0.012991880074953154, 'mean_word_length': 2.6014394961763383, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2066783', 'n_tokens_mistral': 2098, 'n_tokens_neox': 1987, 'n_words': 322}