Skip to content

Commit

Permalink
chore: release v1.196.0
Browse files Browse the repository at this point in the history
test: update file name, cleanup

chore: disable temp deploy

chore: cleanup

test: add s3 upload missing tests
  • Loading branch information
ccbc-service-account authored and rafasdc committed Oct 4, 2024
1 parent 0507bb1 commit be1fd9a
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 32 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ jobs:
- run: ./.bin/sqitch-last-change-is-tag.sh db

deploy:
# if: github.event.ref == 'refs/heads/main'
# needs: [test-code, test-containers]
if: github.event.ref == 'refs/heads/main'
needs: [test-code, test-containers]
uses: ./.github/workflows/deploy.yaml
secrets:
OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }}
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# [1.196.0](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.195.4...v1.196.0) (2024-10-04)

### Features

- add application coverages upload ([a8d961c](https://github.com/bcgov/CONN-CCBC-portal/commit/a8d961c39e0cf72240d07c0dc90f9cadc0bbc1cf))
- add er and rd to ccbc summary page ([6d3d07d](https://github.com/bcgov/CONN-CCBC-portal/commit/6d3d07d72c5166ced067adc3a0cf005b22b3f338))
- ccbc er rd job ([5bd21ec](https://github.com/bcgov/CONN-CCBC-portal/commit/5bd21ecbeb2e31702c506e4967d67e0523dd1a2b))

## [1.195.5](https://github.com/bcgov/CONN-CCBC-portal/compare/v1.195.4...v1.195.5) (2024-10-04)

### Bug Fixes
Expand Down
23 changes: 21 additions & 2 deletions app/tests/backend/lib/s3upload.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jest.mock('../../../backend/lib/s3client', () => {

jest.setTimeout(10000000);

describe('The s3 download', () => {
describe('The s3 upload', () => {
let app;

beforeEach(async () => {
Expand All @@ -42,7 +42,7 @@ describe('The s3 download', () => {
};
});

const response = await request(app).get('/api/s3/download/test/test');
const response = await request(app).post('/api/s3/upload');
expect(response.status).toBe(404);
});

Expand All @@ -58,5 +58,24 @@ describe('The s3 download', () => {
expect(response.status).toBe(200);
});

it('should upload any file for authorized user', async () => {
mocked(getAuthRole).mockImplementation(() => {
return {
pgRole: 'ccbc_admin',
landingRoute: '/',
};
});

const response = await request(app)
.post('/api/s3/upload')
.set('Content-Type', 'application/json')
.set('Connection', 'keep-alive')
.field('data', JSON.stringify({ name: 'gis-data' }))
.attach('gis-data', `${__dirname}/gis-data-200.json`)
.expect(200);

expect(response.status).toBe(200);
});

jest.resetAllMocks();
});
51 changes: 24 additions & 27 deletions app/tests/pages/analyst/gis/coverages.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { act, fireEvent, screen } from '@testing-library/react';
import { fireEvent, screen } from '@testing-library/react';
import { act } from 'react';
import userEvent from '@testing-library/user-event';
import * as moduleApi from '@growthbook/growthbook-react';
import { FeatureResult, JSONValue } from '@growthbook/growthbook-react';
import coverages from 'pages/analyst/gis/coverages';

import compiledCoveragesQuery, {
Expand Down Expand Up @@ -35,28 +34,19 @@ const pageTestingHelper = new PageTestingHelper<coveragesQuery>({
defaultQueryVariables: {},
});

const mockShowGisUpload: FeatureResult<JSONValue> = {
value: true,
source: 'defaultValue',
on: null,
off: null,
ruleId: 'show_gis_upload',
};

describe('The Gis coverages upload page', () => {
beforeEach(() => {
pageTestingHelper.reinit();
pageTestingHelper.setMockRouterValues({
pathname: '/analyst/gis/coverages',
});
jest.spyOn(moduleApi, 'useFeature').mockReturnValue(mockShowGisUpload);
});

it('highlights the correct nav tabs', async () => {
pageTestingHelper.loadQuery();
pageTestingHelper.renderPage();

const tabName = 'GIS';
const tabName = 'Application Coverages Upload';

expect(
screen.getByRole('link', {
Expand Down Expand Up @@ -84,7 +74,6 @@ describe('The Gis coverages upload page', () => {
await act(async () => {
await userEvent.click(button);
});
expect(fetch).toHaveBeenCalledWith('/api/s3/upload', expect.anything());
});

it('handles incorrect file extension', async () => {
Expand All @@ -94,9 +83,13 @@ describe('The Gis coverages upload page', () => {
type: 'application/vnd.google-earth.kmz',
});

const goodfile = new File([new ArrayBuffer(1)], 'file.zip', {
type: 'application/json',
});
const goodfile = new File(
[new ArrayBuffer(1)],
'CCBC_APPLICATION_COVERAGES_AGGREGATED_NoDATA.zip',
{
type: 'application/zip',
}
);

const inputFile = screen.getAllByTestId('file-test')[0];
const uploadBtn = screen.getByRole('button', {
Expand Down Expand Up @@ -137,9 +130,13 @@ describe('The Gis coverages upload page', () => {
) as jest.Mock;
global.alert = jest.fn() as jest.Mock;

const goodfile = new File([new ArrayBuffer(1)], 'file.zip', {
type: 'application/json',
});
const goodfile = new File(
[new ArrayBuffer(1)],
'CCBC_APPLICATION_COVERAGES_AGGREGATED_NoDATA.zip',
{
type: 'application/zip',
}
);

const inputFile = screen.getAllByTestId('file-test')[0];

Expand All @@ -150,8 +147,6 @@ describe('The Gis coverages upload page', () => {
await act(async () => {
await userEvent.click(button);
});
// expect(global.alert).toHaveBeenCalledTimes(1);
// expect(global.alert).toHaveBeenCalledWith('This is a valid file. You can proceed.');
});

it('handles fetch error from backend', async () => {
Expand All @@ -165,9 +160,13 @@ describe('The Gis coverages upload page', () => {
) as jest.Mock;
global.alert = jest.fn() as jest.Mock;

const goodfile = new File([new ArrayBuffer(1)], 'file.zip', {
type: 'application/json',
});
const goodfile = new File(
[new ArrayBuffer(1)],
'CCBC_APPLICATION_COVERAGES_AGGREGATED_NoDATA.zip',
{
type: 'application/zip',
}
);

const inputFile = screen.getAllByTestId('file-test')[0];

Expand All @@ -179,8 +178,6 @@ describe('The Gis coverages upload page', () => {
await act(async () => {
await userEvent.click(button);
});
// expect(global.alert).toHaveBeenCalledTimes(1);
// expect(global.alert).toHaveBeenCalledWith(Error('oops'));
});

afterEach(() => {
Expand Down
1 change: 1 addition & 0 deletions db/sqitch.plan
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,4 @@ computed_columns/cbc_history 2024-09-03T15:16:07Z Anthony Bushara <anthony@butto
@1.195.5 2024-10-04T20:22:04Z CCBC Service Account <ccbc@button.is> # release v1.195.5
tables/application_er 2024-09-11T18:20:37Z Rafael Solorzano <61289255+rafasdc@users.noreply.github.com> # create application economic regions table
tables/application_rd 2024-09-11T18:21:13Z Rafael Solorzano <61289255+rafasdc@users.noreply.github.com> # create application regional district table
@1.196.0 2024-10-04T16:31:01Z CCBC Service Account <ccbc@button.is> # release v1.196.0
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "CONN-CCBC-portal",
"version": "1.195.5",
"version": "1.196.0",
"main": "index.js",
"repository": "https://github.com/bcgov/CONN-CCBC-portal.git",
"author": "Romer, Meherzad CITZ:EX <Meherzad.Romer@gov.bc.ca>",
Expand Down

0 comments on commit be1fd9a

Please sign in to comment.