Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1002 from UserOfficeProject/release-2022-08-31
Browse files Browse the repository at this point in the history
Release 2022 08 31
  • Loading branch information
simonfernandes authored Aug 31, 2022
2 parents d02f0f4 + c9a67a3 commit b27082a
Show file tree
Hide file tree
Showing 124 changed files with 4,322 additions and 2,381 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REACT_APP_ORCID_REDIRECT=
GENERATE_SOURCEMAP=false

SCHEMA_URL=http://localhost:4100/graphql
SCHEMA_URL=http://localhost:4000/graphql
69 changes: 55 additions & 14 deletions .github/workflows/test-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,35 @@ jobs:
local branch=$1
local found=0
shift
for endpoint in $@; do
local json=$(curl -s $endpoint)
local branch_found=$(echo $json | jq -c ".[] | select(.name==\"$branch\") | .name")
# to track what we found
>&2 echo "$endpoint -> $branch_found"
if [[ $branch_found != "" ]]; then
found=$((found += 1))
fi
done
local dockerhub_endpoint=$1
local dockerhub_json=$(curl -s $dockerhub_endpoint)
local dockerhub_branch_found=$(echo $dockerhub_json | jq -c ".results[] | select(.name==\"$branch\") | .name")
# to track what we found
>&2 echo "$dockerhub_endpoint -> $dockerhub_branch_found"
if [[ $dockerhub_branch_found != "" ]]; then
found=$((found += 1))
fi
local github_endpoint=$2
local github_json=$(curl -s $github_endpoint)
local github_branch_found=$(echo $github_json | jq -c ".[] | select(.name==\"$branch\") | .name")
# to track what we found
>&2 echo "$github_endpoint -> $github_branch_found"
if [[ $github_branch_found != "" ]]; then
found=$((found += 1))
fi
echo $found
}
BE_TAGS=$(check_feature ${{ github.head_ref }} \
https://registry.hub.docker.com/v1/repositories/dmsc/duo-backend/tags \
https://api.github.com/repos/UserOfficeProject/user-office-backend/branches
https://registry.hub.docker.com/v2/repositories/dmsc/duo-backend/tags \
https://api.github.com/repos/UserOfficeProject/user-office-backend/branches?per_page=100
)
FACTORY_TAGS=$(check_feature ${{ github.head_ref }} \
https://registry.hub.docker.com/v1/repositories/dmsc/duo-factory/tags \
https://api.github.com/repos/UserOfficeProject/user-office-factory/branches
https://registry.hub.docker.com/v2/repositories/dmsc/duo-factory/tags \
https://api.github.com/repos/UserOfficeProject/user-office-factory/branches?per_page=100
)
BE_TAG=develop
Expand Down Expand Up @@ -263,7 +273,7 @@ jobs:
run: |
DOCKERFILE_VERSION=${{ hashFiles('Dockerfile.e2e', 'cypress/*.json') }}
TAG="docker.pkg.github.com/userofficeproject/user-office-frontend/e2e-cypress-core:$DOCKERFILE_VERSION"
docker pull $TAG
docker pull $TAG
docker tag $TAG e2e-cypress:latest
- name: Load app cache
Expand Down Expand Up @@ -330,6 +340,37 @@ jobs:
-f docker-compose.all.yml \
up --exit-code-from cypress
- name: Run docker-compose stfc
env:
SVC_ACC_TOKEN: ${{ secrets.SVC_ACC_TOKEN }}
run: |
cd "$GITHUB_WORKSPACE/.."
REPO_DIR_NAME=$(basename $GITHUB_WORKSPACE)
export USER_OFFICE_BACKEND_TAG=${{ needs.resolve_dep.outputs.BE_TAG }}
export USER_OFFICE_BACKEND_DIR=user-office-backend
export USER_OFFICE_BACKEND=http://backend:4000/graphql
export USER_OFFICE_ENDPOINT=$USER_OFFICE_BACKEND
export USER_OFFICE_FACTORY_TAG=${{ needs.resolve_dep.outputs.FACTORY_TAG }}
export USER_OFFICE_FACTORY_ENDPOINT=http://factory:4500/generate
export USER_OFFICE_FRONTEND_DIR=$REPO_DIR_NAME
export BUILD_TAG=${{ github.sha }}
export CYPRES_SPEC_PATTERN=${{ matrix.pattern }}
docker-compose --project-directory $PWD \
-f "$REPO_DIR_NAME/docker-compose-stfc.e2e.yml" \
up -d mockServer
sleep 10
docker-compose --project-directory $PWD \
-f "$REPO_DIR_NAME/docker-compose-stfc.e2e.yml" \
up --exit-code-from cypress
- name: Upload cypres screenshots
if: ${{ failure() }}
uses: actions/upload-artifact@v2
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ src/generated/
README.md
.vscode/
cypress/fixtures/
docker-compose-stfc.e2e.yml
1 change: 1 addition & 0 deletions cypress/fixtures/shipments_template.json

Large diffs are not rendered by default.

90 changes: 87 additions & 3 deletions cypress/integration/SEP.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import faker from 'faker';
import { faker } from '@faker-js/faker';

import {
ProposalEndStatus,
Expand All @@ -7,8 +7,12 @@ import {
UserRole,
UpdateUserMutationVariables,
User,
TemplateGroupId,
FeatureId,
} from '../../src/generated/sdk';
import featureFlags from '../support/featureFlags';
import initialDBData from '../support/initialDBData';
import { updatedCall } from '../support/utils';

const sepMembers = {
chair: initialDBData.users.user2,
Expand Down Expand Up @@ -107,8 +111,35 @@ const instrument = {
let createdSepId: number;
let createdProposalPk: number;
let createdProposalId: string;
let createdWorkflowId: number;
let createdEsiTemplateId: number;

function createWorkflowAndEsiTemplate() {
const workflowName = faker.lorem.words(2);
const workflowDescription = faker.lorem.words(5);

cy.createProposalWorkflow({
name: workflowName,
description: workflowDescription,
}).then((result) => {
const workflow = result.createProposalWorkflow.proposalWorkflow;
if (workflow) {
createdWorkflowId = workflow.id;

cy.createTemplate({
name: 'default esi template',
groupId: TemplateGroupId.PROPOSAL_ESI,
}).then((result) => {
if (result.createTemplate.template) {
createdEsiTemplateId = result.createTemplate.template.templateId;
}
});
}
});
}

function initializationBeforeTests() {
cy.getAndStoreFeaturesEnabled();
cy.resetDB();
cy.createSep({
code: sep1.code,
Expand Down Expand Up @@ -154,15 +185,26 @@ function initializationBeforeTests() {
id: sepMembers.reviewer.id,
roles: [initialDBData.roles.sepReviewer],
});
createWorkflowAndEsiTemplate();
}

context('SEP reviews tests', () => {
beforeEach(() => {
initializationBeforeTests();
cy.getAndStoreFeaturesEnabled();
});
beforeEach(function () {
if (!featureFlags.getEnabledFeatures().get(FeatureId.SEP_REVIEW)) {
this.skip();
}
});

describe('User officer role', () => {
it('Officer should be able to assign proposal to existing SEP', () => {
it('Officer should be able to assign proposal to existing SEP', function () {
cy.getAndStoreFeaturesEnabled();
if (featureFlags.getEnabledFeatures().get(FeatureId.EXTERNAL_AUTH)) {
this.skip();
}
cy.login('officer');
cy.visit(`/SEPPage/${createdSepId}?tab=2`);

Expand All @@ -183,6 +225,32 @@ context('SEP reviews tests', () => {
);
cy.get('[data-cy="sep-selection"]').click();

// NOTE: Check first for empty list because call has no SEPs assigned.
cy.get('[role="presentation"] .MuiAutocomplete-noOptions').contains(
'No SEPs'
);

// NOTE: Assign SEP to a call.
cy.updateCall({
id: initialDBData.call.id,
...updatedCall,
proposalWorkflowId: createdWorkflowId,
esiTemplateId: createdEsiTemplateId,
seps: [createdSepId],
});

cy.reload();

cy.contains(proposal1.title).parent().find('[type="checkbox"]').check();

cy.get("[aria-label='Assign proposals to SEP']").first().click();

cy.get('[data-cy="sep-selection"] input').should(
'not.have.class',
'Mui-disabled'
);
cy.get('[data-cy="sep-selection"]').click();

cy.get('[data-cy="sep-selection-options"]').contains(sep1.code).click();

cy.get('[data-cy="submit"]').click();
Expand Down Expand Up @@ -857,6 +925,12 @@ context('SEP meeting components tests', () => {

beforeEach(() => {
initializationBeforeTests();
});
beforeEach(function () {
if (!featureFlags.getEnabledFeatures().get(FeatureId.SEP_REVIEW)) {
this.skip();
}
createWorkflowAndEsiTemplate();
cy.assignProposalsToSep({
sepId: createdSepId,
proposals: [
Expand Down Expand Up @@ -909,6 +983,14 @@ context('SEP meeting components tests', () => {
});
}
});
// NOTE: Assign SEP to a call.
cy.updateCall({
id: initialDBData.call.id,
...updatedCall,
proposalWorkflowId: createdWorkflowId,
esiTemplateId: createdEsiTemplateId,
seps: [createdSepId],
});
});

describe('User Officer role', () => {
Expand Down Expand Up @@ -1554,7 +1636,9 @@ context('SEP meeting components tests', () => {
cy.get('[data-cy="download-sep-xlsx"]').click();

cy.get('[data-cy="preparing-download-dialog"]').should('exist');
cy.get('[data-cy="preparing-download-dialog-item"]').contains('call 1');
cy.get('[data-cy="preparing-download-dialog-item"]').contains(
updatedCall.shortCode
);
});

it('Officer should be able to remove assigned SEP member from proposal in existing SEP', () => {
Expand Down
52 changes: 51 additions & 1 deletion cypress/integration/appSettings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { FeatureId, ReviewerFilter } from '../../src/generated/sdk';
import featureFlags from '../support/featureFlags';
import initialDBData from '../support/initialDBData';

context('App settings tests', () => {
beforeEach(() => {
cy.viewport(1920, 2000);
cy.getAndStoreAppSettings();
cy.getAndStoreFeaturesEnabled();
cy.resetDB();
});

Expand All @@ -25,11 +30,15 @@ context('App settings tests', () => {
initialDBData.getFormats().dateTimeFormat
);

cy.get('body').type('{esc}');
cy.get('[data-cy="close-modal-btn"]').click();

cy.get('[data-cy="officer-menu-items"]').contains('Settings').click();
cy.get('[data-cy="officer-menu-items"]').contains('App settings').click();

cy.get('[data-cy="settings-table"]')
.find('button[aria-label="Next Page"]')
.click();

cy.get('[data-cy="settings-table"]')
.contains(initialDBData.settings.dateTimeFormat.id)
.parent()
Expand Down Expand Up @@ -73,5 +82,46 @@ context('App settings tests', () => {
newDateTimeFormat
);
});

it('Instrument Scientist filter should differ based on setting value', function () {
if (featureFlags.getEnabledFeatures().get(FeatureId.EXTERNAL_AUTH)) {
//temporarily skipping, until instr sci login is enabled
this.skip();
}
const scientist2 = initialDBData.users.user2;

cy.updateUserRoles({
id: scientist2.id,

roles: [initialDBData.roles.instrumentScientist],
});

cy.login(scientist2);

cy.visit('/');

cy.log(
'hello' + JSON.stringify(initialDBData.getFormats().reviewerFilter)
);

cy.contains('Proposals');

if (initialDBData.getFormats().reviewerFilter === 'ALL') {
cy.get('[data-cy="reviewer-filter"] input').should(
'have.value',
ReviewerFilter.ALL
);
} else {
cy.get('[data-cy="reviewer-filter"] input').should(
'have.value',
ReviewerFilter.ME
);
}
if (initialDBData.getFormats().statusFilter === 'ALL') {
cy.get('[data-cy="status-filter"] input').should('have.value', 0);
} else {
cy.get('[data-cy="status-filter"] input').should('have.value', 2);
}
});
});
});
Loading

0 comments on commit b27082a

Please sign in to comment.