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

Add Origins page Traffic Portal v2 #7881

Merged
merged 8 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions experimental/traffic-portal/src/app/api/coordinate.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,38 @@ describe("CoordinateService", () => {
await expectAsync(responseP).toBeResolvedTo(coordinate);
});

it("sends requests for multiple coordinates by ID", async () => {
ntheanh201 marked this conversation as resolved.
Show resolved Hide resolved
const responseParams = service.getCoordinates(coordinate.id);
const req = httpTestingController.expectOne(
(r) => r.url === `/api/${service.apiVersion}/coordinates`
);
expect(req.request.method).toBe("GET");
expect(req.request.params.keys().length).toBe(1);
expect(req.request.params.get("id")).toBe(String(coordinate.id));
const data = {
response: [
{
id: 1,
lastUpdated: new Date(),
latitude: 1.0,
longitude: -1.0,
name: "test_coordinate1",
},
{
id: 1,
lastUpdated: new Date(),
latitude: 1.0,
longitude: -1.0,
name: "test_coordinate2",
},
],
};
req.flush(data);
await expectAsync(responseParams).toBeRejectedWithError(
`Traffic Ops responded with 2 Coordinates by identifier ${coordinate.id}`
);
});

afterEach(() => {
httpTestingController.verify();
});
Expand Down
60 changes: 60 additions & 0 deletions experimental/traffic-portal/src/app/api/origin.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,66 @@ describe("OriginService", () => {
await expectAsync(responseP).toBeResolved();
});

it("sends requests for multiple origins by ID", async () => {
const responseParams = service.getOrigins(origin.id);
const req = httpTestingController.expectOne(
(r) => r.url === `/api/${service.apiVersion}/origins`
);
expect(req.request.method).toBe("GET");
expect(req.request.params.keys().length).toBe(1);
expect(req.request.params.get("id")).toBe(String(origin.id));
const data = {
response: [
{
cachegroup: null,
cachegroupId: null,
coordinate: null,
coordinateId: null,
deliveryService: "test",
deliveryServiceId: 1,
fqdn: "origin.infra.ciab.test",
id: 1,
ip6Address: null,
ipAddress: null,
isPrimary: false,
lastUpdated: new Date(),
name: "test",
port: null,
profile: null,
profileId: null,
protocol: "http" as never,
tenant: "root",
tenantId: 1,
},
{
cachegroup: null,
cachegroupId: null,
coordinate: null,
coordinateId: null,
deliveryService: "test",
deliveryServiceId: 1,
fqdn: "origin.infra.ciab.test",
id: 1,
ip6Address: null,
ipAddress: null,
isPrimary: false,
lastUpdated: new Date(),
name: "test2",
port: null,
profile: null,
profileId: null,
protocol: "http" as never,
tenant: "root",
tenantId: 1,
},
],
};
req.flush(data);
await expectAsync(responseParams).toBeRejectedWithError(
`Traffic Ops responded with 2 Origins by identifier ${origin.id}`
);
});

afterEach(() => {
httpTestingController.verify();
});
Expand Down
Loading