OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix stub, selectors in pull-request component spec
Alexander Brandon Coles1f71972eda40
diff --git a/modules/github_integration/frontend/module/pull-request/pull-request.component.spec.ts b/modules/github_integration/frontend/module/pull-request/pull-request.component.spec.tsindex 939eb256fd8..7c4f2ff97f5 100644--- a/modules/github_integration/frontend/module/pull-request/pull-request.component.spec.ts+++ b/modules/github_integration/frontend/module/pull-request/pull-request.component.spec.ts@@ -2,6 +2,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';import { Component, DebugElement, Input } from '@angular/core';import { By } from "@angular/platform-browser";import { PullRequestComponent } from "./pull-request.component";+import { IGithubCheckRunResource, IGithubPullRequest, IGithubUserResource } from '../state/github-pull-request.model';@Component({selector: 'op-date-time',@@ -15,12 +16,12 @@ describe('PullRequestComponent', () => {let component:PullRequestComponent;let fixture:ComponentFixture<PullRequestComponent>;let element:DebugElement;- const githubUser = {+ const githubUser:IGithubUserResource = {avatarUrl: 'testavatarurl',htmlUrl: 'test htmlUrl',login: 'test login',};- const checkRun = {+ const checkRun:IGithubCheckRunResource = {appOwnerAvatarUrl: 'test appOwnerAvatarUrl',completedAt: 'test completedAt',conclusion: 'test conclusion',@@ -32,7 +33,8 @@ describe('PullRequestComponent', () => {startedAt: 'test startedAt',status: 'test status',};- const pullRequestStub = {+ const pullRequestStub:IGithubPullRequest = {+ id: 3,additionsCount: 3,body:{format: '',@@ -46,19 +48,31 @@ describe('PullRequestComponent', () => {draft: false,githubUpdatedAt: 'test githubUpdatedAt',htmlUrl: 'test htmlUrl',- id: 3,labels: ['test'],merged: false,- mergedAt: false,- mergedBy: githubUser,+ mergedAt: '',number: 3,repository: 'test repository',+ repositoryHtmlUrl: 'test repositoryHtmlUrl',reviewCommentsCount: 3,state: 'open',title: 'test title',updatedAt: 'test updatedAt',- githubUser,- checkRuns:[checkRun],+ _links: {+ githubUser: {+ href: 'test api url',+ title: 'test github user'+ },+ self: {+ href: 'this url',+ title: 'this title'+ }+ },+ _embedded: {+ githubUser,+ mergedBy: githubUser,+ checkRuns:[checkRun],+ }}beforeEach(async () => {@@ -89,18 +103,18 @@ describe('PullRequestComponent', () => {it('should render pull request data', () => {const titleElement = fixture.debugElement.query(By.css('.op-pull-request--title')).nativeElement;const avatarElement = fixture.debugElement.query(By.css('.op-avatar')).nativeElement;- const userElement = fixture.debugElement.query(By.css('.op-pull-request--user')).nativeElement;+ const userElement = fixture.debugElement.query(By.css('.op-principal')).nativeElement;const detailsElement = fixture.debugElement.query(By.css('.op-pull-request--link')).nativeElement;const checkRuns = fixture.debugElement.queryAll(By.css('.op-pr-check'));const checkRunElement = checkRuns[0].nativeElement;const checkRunLinkElement = checkRuns[0].query(By.css('a')).nativeElement;expect(titleElement.textContent).toContain(pullRequestStub.title);- expect(avatarElement.src).toContain(pullRequestStub.githubUser.avatarUrl);- expect(userElement.textContent).toContain(pullRequestStub.githubUser.login);+ expect(avatarElement.src).toContain(pullRequestStub._embedded.githubUser.avatarUrl);+ expect(userElement.textContent).toContain(pullRequestStub._embedded.githubUser.login);expect(detailsElement.textContent).toContain(`${pullRequestStub.repository}#${pullRequestStub.number}`);expect(checkRuns.length).toBe(1);- expect(checkRunElement.textContent).toContain(pullRequestStub.checkRuns[0].name);- expect(checkRunLinkElement.href).toContain(pullRequestStub.checkRuns[0].detailsUrl);+ expect(checkRunElement.textContent).toContain(pullRequestStub._embedded.checkRuns[0].name);+ expect(checkRunLinkElement.href).toContain(pullRequestStub._embedded.checkRuns[0].detailsUrl);});});