Skip to content

Commit ca47008

Browse files
committed
updated Cypress.env uses
1 parent a92c928 commit ca47008

2 files changed

Lines changed: 55 additions & 54 deletions

File tree

cypress.config.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,6 @@ export default defineConfig({
2323
// Account used to test basic submission process
2424
DSPACE_TEST_SUBMIT_USER: 'dspacedemo+submit@gmail.com',
2525
DSPACE_TEST_SUBMIT_USER_PASSWORD: 'dspace',
26-
// Administrator users group
27-
DSPACE_ADMINISTRATOR_GROUP: 'e59f5659-bff9-451e-b28f-439e7bd467e4',
28-
//Collection to send and test workflow item
29-
DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME: '1-step Workflow collection',
30-
//Collection to send a test people
31-
DSPACE_TEST_PEOPLE_COLLECTION_NAME: 'People',
32-
//Collection to send a test Org Unit
33-
DSPACE_TEST_ORG_UNIT_COLLECTION_NAME: 'OrgUnits',
34-
//Collection to send a test Journal
35-
DSPACE_TEST_JOURNAL_COLLECTION_NAME: 'Journals',
36-
//Collection to send a test Journal Volumes
37-
DSPACE_TEST_JOURNAL_VOLUME_COLLECTION_NAME: 'Journal Volumes',
38-
//Collection to send a test Journal Issues
39-
DSPACE_TEST_JOURNAL_ISSUE_COLLECTION_NAME: 'Journal Issues',
4026
},
4127
e2e: {
4228
expose: {
@@ -57,6 +43,16 @@ export default defineConfig({
5743
DSPACE_TEST_SUBMIT_PERSON_COLLECTION_NAME: 'People',
5844
DSPACE_TEST_SUBMIT_USER_UUID: '914955b1-cf2e-4884-8af7-a166aa24cf73',
5945
DSPACE_TEST_ADMIN_USER_UUID: '335647b6-8a52-4ecb-a8c1-7ebabb199bda',
46+
//Collection to send a test people
47+
DSPACE_TEST_PEOPLE_COLLECTION_NAME: 'People',
48+
//Collection to send a test Org Unit
49+
DSPACE_TEST_ORG_UNIT_COLLECTION_NAME: 'OrgUnits',
50+
//Collection to send a test Journal
51+
DSPACE_TEST_JOURNAL_COLLECTION_NAME: 'Journals',
52+
//Collection to send a test Journal Volumes
53+
DSPACE_TEST_JOURNAL_VOLUME_COLLECTION_NAME: 'Journal Volumes',
54+
//Collection to send a test Journal Issues
55+
DSPACE_TEST_JOURNAL_ISSUE_COLLECTION_NAME: 'Journal Issues',
6056
},
6157
// Setup our plugins for e2e tests
6258
setupNodeEvents(on, config) {

cypress/e2e/my-dspace.cy.ts

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -164,68 +164,74 @@ describe('My DSpace page', () => {
164164
//Enter to MyDspace and validate that submission-dropdown is visible
165165
beforeEach(() => {
166166
cy.visit('/mydspace');
167-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
167+
cy.env(['DSPACE_TEST_ADMIN_USER', 'DSPACE_TEST_ADMIN_PASSWORD']).then(({ DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD }) => {
168+
cy.loginViaForm(DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD);
169+
});
168170
cy.get('[data-test="submission-dropdown"]').should('be.visible').click();
169171
});
170172

171173
it('should let you send a new Item', () => {
172174
const title = 'test item';
173-
startSubmission('none', Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME'));
175+
startSubmission('none', Cypress.expose('DSPACE_TEST_SUBMIT_COLLECTION_NAME'));
174176
fillSubmission(['title', 'date_issued', 'type'], title);
175177
validateSubmission(title);
176178
});
177179

178180
it('should let you send a new Publication', () => {
179181
const title = 'test publication';
180-
startSubmission('Publication', Cypress.env('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME'));
182+
startSubmission('Publication', Cypress.expose('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME'));
181183
fillSubmission(['title', 'date_issued', 'type'], title);
182184
validateSubmission(title);
183185
});
184186

185187
it('should let you send a new Peson', () => {
186188
const name = 'Tester';
187-
startSubmission('Person', Cypress.env('DSPACE_TEST_PEOPLE_COLLECTION_NAME'));
189+
startSubmission('Person', Cypress.expose('DSPACE_TEST_PEOPLE_COLLECTION_NAME'));
188190
fillSubmission(['givenName'], undefined, name);
189191
validateSubmission(name);
190192
});
191193

192194
it('should let you send a new Org Unit', () => {
193195
const name = 'test Org Unit';
194-
startSubmission('OrgUnit', Cypress.env('DSPACE_TEST_ORG_UNIT_COLLECTION_NAME'));
196+
startSubmission('OrgUnit', Cypress.expose('DSPACE_TEST_ORG_UNIT_COLLECTION_NAME'));
195197
fillSubmission(['legalName'], undefined, name);
196198
validateSubmission(name);
197199
});
198200

199201
it('should let you send a new Journal', () => {
200202
const title = 'test Journal';
201-
startSubmission('Journal', Cypress.env('DSPACE_TEST_JOURNAL_COLLECTION_NAME'));
203+
startSubmission('Journal', Cypress.expose('DSPACE_TEST_JOURNAL_COLLECTION_NAME'));
202204
fillSubmission(['title'], title);
203205
validateSubmission(title);
204206
});
205207

206208
it('should let you send a new Journal Volume', () => {
207209
const title = 'test Journal Volume';
208-
startSubmission('JournalVolume', Cypress.env('DSPACE_TEST_JOURNAL_VOLUME_COLLECTION_NAME'));
210+
startSubmission('JournalVolume', Cypress.expose('DSPACE_TEST_JOURNAL_VOLUME_COLLECTION_NAME'));
209211
fillSubmission(['title'], title);
210212
validateSubmission(title);
211213
});
212214

213215
it('should let you send a new Journal Issue', () => {
214216
const title = 'test Journal Issue';
215-
startSubmission('JournalIssue', Cypress.env('DSPACE_TEST_JOURNAL_ISSUE_COLLECTION_NAME'));
217+
startSubmission('JournalIssue', Cypress.expose('DSPACE_TEST_JOURNAL_ISSUE_COLLECTION_NAME'));
216218
fillSubmission(['title'], title);
217219
validateSubmission(title);
218220
});
219221

220222
});
221223

222224
describe('Testing import external button', () => {
223-
it('should pass accesibility tests', () => {
225+
beforeEach(() => {
224226
cy.visit('/mydspace');
225227

226228
// This page is restricted, so we will be shown the login form. Fill it out & submit.
227-
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
229+
cy.env(['DSPACE_TEST_SUBMIT_USER', 'DSPACE_TEST_SUBMIT_USER_PASSWORD']).then(({ DSPACE_TEST_SUBMIT_USER, DSPACE_TEST_SUBMIT_USER_PASSWORD }) => {
230+
cy.loginViaForm(DSPACE_TEST_SUBMIT_USER, DSPACE_TEST_SUBMIT_USER_PASSWORD);
231+
});
232+
});
228233

234+
it('should pass accesibility tests', () => {
229235
// Open the New Import dropdown
230236
cy.get('button[data-test="import-dropdown"]').click();
231237
// Click on the "Item" type in that dropdown
@@ -242,11 +248,6 @@ describe('My DSpace page', () => {
242248
});
243249

244250
it('should let you import an item from external source', () => {
245-
cy.visit('/mydspace');
246-
247-
// This page is restricted, so we will be shown the login form. Fill it out & submit.
248-
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
249-
250251
// Open the New Import dropdown
251252
cy.get('button[data-test="import-dropdown"]').click();
252253

@@ -275,19 +276,14 @@ describe('My DSpace page', () => {
275276
cy.get('ds-collection-dropdown').should('be.visible');
276277

277278
// Type the name of the collection and click
278-
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME'));
279-
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.env('DSPACE_TEST_SUBMIT_COLLECTION_NAME')).concat('"]')).click();
279+
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.expose('DSPACE_TEST_SUBMIT_COLLECTION_NAME'));
280+
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.expose('DSPACE_TEST_SUBMIT_COLLECTION_NAME')).concat('"]')).click();
280281

281282
// And the new URL should include /workspaceitems, as we've started a new submission
282283
cy.url().should('include', '/workspaceitems');
283284
});
284285

285286
it('should let you import an publication from external source', () => {
286-
cy.visit('/mydspace');
287-
288-
// This page is restricted, so we will be shown the login form. Fill it out & submit.
289-
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
290-
291287
// Open the New Import dropdown
292288
cy.get('button[data-test="import-dropdown"]').click();
293289

@@ -316,19 +312,14 @@ describe('My DSpace page', () => {
316312
cy.get('ds-collection-dropdown').should('be.visible');
317313

318314
// Type the name of the collection and click
319-
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.env('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME'));
320-
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.env('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME')).concat('"]')).click();
315+
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.expose('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME'));
316+
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.expose('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME')).concat('"]')).click();
321317

322318
// And the new URL should include /workspaceitems, as we've started a new submission
323319
cy.url().should('include', '/workspaceitems');
324320
});
325321

326322
it('should let you import a person from external source', () => {
327-
cy.visit('/mydspace');
328-
329-
// This page is restricted, so we will be shown the login form. Fill it out & submit.
330-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
331-
332323
// Open the New Import dropdown
333324
cy.get('button[data-test="import-dropdown"]').click();
334325

@@ -357,8 +348,8 @@ describe('My DSpace page', () => {
357348
cy.get('ds-collection-dropdown').should('be.visible');
358349

359350
// Type the name of the collection and click
360-
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.env('DSPACE_TEST_PEOPLE_COLLECTION_NAME'));
361-
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.env('DSPACE_TEST_PEOPLE_COLLECTION_NAME')).concat('"]')).click();
351+
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.expose('DSPACE_TEST_PEOPLE_COLLECTION_NAME'));
352+
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.expose('DSPACE_TEST_PEOPLE_COLLECTION_NAME')).concat('"]')).click();
362353

363354
// And the new URL should include /workspaceitems, as we've started a new submission
364355
cy.url().should('include', '/workspaceitems');
@@ -528,14 +519,16 @@ describe('My DSpace page', () => {
528519
const currentYear = new Date().getFullYear();
529520

530521
cy.visit('/mydspace');
531-
cy.loginViaForm(Cypress.env('DSPACE_TEST_SUBMIT_USER'), Cypress.env('DSPACE_TEST_SUBMIT_USER_PASSWORD'));
522+
cy.env(['DSPACE_TEST_SUBMIT_USER', 'DSPACE_TEST_SUBMIT_USER_PASSWORD']).then(({ DSPACE_TEST_SUBMIT_USER, DSPACE_TEST_SUBMIT_USER_PASSWORD }) => {
523+
cy.loginViaForm(DSPACE_TEST_SUBMIT_USER, DSPACE_TEST_SUBMIT_USER_PASSWORD);
524+
});
532525
cy.get('ds-my-dspace-page').should('be.visible');
533526

534527
cy.wait(500);
535528
cy.get('ds-uploader .well').selectFile(`cypress/fixtures/${fileName}`, { action: 'drag-drop' });
536529
cy.get('ds-collection-dropdown').should('be.visible');
537-
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.env('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME'));
538-
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.env('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME')).concat('"]')).click();
530+
cy.get('ds-collection-dropdown input[type="search"]').type(Cypress.expose('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME'));
531+
cy.get('ds-collection-dropdown li[title="'.concat(Cypress.expose('DSPACE_TEST_SUBMIT_WORKFLOW_COLLECTION_NAME')).concat('"]')).click();
539532
cy.url().should('include', '/workspaceitems');
540533

541534
cy.get('#dc_title').type('Workflow test item');
@@ -554,7 +547,9 @@ describe('My DSpace page', () => {
554547

555548
const takeLastSubmittedItem = () => {
556549
cy.visit('/mydspace');
557-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
550+
cy.env(['DSPACE_TEST_ADMIN_USER', 'DSPACE_TEST_ADMIN_PASSWORD']).then(({ DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD }) => {
551+
cy.loginViaForm(DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD);
552+
});
558553
cy.get('[data-test="objects"]').should('be.visible');
559554

560555
cy.intercept({
@@ -620,7 +615,9 @@ describe('My DSpace page', () => {
620615
it('should let you return to pool the workflow item', () => {
621616
//Log in
622617
cy.visit('/mydspace');
623-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
618+
cy.env(['DSPACE_TEST_ADMIN_USER', 'DSPACE_TEST_ADMIN_PASSWORD']).then(({ DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD }) => {
619+
cy.loginViaForm(DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD);
620+
});
624621
cy.get('[data-test="objects"]').should('be.visible');
625622

626623
//Go to workflow items
@@ -697,7 +694,9 @@ describe('My DSpace page', () => {
697694
it('should let you reject an workflow item', () => {
698695
//Log in
699696
cy.visit('/mydspace');
700-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
697+
cy.env(['DSPACE_TEST_ADMIN_USER', 'DSPACE_TEST_ADMIN_PASSWORD']).then(({ DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD }) => {
698+
cy.loginViaForm(DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD);
699+
});
701700
cy.get('[data-test="objects"]').should('be.visible');
702701

703702
//Go to workflow items
@@ -775,7 +774,9 @@ describe('My DSpace page', () => {
775774
describe('Testing supervised items', () => {
776775
before(()=> {
777776
cy.visit('/admin/workflow');
778-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
777+
cy.env(['DSPACE_TEST_ADMIN_USER', 'DSPACE_TEST_ADMIN_PASSWORD']).then(({ DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD }) => {
778+
cy.loginViaForm(DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD);
779+
});
779780
//We are going to use an submission test item to generate a supervised item
780781
cy.get('input[data-test="search-box"]').type('workflow item');
781782
cy.get('button[data-test="search-button"]').type('workflow item');
@@ -845,7 +846,9 @@ describe('My DSpace page', () => {
845846
it('should let you edit metadata of supervised item', () => {
846847
//Visit myDSpace page
847848
cy.visit('/mydspace');
848-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
849+
cy.env(['DSPACE_TEST_ADMIN_USER', 'DSPACE_TEST_ADMIN_PASSWORD']).then(({ DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD }) => {
850+
cy.loginViaForm(DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD);
851+
});
849852
cy.get('[data-test="objects"]').should('be.visible');
850853

851854
//Select the supervisedItemSearch value on selector
@@ -895,7 +898,9 @@ describe('My DSpace page', () => {
895898
it('should let you delete a supervised item', () => {
896899
//Visit myDSpace page
897900
cy.visit('/mydspace');
898-
cy.loginViaForm(Cypress.env('DSPACE_TEST_ADMIN_USER'), Cypress.env('DSPACE_TEST_ADMIN_PASSWORD'));
901+
cy.env(['DSPACE_TEST_ADMIN_USER', 'DSPACE_TEST_ADMIN_PASSWORD']).then(({ DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD }) => {
902+
cy.loginViaForm(DSPACE_TEST_ADMIN_USER, DSPACE_TEST_ADMIN_PASSWORD);
903+
});
899904
cy.get('[data-test="objects"]').should('be.visible');
900905

901906
//Select the supervisedItemSearch value on selector

0 commit comments

Comments
 (0)