Skip to content

Commit eddb3df

Browse files
Merge pull request #2 from dataquest-dev/test-first-touch
Created example tests, updated README.md and created README-dtq.md, changed BE to localhost
2 parents 513889e + b721a06 commit eddb3df

File tree

14 files changed

+672
-39
lines changed

14 files changed

+672
-39
lines changed

README-dtq.md

Lines changed: 535 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![Build](https://github.com/dataquest-dev/dspace-angular/actions/workflows/build.yml/badge.svg)](https://github.com/dataquest-dev/dspace-angular/actions/workflows/build.yml) [![Coverage Status](https://codecov.io/gh/DSpace/dspace-angular/branch/main/graph/badge.svg)](https://codecov.io/gh/DSpace/dspace-angular) [![Universal Angular](https://img.shields.io/badge/universal-angular2-brightgreen.svg?style=flat)](https://github.com/angular/universal)
1+
[![Build](https://github.com/dataquest-dev/dspace-angular/actions/workflows/build.yml/badge.svg)](https://github.com/dataquest-dev/dspace-angular/actions/workflows/build.yml) [![codecov](https://codecov.io/gh/dataquest-dev/dspace-angular/branch/dtq-dev/graph/badge.svg?token=DQ7QIZN8S6)](https://codecov.io/gh/dataquest-dev/dspace-angular) [![Universal Angular](https://img.shields.io/badge/universal-angular2-brightgreen.svg?style=flat)](https://github.com/angular/universal)
22

33
dspace-angular
44
==============
@@ -15,7 +15,7 @@ For more information, visit http://www.dspace.org/
1515
DSpace consists of both a Java-based backend and an Angular-based frontend.
1616

1717
* Backend (https://github.com/DSpace/DSpace/) provides a REST API, along with other machine-based interfaces (e.g. OAI-PMH, SWORD, etc)
18-
* The REST Contract is at https://github.com/DSpace/RestContract
18+
* The REST Contract is at https://github.com/DSpace/RestContract
1919
* Frontend (this codebase) is the User Interface built on the REST API
2020

2121
Downloads
@@ -61,17 +61,17 @@ Table of Contents
6161
- [Introduction to the technology](#introduction-to-the-technology)
6262
- [Requirements](#requirements)
6363
- [Installing](#installing)
64-
- [Configuring](#configuring)
64+
- [Configuring](#configuring)
6565
- [Running the app](#running-the-app)
66-
- [Running in production mode](#running-in-production-mode)
67-
- [Deploy](#deploy)
68-
- [Running the application with Docker](#running-the-application-with-docker)
66+
- [Running in production mode](#running-in-production-mode)
67+
- [Deploy](#deploy)
68+
- [Running the application with Docker](#running-the-application-with-docker)
6969
- [Cleaning](#cleaning)
7070
- [Testing](#testing)
71-
- [Test a Pull Request](#test-a-pull-request)
72-
- [Unit Tests](#unit-tests)
73-
- [E2E Tests](#e2e-tests)
74-
- [Writing E2E Tests](#writing-e2e-tests)
71+
- [Test a Pull Request](#test-a-pull-request)
72+
- [Unit Tests](#unit-tests)
73+
- [E2E Tests](#e2e-tests)
74+
- [Writing E2E Tests](#writing-e2e-tests)
7575
- [Documentation](#documentation)
7676
- [Other commands](#other-commands)
7777
- [Recommended Editors/IDEs](#recommended-editorsides)
@@ -238,8 +238,8 @@ Testing
238238
If you would like to contribute by testing a Pull Request (PR), here's how to do so. Keep in mind, you **do not need to have a DSpace backend / REST API installed locally to test a PR**. By default, the dspace-angular project points at our demo REST API
239239

240240
1. Pull down the branch that the Pull Request was built from. Easy instructions for doing so can be found on the Pull Request itself.
241-
* Next to the "Merge" button, you'll see a link that says "command line instructions".
242-
* Click it, and follow "Step 1" of those instructions to checkout the pull down the PR branch.
241+
* Next to the "Merge" button, you'll see a link that says "command line instructions".
242+
* Click it, and follow "Step 1" of those instructions to checkout the pull down the PR branch.
243243
2. `yarn run clean` (This resets your local dependencies to ensure you are up-to-date with this PR)
244244
3. `yarn install` (Updates your local dependencies to those in the PR)
245245
4. `yarn start` (Rebuilds the project, and deploys to localhost:4000, by default)
@@ -292,9 +292,9 @@ All E2E tests must be created under the `./cypress/integration/` folder, and mus
292292
* Run your test file from the Cypress window. This starts the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner) in a new browser window.
293293
* In the [Cypress Test Runner](https://docs.cypress.io/guides/core-concepts/test-runner), you'll Cypress automatically visit the page. This first test will succeed, as all you are doing is making sure the _page exists_.
294294
* From here, you can use the [Selector Playground](https://docs.cypress.io/guides/core-concepts/test-runner#Selector-Playground) in the Cypress Test Runner window to determine how to tell Cypress to interact with a specific HTML element on that page.
295-
* Most commands start by telling Cypress to [get()](https://docs.cypress.io/api/commands/get) a specific element, using a CSS or jQuery style selector
296-
* Cypress can then do actions like [click()](https://docs.cypress.io/api/commands/click) an element, or [type()](https://docs.cypress.io/api/commands/type) text in an input field, etc.
297-
* Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions.
295+
* Most commands start by telling Cypress to [get()](https://docs.cypress.io/api/commands/get) a specific element, using a CSS or jQuery style selector
296+
* Cypress can then do actions like [click()](https://docs.cypress.io/api/commands/click) an element, or [type()](https://docs.cypress.io/api/commands/type) text in an input field, etc.
297+
* Cypress can also validate that something occurs, using [should()](https://docs.cypress.io/api/commands/should) assertions.
298298
* Any time you save your test file, the Cypress Test Runner will reload & rerun it. This allows you can see your results quickly as you write the tests & correct any broken tests rapidly.
299299
* Cypress also has a great guide on [writing your first test](https://on.cypress.io/writing-first-test) with much more info. Keep in mind, while the examples in the Cypress docs often involve Javascript files (.js), the same examples will work in our Typescript (.ts) e2e tests.
300300

@@ -332,12 +332,12 @@ Recommended Editors/IDEs
332332
To get the most out of TypeScript, you'll need a TypeScript-aware editor. We've had good experiences using these editors:
333333

334334
- Free
335-
- [Visual Studio Code](https://code.visualstudio.com/)
336-
- [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome)
335+
- [Visual Studio Code](https://code.visualstudio.com/)
336+
- [Debugger for Chrome](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome)
337337
- Paid
338-
- [Webstorm](https://www.jetbrains.com/webstorm/download/) or [IntelliJ IDEA Ultimate](https://www.jetbrains.com/idea/)
339-
- [Sublime Text](http://www.sublimetext.com/3)
340-
- [Typescript-Sublime-Plugin](https://github.com/Microsoft/Typescript-Sublime-plugin#installation)
338+
- [Webstorm](https://www.jetbrains.com/webstorm/download/) or [IntelliJ IDEA Ultimate](https://www.jetbrains.com/idea/)
339+
- [Sublime Text](http://www.sublimetext.com/3)
340+
- [Typescript-Sublime-Plugin](https://github.com/Microsoft/Typescript-Sublime-plugin#installation)
341341

342342
Collaborating
343343
-------------
@@ -438,7 +438,7 @@ This project makes use of [`yarn`](https://yarnpkg.com/en/) to ensure that the e
438438

439439
* `yarn` creates a [`yarn.lock`](https://yarnpkg.com/en/docs/yarn-lock) to track those versions. That file is updated automatically by whenever dependencies are added/updated/removed via yarn.
440440
* **Adding new dependencies**: To install/add a new dependency (third party library), use [`yarn add`](https://yarnpkg.com/en/docs/cli/add). For example: `yarn add some-lib`.
441-
* If you are adding a new build tool dependency (to `devDependencies`), use `yarn add some-lib --dev`
441+
* If you are adding a new build tool dependency (to `devDependencies`), use `yarn add some-lib --dev`
442442
* **Upgrading existing dependencies**: To upgrade existing dependencies, you can use [`yarn upgrade`](https://yarnpkg.com/en/docs/cli/upgrade). For example: `yarn upgrade some-lib` or `yarn upgrade some-lib@version`
443443
* **Removing dependencies**: If a dependency is no longer needed, or replaced, use [`yarn remove`](https://yarnpkg.com/en/docs/cli/remove) to remove it.
444444

@@ -480,22 +480,22 @@ Frequently asked questions
480480
--------------------------
481481

482482
- Why is my service, aka provider, is not injecting a parameter correctly?
483-
- Please use `@Injectable()` for your service for typescript to correctly attach the metadata
483+
- Please use `@Injectable()` for your service for typescript to correctly attach the metadata
484484
- Where do I write my tests?
485-
- You can write your tests next to your component files. e.g. for `src/app/home/home.component.ts` call it `src/app/home/home.component.spec.ts`
485+
- You can write your tests next to your component files. e.g. for `src/app/home/home.component.ts` call it `src/app/home/home.component.spec.ts`
486486
- How do I start the app when I get `EACCES` and `EADDRINUSE` errors?
487-
- The `EADDRINUSE` error means the port `4000` is currently being used and `EACCES` is lack of permission to build files to `./dist/`
487+
- The `EADDRINUSE` error means the port `4000` is currently being used and `EACCES` is lack of permission to build files to `./dist/`
488488
- What are the naming conventions for Angular?
489-
- See [the official angular style guide](https://angular.io/styleguide)
489+
- See [the official angular style guide](https://angular.io/styleguide)
490490
- Why is the size of my app larger in development?
491-
- The production build uses a whole host of techniques (ahead-of-time compilation, rollup to remove unreachable code, minification, etc.) to reduce the size, that aren't used during development in the intrest of build speed.
491+
- The production build uses a whole host of techniques (ahead-of-time compilation, rollup to remove unreachable code, minification, etc.) to reduce the size, that aren't used during development in the intrest of build speed.
492492
- node-pre-gyp ERR in yarn install (Windows)
493-
- install Python x86 version between 2.5 and 3.0 on windows. See [this issue](https://github.com/AngularClass/angular2-webpack-starter/issues/626)
493+
- install Python x86 version between 2.5 and 3.0 on windows. See [this issue](https://github.com/AngularClass/angular2-webpack-starter/issues/626)
494494
- How do I handle merge conflicts in yarn.lock?
495-
- first check out the yarn.lock file from the branch you're merging in to yours: e.g. `git checkout --theirs yarn.lock`
496-
- now run `yarn install` again. Yarn will create a new lockfile that contains both sets of changes.
497-
- then run `git add yarn.lock` to stage the lockfile for commit
498-
- and `git commit` to conclude the merge
495+
- first check out the yarn.lock file from the branch you're merging in to yours: e.g. `git checkout --theirs yarn.lock`
496+
- now run `yarn install` again. Yarn will create a new lockfile that contains both sets of changes.
497+
- then run `git add yarn.lock` to stage the lockfile for commit
498+
- and `git commit` to conclude the merge
499499

500500
Getting Help
501501
------------
@@ -529,4 +529,4 @@ DSpace source code is freely available under a standard [BSD 3-Clause license](h
529529
The full license is available in the [LICENSE](LICENSE) file or online at http://www.dspace.org/license/
530530

531531
DSpace uses third-party libraries which may be distributed under different licenses. Those licenses are listed
532-
in the [LICENSES_THIRD_PARTY](LICENSES_THIRD_PARTY) file.
532+
in the [LICENSES_THIRD_PARTY](LICENSES_THIRD_PARTY) file.

angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
"loaders": "prepend"
125125
}
126126
},
127-
"main": "src/test.ts",
127+
"main": "src/test-dtq.ts",
128128
"polyfills": "src/polyfills.ts",
129129
"tsConfig": "tsconfig.spec.json",
130130
"karmaConfig": "karma.conf.js",
@@ -261,4 +261,4 @@
261261
"cli": {
262262
"analytics": false
263263
}
264-
}
264+
}

config/config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
rest:
2-
ssl: true
3-
host: api7.dspace.org
4-
port: 443
2+
ssl: false
3+
host: localhost
4+
port: 8080
55
nameSpace: /server
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { testA11y } from 'cypress/support/utils';
2+
3+
describe('Footer right background color', () => {
4+
it('should have backgroubd color from var --ds-footer-bg', () => {
5+
cy.visit('/');
6+
7+
// Footer must have specific color
8+
cy.get('footer')
9+
.should('have.css', 'background-color', 'rgb(67, 81, 95)');
10+
11+
// Analyze <ds-footer> for accessibility
12+
testA11y('footer');
13+
});
14+
});

src/app/app.module.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { ThemedHeaderNavbarWrapperComponent } from './header-nav-wrapper/themed-
5656
import { IdleModalComponent } from './shared/idle-modal/idle-modal.component';
5757
import { ThemedPageInternalServerErrorComponent } from './page-internal-server-error/themed-page-internal-server-error.component';
5858
import { PageInternalServerErrorComponent } from './page-internal-server-error/page-internal-server-error.component';
59+
import { DtqTestExampleComponent } from './dtq-test-example/dtq-test-example.component';
5960

6061
import { APP_CONFIG, AppConfig } from '../config/app-config.interface';
6162

@@ -185,7 +186,8 @@ const DECLARATIONS = [
185186
ThemedForbiddenComponent,
186187
IdleModalComponent,
187188
ThemedPageInternalServerErrorComponent,
188-
PageInternalServerErrorComponent
189+
PageInternalServerErrorComponent,
190+
DtqTestExampleComponent
189191
];
190192

191193
const EXPORTS = [
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<p>dtq-test-example works!</p>

src/app/dtq-test-example/dtq-test-example.component.scss

Whitespace-only changes.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { DtqTestExampleComponent } from './dtq-test-example.component';
4+
import {By} from '@angular/platform-browser';
5+
6+
describe('DtqTestExampleComponent', () => {
7+
let component: DtqTestExampleComponent;
8+
let fixture: ComponentFixture<DtqTestExampleComponent>;
9+
10+
beforeEach(async () => {
11+
await TestBed.configureTestingModule({
12+
declarations: [ DtqTestExampleComponent ]
13+
})
14+
.compileComponents();
15+
});
16+
17+
beforeEach(() => {
18+
fixture = TestBed.createComponent(DtqTestExampleComponent);
19+
component = fixture.componentInstance;
20+
fixture.detectChanges();
21+
});
22+
23+
it('should create', () => {
24+
expect(component).toBeTruthy();
25+
});
26+
27+
it('should have specific context', () => {
28+
const tag = fixture.debugElement.query(By.css('p')).nativeElement;
29+
expect(tag.innerHTML).toBe('dtq-test-example works!');
30+
});
31+
32+
it('should not have wrong context', () => {
33+
const tag = fixture.debugElement.query(By.css('p')).nativeElement;
34+
expect(tag.innerHTML).not.toBe('This text is not there!');
35+
});
36+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'ds-dtq-test-example',
5+
templateUrl: './dtq-test-example.component.html',
6+
styleUrls: ['./dtq-test-example.component.scss']
7+
})
8+
export class DtqTestExampleComponent {
9+
10+
}

0 commit comments

Comments
 (0)