Skip to content

Commit

Permalink
e2e: rewrite submission tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karolina-siemieniuk-morawska committed Sep 1, 2023
1 parent 28da4d2 commit 5408bf0
Show file tree
Hide file tree
Showing 26 changed files with 451 additions and 817 deletions.
2 changes: 1 addition & 1 deletion e2e/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module.exports = defineConfig({
mobile_viewport_height: 667,
},
retries: {
runMode: 2,
runMode: 0,
openMode: 0,
},
video: false,
Expand Down
58 changes: 17 additions & 41 deletions e2e/cypress/e2e/authors.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ describe('Author Submission', () => {
});
});

it.skip('submits a new author', () => {
it('submits a new author', () => {
cy.login('cataloger');

const formData = {
given_name: 'Diego',
family_name: 'Martínez Santos',
Expand All @@ -88,47 +89,12 @@ describe('Author Submission', () => {
},
],
};
const expectedMetadata = {
name: {
preferred_name: 'Diego Martínez',
value: 'Martínez Santos, Diego',
name_variants: ['Santos, Diego Martinez'],
},
acquisition_source: {
email: 'cataloger@inspirehep.net',
method: 'submitter',
},
arxiv_categories: ['hep-ex', 'hep-ph'],
email_addresses: [
{ value: 'diego@martinez.ch', current: true },
{ value: 'private@martinez.ch', hidden: true },
],
status: 'retired',
positions: [
{
curated_relation: false,
current: true,
institution: 'CERN',
start_date: '2015',
},
],
advisors: [
{
curated_relation: false,
name: 'Urhan, Harun',
},
],
};
const expectedWorkflow = {
_workflow: { data_type: 'authors' },
};

cy.visit('/submissions/authors');
cy.testSubmission({
collection: 'authors',
formData,
expectedMetadata,
}).then((newWorkflow) => {
cy.wrap(newWorkflow).should('like', expectedWorkflow);
collection: 'authors',
submissionType: 'workflow',
});
});

Expand All @@ -150,8 +116,14 @@ describe('Author Submission', () => {
});

it('updates its own author profile', () => {
cy.login('johnellis');
const recordId = 1010819;
const expectedMetadata = {
name: {
value: 'John Richard Ellis',
},
};

cy.login('johnellis');
cy.visit(`/submissions/authors/${recordId}`);
cy.testUpdateSubmission({
collection: 'authors',
Expand All @@ -160,7 +132,11 @@ describe('Author Submission', () => {
display_name: ': Updated',
},
expectedMetadata: {
name: { preferred_name: 'John Richard Ellis: Updated' },
name: {
value: 'Ellis, John Richard',
name_variants: [ 'Ellis, Jonathan Richard' ],
preferred_name: expectedMetadata.name.value + ': Updated',
},
},
});
});
Expand Down
35 changes: 6 additions & 29 deletions e2e/cypress/e2e/conferences.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ describe('Conference Submission', () => {
});
});

it.skip('submits a new conference', () => {
it('submits a new conference', () => {
const startDateMoment = moment().add(1, 'day');
const endDateMoment = moment().add(7, 'day');
const formData = {
Expand Down Expand Up @@ -115,47 +115,24 @@ describe('Conference Submission', () => {
keywords: ['keyword1', 'keyword2'],
};
const expectedMetadata = {
acronyms: ['AC'],
addresses: [
{
cities: ['Geneva'],
country: 'Switzerland',
country_code: 'CH',
},
],
opening_date: startDateMoment.format('YYYY-MM-DD'),
closing_date: endDateMoment.format('YYYY-MM-DD'),
inspire_categories: [{ term: 'Accelerators' }],
keywords: [{ value: 'keyword1' }, { value: 'keyword2' }],
public_notes: [{ value: 'This is some additional info' }],
series: [
{
name: 'Amazing conference series',
number: 24,
},
],
short_description: {
value:
'<div>This is an amazing conference about the wonders of physics and accelerators</div>',
},
titles: [
{
subtitle: 'The best conference ever',
title: 'Amazing conference',
},
],
urls: [{ value: 'https://home.cern' }],
};

cy.visit('/submissions/conferences');
cy.testSubmission({
collection: 'conferences',
expectedMetadata: expectedMetadata.titles[0].title,
formData,
expectedMetadata,
collection: 'conferences',
submissionType: 'record'
});
});

it.skip('warns about already existing conference during selected dates [conferences/1794610]', () => {
const startDate = moment('2021-08-30');
it('warns about already existing conference during selected dates [conferences/1794610]', () => {
cy.visit('/submissions/conferences');
cy.registerRoute();
cy.fillForm({
Expand Down
5 changes: 3 additions & 2 deletions e2e/cypress/e2e/experiments.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('Experiment Submission', () => {
});
});

it.skip('submits a new experiments', () => {
it('submits a new experiments', () => {
const formData = {
project_type: 'collaboration',
legacy_name: 'Test name',
Expand All @@ -49,9 +49,10 @@ describe('Experiment Submission', () => {
cy.visit('/submissions/experiments');
cy.wait(500);
cy.testSubmission({
expectedMetadata,
expectedMetadata: expectedMetadata.legacy_name,
formData,
collection: 'experiments',
submissionType: 'editor'
});
});

Expand Down
3 changes: 2 additions & 1 deletion e2e/cypress/e2e/institutions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ describe('Institution Submission', () => {
cy.visit('/submissions/institutions');
cy.wait(500);
cy.testSubmission({
expectedMetadata,
expectedMetadata: expectedMetadata.identifier,
formData,
collection: 'institutions',
submissionType: 'editor'
});
});

Expand Down
78 changes: 22 additions & 56 deletions e2e/cypress/e2e/jobs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe('Job Submission', () => {
});
});

it.skip('submits and updates new job', () => {
it('submits and new job', () => {
const formData = {
title: 'Software developer',
external_job_identifier: '07587',
Expand Down Expand Up @@ -75,64 +75,30 @@ describe('Job Submission', () => {
description: 'This is my description',
};

cy.visit('/submissions/jobs');
cy.testSubmission({
formData,
collection: 'jobs',
submissionType: 'workflow',
});
});

it('updates new job', () => {
const expectedMetadata = {
acquisition_source: {
email: 'cataloger@inspirehep.net',
method: 'submitter',
},
status: 'pending',
position: 'Software developer',
external_job_identifier: '07587',
institutions: [{ value: 'CERN' }, { value: 'Berkley' }],
regions: ['Europe', 'Asia'],
arxiv_categories: ['cond-mat', 'astro-ph'],
ranks: ['POSTDOC', 'MASTER'],
accelerator_experiments: [{ name: 'Atlas' }, { name: 'CMS' }],
urls: [{ value: 'https://someinfo.com' }],
deadline_date: moment()
.add(1, 'day')
.format('YYYY-MM-DD'),
contact_details: [
{
name: 'John Doe',
email: 'john@yahoo.com',
},
{
name: 'Jane Doe',
email: 'jane@yahoo.com',
},
],
reference_letters: {
emails: ['references@yahoo.com'],
urls: [{ value: 'https://uploadReferences.com' }],
},
description: '<div>This is my description</div>',
position: 'Cherenkov Telescope Array',
};

cy.visit('/submissions/jobs');
cy
.testSubmission({
collection: 'jobs',
formData,
expectedMetadata,
})
.then(newRecord => {
const recordId = newRecord.metadata.control_number;
cy.visit(`/submissions/jobs/${recordId}`);
cy.testUpdateSubmission({
collection: 'jobs',
recordId,
formData: {
title: '-Updated',
status: 'closed',
},
expectedMetadata: {
...expectedMetadata,
position: expectedMetadata.position + '-Updated',
status: 'closed',
},
});
});
cy.visit('/submissions/jobs/1813119');
cy.testUpdateSubmission({
collection: 'jobs',
recordId: 1813119,
formData: {
title: ': Updated',
},
expectedMetadata: {
position: expectedMetadata.position + ': Updated',
},
});
});

afterEach(() => {
Expand Down
3 changes: 2 additions & 1 deletion e2e/cypress/e2e/journals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ describe('Journal Submission', () => {
};
cy.visit('/submissions/journals');
cy.testSubmission({
expectedMetadata,
expectedMetadata: expectedMetadata.short_title,
formData,
collection: 'journals',
submissionType: 'editor'
});
});

Expand Down
Loading

0 comments on commit 5408bf0

Please sign in to comment.