generated from cloud-gov/.github
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #548 from cloud-gov/eoc/539
Implements all orgs page
- Loading branch information
Showing
36 changed files
with
1,286 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
export const mockOrgQuotas = { | ||
pagination: { | ||
total_results: 1, | ||
total_pages: 1, | ||
first: { | ||
href: 'https://api.dev.us-gov-west-1.aws-us-gov.cloud.gov/v3/organization_quotas?organization_guids=470bd8ff-ed0e-4d11-95c4-cf765202cebd&page=1&per_page=50', | ||
}, | ||
last: { | ||
href: 'https://api.dev.us-gov-west-1.aws-us-gov.cloud.gov/v3/organization_quotas?organization_guids=470bd8ff-ed0e-4d11-95c4-cf765202cebd&page=1&per_page=50', | ||
}, | ||
next: null, | ||
previous: null, | ||
}, | ||
resources: [ | ||
{ | ||
guid: '3564fac5-c405-480e-b758-57912da29f9e', | ||
created_at: '2017-04-27T19:12:50Z', | ||
updated_at: '2022-07-18T21:01:25Z', | ||
name: 'default', | ||
apps: { | ||
total_memory_in_mb: 10240, | ||
per_process_memory_in_mb: null, | ||
total_instances: null, | ||
per_app_tasks: null, | ||
log_rate_limit_in_bytes_per_second: null, | ||
}, | ||
services: { | ||
paid_services_allowed: true, | ||
total_service_instances: 100, | ||
total_service_keys: 1000, | ||
}, | ||
routes: { | ||
total_routes: 1000, | ||
total_reserved_ports: 5, | ||
}, | ||
domains: { | ||
total_domains: null, | ||
}, | ||
relationships: { | ||
organizations: { | ||
data: [ | ||
{ | ||
guid: 'orgId1', | ||
}, | ||
{ | ||
guid: 'foo', | ||
}, | ||
{ | ||
guid: 'bar', | ||
}, | ||
{ | ||
guid: 'baz', | ||
}, | ||
], | ||
}, | ||
}, | ||
links: { | ||
self: { | ||
href: 'https://api.dev.us-gov-west-1.aws-us-gov.cloud.gov/v3/organization_quotas/3564fac5-c405-480e-b758-57912da29f9e', | ||
}, | ||
}, | ||
}, | ||
{ | ||
guid: '3564fac5-c405-480e-b758-57912da29f9f', | ||
created_at: '2017-04-27T19:12:50Z', | ||
updated_at: '2022-07-18T21:01:25Z', | ||
name: 'staging', | ||
apps: { | ||
total_memory_in_mb: 500, | ||
per_process_memory_in_mb: null, | ||
total_instances: null, | ||
per_app_tasks: null, | ||
log_rate_limit_in_bytes_per_second: null, | ||
}, | ||
services: { | ||
paid_services_allowed: true, | ||
total_service_instances: 100, | ||
total_service_keys: 1000, | ||
}, | ||
routes: { | ||
total_routes: 1000, | ||
total_reserved_ports: 5, | ||
}, | ||
domains: { | ||
total_domains: null, | ||
}, | ||
relationships: { | ||
organizations: { | ||
data: [ | ||
{ | ||
guid: 'orgId2', | ||
}, | ||
{ | ||
guid: 'foo', | ||
}, | ||
{ | ||
guid: 'bar', | ||
}, | ||
{ | ||
guid: 'baz', | ||
}, | ||
], | ||
}, | ||
}, | ||
links: { | ||
self: { | ||
href: 'https://api.dev.us-gov-west-1.aws-us-gov.cloud.gov/v3/organization_quotas/3564fac5-c405-480e-b758-57912da29f9e', | ||
}, | ||
}, | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { cookies } from 'next/headers'; | ||
import { describe, expect, it, beforeEach } from '@jest/globals'; | ||
import { render } from '@testing-library/react'; | ||
import { LastViewedOrgLink } from '@/components/LastViewedOrgLink'; | ||
|
||
/* global jest */ | ||
/* eslint no-undef: "off" */ | ||
jest.mock('next/headers', () => ({ | ||
cookies: jest.fn(), | ||
})); | ||
/* eslint no-undef: "error" */ | ||
|
||
describe.skip('<LastViewedOrgLink />', () => { | ||
describe('when no org id cookie is found', () => { | ||
beforeEach(() => { | ||
// TODO: figure out how to mock cookies (we're mocking same as token.test.js but it doesn't work here) | ||
cookies.mockImplementation(() => ({ | ||
get: () => null, | ||
})); | ||
}); | ||
it('returns nothing', async () => { | ||
// act | ||
const component = render(await LastViewedOrgLink()); | ||
// assert | ||
const link = component.queryByRole('link'); | ||
expect(link).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('when get org request fails', () => { | ||
it.todo('returns nothing'); | ||
}); | ||
|
||
describe('when org cookie is present and get org succeeds', () => { | ||
it.todo('shows correct hyperlink and org name'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { describe, expect, it, beforeEach } from '@jest/globals'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { MemoryBar } from '@/components/MemoryBar'; | ||
|
||
describe('<MemoryBar />', () => { | ||
describe('when allocated memory is null', () => { | ||
render(<MemoryBar memoryUsed={50} memoryAllocated={null} />); | ||
|
||
it('says no upper limit', () => { | ||
const text = screen.queryByText(/no upper limit/); | ||
expect(text).toBeInTheDocument(); | ||
}); | ||
|
||
it('hides memory remaining', () => { | ||
const text = screen.queryByText(/remaining/); | ||
expect(text).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('when allocated memory', () => { | ||
beforeEach(() => { | ||
render(<MemoryBar memoryUsed={40} memoryAllocated={100} />); | ||
}); | ||
|
||
it('returns content', () => { | ||
const component = screen.queryByTestId('memory-bar'); | ||
expect(component).toBeInTheDocument(); | ||
}); | ||
|
||
it('shows correct amount remaining', () => { | ||
const remainingText = screen.queryByText(/60MB remaining/); | ||
expect(remainingText).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
31 changes: 0 additions & 31 deletions
31
__tests__/components/OrganizationsList/OrganizationsListItem.test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* @jest-environment jsdom | ||
*/ | ||
import { describe, expect, it } from '@jest/globals'; | ||
import { render } from '@testing-library/react'; | ||
import { ProgressBar } from '@/components/ProgressBar'; | ||
|
||
describe('<ProgressBar />', () => { | ||
describe('when changeColors is false', () => { | ||
it('keeps progress bar green', () => { | ||
// act | ||
const { container } = render( | ||
<ProgressBar total={100} fill={99} changeColors={false} /> | ||
); | ||
// assert | ||
const progressDiv = container.querySelector('.bg-mint'); | ||
expect(progressDiv).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('when percentage is less than threshold1', () => { | ||
it('shows a green bar', () => { | ||
// act | ||
const { container } = render(<ProgressBar total={100} fill={25} />); | ||
// assert | ||
const progressDiv = container.querySelector('.bg-mint'); | ||
expect(progressDiv).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('when percentage is above threshold1 but below threshold2', () => { | ||
it('shows an light red bar', () => { | ||
// act | ||
const { container } = render(<ProgressBar total={100} fill={76} />); | ||
// assert | ||
const progressDiv = container.querySelector('.bg-red-30v'); | ||
expect(progressDiv).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('when percentage is above threshold2', () => { | ||
it('shows a deep red bar', () => { | ||
// act | ||
const { container } = render(<ProgressBar total={100} fill={95} />); | ||
// assert | ||
const progressDiv = container.querySelector('.bg-red-40v'); | ||
expect(progressDiv).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.