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

DSP-474 Create custom Harness for select ontology comp. #124

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c666ac0
tests (search): create custom Harness for select ontology comp.
Jul 13, 2020
c4e90db
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Jul 13, 2020
5546faa
tests (e2e): load path config for lib in protractor
Jul 14, 2020
61bcb21
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Jul 14, 2020
a8ed5c4
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Jul 16, 2020
0ad14e5
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Jul 17, 2020
53ead57
tests (e2e): set global window object to prevent reference error in j…
Jul 17, 2020
223b0c9
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Jul 27, 2020
b3b1a39
Merge branch 'master' into wip/dsp-474-create-harnesses
Sep 7, 2020
11de6f9
test (e2e): remove unnecessary variable
Sep 7, 2020
f3866fa
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Sep 10, 2020
b14434a
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Sep 14, 2020
d45a7e5
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Oct 12, 2020
da7e928
Merge branch 'master' into wip/dsp-474-create-harnesses
tobiasschweizer Oct 13, 2020
83dab74
Merge branch 'main' into wip/dsp-474-create-harnesses
tobiasschweizer Nov 19, 2020
dedba59
Merge branch 'main' into wip/dsp-474-create-harnesses
tobiasschweizer Nov 19, 2020
b19f802
Merge branch 'main' into wip/dsp-474-create-harnesses
tobiasschweizer Dec 10, 2020
f5c61f3
Merge branch 'main' into wip/dsp-474-create-harnesses
tobiasschweizer Jan 7, 2021
ce88176
Merge branch 'main' into wip/dsp-474-create-harnesses
tobiasschweizer Mar 19, 2021
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
11 changes: 11 additions & 0 deletions e2e/protractor.conf.js
Expand Up @@ -2,6 +2,12 @@
// Protractor configuration file, see link for more information
// https://github.com/angular/protractor/blob/master/lib/config.ts

const tsConfig = require('../tsconfig.json'); // https://github.com/nrwl/nx/issues/263#issuecomment-485889032

// define the global window object because jsonld needs it
global['window'] = {
addEventListener: () => {}
};
const {SpecReporter, StacktraceOption} = require('jasmine-spec-reporter');

/**
Expand Down Expand Up @@ -31,6 +37,11 @@ exports.config = {
require('ts-node').register({
project: require('path').join(__dirname, './tsconfig.json')
});
require('tsconfig-paths').register({
project: require('path').join(__dirname, './tsconfig.json'),
baseUrl: './',
paths: tsConfig.compilerOptions.paths
});
jasmine.getEnv().addReporter(new SpecReporter({spec: {displayStacktrace: StacktraceOption.RAW}}));
}
};
12 changes: 6 additions & 6 deletions e2e/src/app.e2e-spec.ts
@@ -1,5 +1,7 @@
import { ProtractorHarnessEnvironment } from '@angular/cdk/testing/protractor';
import { MatAutocompleteHarness } from '@angular/material/autocomplete/testing';
// import { SelectOntologyHarness } from '../../projects/dsp-ui/src/lib/search/advanced-search/select-ontology/select-ontology.harness'; // TODO: import from lib path
import { SelectOntologyHarness } from '@dasch-swiss/dsp-ui';
import { MatInputHarness } from '@angular/material/input/testing';
import { browser, by, element, logging, WebElement } from 'protractor';
import { AppPage } from './app.po';
Expand Down Expand Up @@ -92,18 +94,16 @@ describe('Test App', () => {

expect(await submitButton.isDisabled()).toBe(true);

const selectOntos = await page.getAdvancedSearchOntologySelection(loader, timeout);

await selectOntos.open();
const selectOntoHarness: SelectOntologyHarness = await loader.getHarness(SelectOntologyHarness);

const ontoOptions = await selectOntos.getOptions();
const ontoOptions = await selectOntoHarness.getOntologyOptions();

expect(ontoOptions.length).toEqual(11);

expect(await ontoOptions[0].getText()).toEqual('The anything ontology');
expect(ontoOptions[0]).toEqual('The anything ontology');

// anything onto
await selectOntos.clickOptions({ text: 'The anything ontology'});
await selectOntoHarness.chooseOntology('The anything ontology');

// check for the async response from Knora: anything and knora-api ontology
await browser.wait(EC.presenceOf(element(by.css('.select-resource-class'))), timeout,
Expand Down
29 changes: 29 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -78,6 +78,7 @@
"ng-packagr": "^9.0.0",
"protractor": "^7.0.0",
"ts-node": "~8.9.0",
"tsconfig-paths": "^3.9.0",
"tslint": "~5.15.0",
"typescript": "3.8.3"
}
Expand Down
@@ -0,0 +1,30 @@
import { AsyncFactoryFn, ComponentHarness } from '@angular/cdk/testing';
import { MatSelectHarness } from '@angular/material/select/testing';

export class SelectOntologyHarness extends ComponentHarness {
static hostSelector = 'dsp-select-ontology';

protected getOntoSelection: AsyncFactoryFn<MatSelectHarness> =
this.locatorFor(MatSelectHarness);

protected async getOntologySelection(): Promise<MatSelectHarness> {
return await this.getOntoSelection();
}

async getOntologyOptions(): Promise<string[]> {
const ontoSelection = await this.getOntologySelection();

await ontoSelection.open();
const options = await ontoSelection.getOptions();
const optionTexts = options.map(option => option.getText());

return Promise.all(optionTexts);
}

async chooseOntology(ontologyText: string): Promise<void> {
const ontoSelection = await this.getOntologySelection();

return ontoSelection.clickOptions({ text: ontologyText});
}

}
1 change: 1 addition & 0 deletions projects/dsp-ui/src/lib/search/index.ts
Expand Up @@ -3,6 +3,7 @@ export * from './search-panel/search-panel.component';
export * from './fulltext-search/fulltext-search.component';
export * from './expert-search/expert-search.component';
export * from './advanced-search/advanced-search.component';
export * from './advanced-search/select-ontology/select-ontology.harness';
export * from './advanced-search/select-property/specify-property-value/operator';
export * from './services/advanced-search-params.service';
export * from './services/gravsearch-generation.service';