-
Notifications
You must be signed in to change notification settings - Fork 4
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
DT-1144: Update Support Destination URLs #2768
Open
rushtong
wants to merge
14
commits into
develop
Choose a base branch
from
gr-DT-1144-support
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
089d202
fix: update to new consent urls
rushtong 6284f96
fix: rm unused
rushtong 98a82cc
fix: more unused
rushtong 19fb0b8
fix: return error responses for component handling
rushtong c3a9001
fix: return error responses for component handling
rushtong 56dd545
fix: handle error responses
rushtong 620782c
Merge remote-tracking branch 'origin/gr-DT-1144-support' into gr-DT-1…
rushtong dcebd42
Merge branch 'refs/heads/develop' into gr-DT-1144-support
rushtong 8b8b81a
fix: first round of component tests
rushtong 60227ee
fix: test for actual submissions; fix upload token handling
rushtong e4ab84c
fix: rm unused
rushtong 4e0793d
Merge branch 'refs/heads/develop' into gr-DT-1144-support
rushtong 8db765b
fix: rename request form
rushtong 1a147de
fix: test for request form
rushtong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
import React from 'react'; | ||
import {mount} from 'cypress/react18'; | ||
import RequestForm from '../../../src/pages/user_profile/RequestForm'; | ||
|
||
describe('SupportRequestsPage Tests', () => { | ||
beforeEach(() => { | ||
cy.viewport(1000, 500); | ||
cy.initApplicationConfig(); | ||
mount(<RequestForm | ||
location={{ | ||
state: { | ||
data: { | ||
profileName: 'name', | ||
email: '[email protected]', | ||
id: 1 | ||
} | ||
} | ||
}} | ||
history={[]} | ||
/>); | ||
}); | ||
|
||
it('Renders all form elements', () => { | ||
cy.get('[data-cy="supportRequestForm"]').should('exist'); | ||
// Note that for the following selectors, each one is a `FormField` components that does not allow a data-cy property | ||
cy.get('[id="checkRegisterDataset"]').should('exist'); | ||
cy.get('[id="checkSOPermissions"]').should('exist'); | ||
cy.get('[id="checkJoinDac"]').should('exist'); | ||
cy.get('[id="extraRequest"]').should('exist'); | ||
cy.get('[data-cy="backButton"]').should('be.enabled'); | ||
cy.get('[data-cy="submitButton"]').should('be.disabled'); | ||
}); | ||
|
||
it('Allows for submission when form is filled out', () => { | ||
cy.get('[id="checkRegisterDataset"]').check(); | ||
cy.get('[data-cy="submitButton"]').should('be.enabled'); | ||
cy.get('[id="checkRegisterDataset"]').uncheck(); | ||
cy.get('[data-cy="submitButton"]').should('be.disabled'); | ||
|
||
cy.get('[id="checkSOPermissions"]').check(); | ||
cy.get('[data-cy="submitButton"]').should('be.enabled'); | ||
cy.get('[id="checkSOPermissions"]').uncheck(); | ||
cy.get('[data-cy="submitButton"]').should('be.disabled'); | ||
|
||
cy.get('[id="checkJoinDac"]').check(); | ||
cy.get('[data-cy="submitButton"]').should('be.enabled'); | ||
cy.get('[id="checkJoinDac"]').uncheck(); | ||
cy.get('[data-cy="submitButton"]').should('be.disabled'); | ||
|
||
cy.get('[id="extraRequest"]').type('Extra Request'); | ||
// Note that the UI currently does not allow submission without a checkbox selected | ||
cy.get('[data-cy="submitButton"]').should('be.disabled'); | ||
|
||
// Test actual submission | ||
cy.intercept({method: 'POST', url: '**/support/request'}, {statusCode: 201}).as('request'); | ||
cy.get('[id="checkRegisterDataset"]').check(); | ||
cy.get('[data-cy="submitButton"]').click(); | ||
cy.wait(['@request']).then((interception) => { | ||
expect(interception).to.not.be.null; | ||
}); | ||
}); | ||
|
||
}); |
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,166 @@ | ||
/* eslint-disable no-undef */ | ||
|
||
import React from 'react'; | ||
import {mount} from 'cypress/react18'; | ||
import {SupportRequestModal} from '../../../src/components/modals/SupportRequestModal'; | ||
import {Storage} from '../../../src/libs/storage'; | ||
|
||
const mockUser = { | ||
displayName: 'Display Name', | ||
email: '[email protected]' | ||
}; | ||
|
||
const handler = () => { | ||
}; | ||
|
||
describe('Support Request Modal Tests', () => { | ||
|
||
beforeEach(() => { | ||
cy.viewport(500, 500); | ||
cy.initApplicationConfig(); | ||
}); | ||
|
||
describe('When a user is logged in:', () => { | ||
beforeEach(() => { | ||
cy.stub(Storage, 'userIsLogged').returns(true); | ||
cy.stub(Storage, 'getCurrentUser').returns(mockUser); | ||
}); | ||
|
||
it('Renders form correctly', () => { | ||
mount(<SupportRequestModal | ||
onCloseRequest={handler} | ||
onOKRequest={handler} | ||
url={'url'} | ||
showModal={true} | ||
/>); | ||
// These fields should exist | ||
cy.get('[data-cy="closeButton"]').should('exist'); | ||
cy.get('[data-cy="supportForm"]').should('exist'); | ||
cy.get('[data-cy="supportFormEmail"]').should('not.exist'); | ||
cy.get('[data-cy="supportFormName"]').should('not.exist'); | ||
cy.get('[data-cy="supportFormType"]').should('exist'); | ||
cy.get('[data-cy="supportFormSubject"]').should('exist'); | ||
cy.get('[data-cy="supportFormDescription"]').should('exist'); | ||
cy.get('[data-cy="supportFormAttachment"]').should('exist'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormCancel"]').should('not.be.disabled'); | ||
}); | ||
|
||
it('Submits properly', () => { | ||
mount(<SupportRequestModal | ||
onCloseRequest={handler} | ||
onOKRequest={handler} | ||
url={'url'} | ||
showModal={true} | ||
/>); | ||
// Ensure that all required fields are filled out before submit becomes available | ||
cy.get('[data-cy="supportFormType"]').select('bug'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormSubject"]').type('Subject'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormDescription"]').type('Description'); | ||
// Form is complete: | ||
cy.get('[data-cy="supportFormSubmit"]').should('not.be.disabled'); | ||
cy.get('[data-cy="supportFormCancel"]').should('not.be.disabled'); | ||
cy.intercept({method: 'POST', url: '**/support/request'}, {statusCode: 201}).as('request'); | ||
cy.intercept({method: 'POST', url: '**/support/upload'}, {statusCode: 201, body: {'token': 'token_string'}}).as('upload'); | ||
// {force: true} is necessary here due to the surrounding div that covers the input. | ||
cy.get('[data-cy="supportFormAttachment"]').selectFile(['cypress/fixtures/example.json'], {force: true}); | ||
cy.get('[data-cy="supportFormSubmit"]').click(); | ||
cy.wait(['@request', '@upload']).then((interceptions) => { | ||
assert(interceptions.length === 2); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe('When a user is NOT logged in:', () => { | ||
beforeEach(() => { | ||
cy.stub(Storage, 'userIsLogged').returns(false); | ||
cy.stub(Storage, 'getCurrentUser').returns(undefined); | ||
}); | ||
|
||
it('Renders form correctly', () => { | ||
mount(<SupportRequestModal | ||
onCloseRequest={handler} | ||
onOKRequest={handler} | ||
url={'url'} | ||
showModal={true} | ||
/>); | ||
// These fields should exist | ||
cy.get('[data-cy="closeButton"]').should('exist'); | ||
cy.get('[data-cy="supportForm"]').should('exist'); | ||
cy.get('[data-cy="supportFormEmail"]').should('exist'); | ||
cy.get('[data-cy="supportFormName"]').should('exist'); | ||
cy.get('[data-cy="supportFormType"]').should('exist'); | ||
cy.get('[data-cy="supportFormSubject"]').should('exist'); | ||
cy.get('[data-cy="supportFormDescription"]').should('exist'); | ||
cy.get('[data-cy="supportFormAttachment"]').should('exist'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormCancel"]').should('not.be.disabled'); | ||
}); | ||
|
||
it('Submits properly', () => { | ||
mount(<SupportRequestModal | ||
onCloseRequest={handler} | ||
onOKRequest={handler} | ||
url={'url'} | ||
showModal={true} | ||
/>); | ||
// Ensure that all required fields are filled out before submit becomes available | ||
cy.get('[data-cy="supportFormName"]').type('Name'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormType"]').select('bug'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormSubject"]').type('Subject'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormDescription"]').type('Description'); | ||
cy.get('[data-cy="supportFormSubmit"]').should('be.disabled'); | ||
cy.get('[data-cy="supportFormEmail"]').type(mockUser.email); | ||
// Form is complete: | ||
cy.get('[data-cy="supportFormSubmit"]').should('not.be.disabled'); | ||
cy.get('[data-cy="supportFormCancel"]').should('not.be.disabled'); | ||
cy.intercept({method: 'POST', url: '**/support/request'}, {statusCode: 201}).as('request'); | ||
cy.intercept({method: 'POST', url: '**/support/upload'}, {statusCode: 201, body: {'token': 'token_string'}}).as('upload'); | ||
// {force: true} is necessary here due to the surrounding div that covers the input. | ||
cy.get('[data-cy="supportFormAttachment"]').selectFile(['cypress/fixtures/example.json'], {force: true}); | ||
cy.get('[data-cy="supportFormSubmit"]').click(); | ||
cy.wait(['@request', '@upload']).then((interceptions) => { | ||
assert(interceptions.length === 2); | ||
}); | ||
}); | ||
|
||
}); | ||
|
||
describe('File Attachments', () => { | ||
beforeEach(() => { | ||
cy.stub(Storage, 'userIsLogged').returns(false); | ||
cy.stub(Storage, 'getCurrentUser').returns(undefined); | ||
}); | ||
it('Single attachment displayed', () => { | ||
mount(<SupportRequestModal | ||
onCloseRequest={handler} | ||
onOKRequest={handler} | ||
url={'url'} | ||
showModal={true} | ||
/>); | ||
// {force: true} is necessary here due to the surrounding div that covers the input. | ||
cy.get('[data-cy="supportFormAttachment"]').selectFile(['cypress/fixtures/example.json'], {force: true}); | ||
const container = cy.get('[data-cy="supportFormAttachmentContainer"]'); | ||
expect(container.contains('example.json')); | ||
}); | ||
|
||
it('Multiple attachments displayed', () => { | ||
mount(<SupportRequestModal | ||
onCloseRequest={handler} | ||
onOKRequest={handler} | ||
url={'url'} | ||
showModal={true} | ||
/>); | ||
// {force: true} is necessary here due to the surrounding div that covers the input. | ||
cy.get('[data-cy="supportFormAttachment"]').selectFile(['cypress/fixtures/example.json', 'cypress/fixtures/dataset-registration-schema_v1.json'], {force: true}); | ||
const container = cy.get('[data-cy="supportFormAttachmentContainer"]'); | ||
expect(container.contains('2 files selected')); | ||
}); | ||
}); | ||
}); |
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 |
---|---|---|
|
@@ -42,10 +42,6 @@ export const getOntologyUrl = async() => { | |
return await Config.getOntologyApiUrl(); | ||
}; | ||
|
||
export const sleep = (ms) => { | ||
return new Promise(resolve => setTimeout(resolve, ms)); | ||
}; | ||
|
||
export const fetchOk = async (...args) => { | ||
//TODO: Remove spinnerService calls | ||
spinnerService.showAll(); | ||
|
@@ -74,11 +70,6 @@ export const fetchAny = async (...args) => { | |
return res; | ||
}; | ||
|
||
export const getFileNameFromHttpResponse = (response) => { | ||
const respHeaders = response.headers; | ||
return respHeaders.get('Content-Disposition').split(';')[1].trim().split('=')[1]; | ||
}; | ||
|
||
Comment on lines
-77
to
-81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Drive-by fix: unused method. |
||
export const reportError = async (url, status) => { | ||
const msg = 'Error fetching response: ' | ||
.concat(JSON.stringify(url)) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by fix: unused method.