c7cf07cd40d768ab5886b4f4f0331b5149916ae7
[evergreen-equinox.git] / Open-ILS / src / eg2 / nightwatch / src / staff / cat / vandelay.spec.ts
1 import {EnhancedPageObject, NightwatchBrowser} from 'nightwatch';
2 import {fixtureFile, randomString} from '../../utils';
3
4 const exampleXpath = '//*[@tag="010"]/*[@code="a"][1]';
5
6 function navigateToMarcBatchImport(vandelay: EnhancedPageObject): void {
7     browser.page.navbar().click('@catMenu')
8                          .click('@catMenuMarcBatchImportExport')
9                          .verify.textContains('div.lead.alert', 'MARC Batch Import/Export');
10 }
11
12 module.exports = {
13     before: (browser: NightwatchBrowser) => {
14         // TODO: Once https://bugs.launchpad.net/evergreen/+bug/1989260 is resolved,
15         // login as a cataloging administrator, rather than the admin / demo123 credentials
16         browser.page.login().loginToWebClient(browser, 'admin', 'demo123');
17     },
18
19     after: (browser: NightwatchBrowser) => {
20         browser.end();
21     },
22
23     'Can create a new record display attribute': (browser: NightwatchBrowser) => {
24         const vandelay = browser.page.vandelay();
25         navigateToMarcBatchImport(vandelay);
26         vandelay.click('@recordDisplayAttributes')
27                 .click('#authority')
28                 .click('@newVqradButton')
29                 .setValue('@codeInput', 'lccn')
30                 .setValue('@descriptionInput', 'LC control number')
31                 .setValue('@xpathInput', exampleXpath)
32                 .click('@saveButton')
33                 .assert.textContains('div.eg-grid-body', exampleXpath);
34     },
35
36     'Record display attribute displays in queue screen': (browser: NightwatchBrowser) => {
37         const vandelay = browser.page.vandelay();
38         navigateToMarcBatchImport(vandelay);
39             vandelay.click('@recordTypeCombobox') // open the combobox
40                     .click('@authorityRecordType') // select the option we want
41                     .setValue('@queueName', randomString())
42                     .setValue('#upload-file', fixtureFile('authority-record.mrc'))
43                     .click('@uploadButton')
44                     .waitForElementVisible('@goToQueueButton', 10_000)
45                     .click('@goToQueueButton')
46                     .assert.textContains('div.eg-grid-header-row', 'LC control number')
47                     .assert.textContains('div.eg-grid-body', 'sh 85038796');
48     }
49 };