diff --git a/.circleci/config.yml b/.circleci/config.yml index f1e15e495b..2f56ba2ff6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -88,7 +88,7 @@ jobs: type: boolean environment: TEST_RESULTS: /tmp/test-results - DKTL_VERSION: "4.2.9" + DKTL_VERSION: "4.2.10" steps: - prepare_build: upgrade: << parameters.upgrade >> @@ -123,7 +123,7 @@ jobs: parallelism: 4 environment: TEST_RESULTS: /tmp/test-results - DKTL_VERSION: "4.2.9" + DKTL_VERSION: "4.2.10" steps: - prepare_build: upgrade: << parameters.upgrade >> diff --git a/cypress.json b/cypress.json index 1bb0914fef..227386c49c 100644 --- a/cypress.json +++ b/cypress.json @@ -2,9 +2,10 @@ "apiUri": "api/1", "env": { "TEST_USER_CREDENTIALS": { - "user": "testuser", - "pass": "2jqzOAnXS9mmcLasy" + "user": "testadmin", + "pass": "testadmin" }, "UUID_REGEX": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" - } + }, + "baseUrl": "http://dkan.localtest.me" } diff --git a/cypress/integration/07_admin_dataset_json_form.spec.js b/cypress/integration/07_admin_dataset_json_form.spec.js index 4786e17c9b..742b1aba62 100644 --- a/cypress/integration/07_admin_dataset_json_form.spec.js +++ b/cypress/integration/07_admin_dataset_json_form.spec.js @@ -1,7 +1,8 @@ context('Admin dataset json form', () => { let baseurl = Cypress.config().baseUrl; beforeEach(() => { - cy.drupalLogin('testeditor', 'testeditor') + const user_credentials = Cypress.env('TEST_USER_CREDENTIALS') + cy.drupalLogin(user_credentials.user, user_credentials.pass) }) it('The dataset form has the correct required fields.', () => { diff --git a/cypress/integration/08_admin_views.spec.js b/cypress/integration/08_admin_views.spec.js index 2d6560ea2e..f422e5e478 100644 --- a/cypress/integration/08_admin_views.spec.js +++ b/cypress/integration/08_admin_views.spec.js @@ -2,8 +2,10 @@ import * as dkan from '../support/helpers/dkan' context('Admin content and dataset views', () => { let baseurl = Cypress.config().baseUrl; + beforeEach(() => { - cy.drupalLogin('testeditor', 'testeditor') + const user_credentials = Cypress.env('TEST_USER_CREDENTIALS') + cy.drupalLogin(user_credentials.user, user_credentials.pass) }) it('The admin content screen has an exposed data type filter that contains the values I expect.', () => { @@ -88,6 +90,7 @@ context('Admin content and dataset views', () => { cy.get('h1').should('contain.text', 'Edit Data') cy.get('#edit-delete').click({ force:true }) cy.get('#edit-submit').click({ force:true }) + cy.visit(baseurl + "/admin/dkan/datasets") cy.get('.messages--status').should('contain','has been deleted') }) diff --git a/cypress/integration/09_admin_links.spec.js b/cypress/integration/09_admin_links.spec.js index 290ade8cd5..bf223ca8c7 100755 --- a/cypress/integration/09_admin_links.spec.js +++ b/cypress/integration/09_admin_links.spec.js @@ -1,7 +1,8 @@ context('Administration pages', () => { let baseurl = Cypress.config().baseUrl; beforeEach(() => { - cy.drupalLogin('testeditor', 'testeditor') + const user_credentials = Cypress.env('TEST_USER_CREDENTIALS') + cy.drupalLogin(user_credentials.user, user_credentials.pass) }) it('I should see a link for the dataset properties configuration', () => { diff --git a/cypress/integration/10_workflow_transitions.spec.js b/cypress/integration/10_workflow_transitions.spec.js index aefcffb0a7..660c725d35 100644 --- a/cypress/integration/10_workflow_transitions.spec.js +++ b/cypress/integration/10_workflow_transitions.spec.js @@ -1,7 +1,10 @@ import * as dkan from '../support/helpers/dkan' -context('Draft datasets', () => { - beforeEach(() => cy.drupalLogin('testeditor', 'testeditor')) +context('DKAN Workflow', () => { + beforeEach(() => { + const user_credentials = Cypress.env('TEST_USER_CREDENTIALS') + cy.drupalLogin(user_credentials.user, user_credentials.pass) + }) it('Draft datasets are hidden from the catalog until published.', () => { // Create draft dataset @@ -33,7 +36,7 @@ context('Draft datasets', () => { cy.get('#edit-submit').click() cy.get('.button').contains('Yes').click({ force:true }) cy.get('.messages--status').should('contain', 'has been updated') - + // Ensure dataset is visible via public API with correct title cy.request('/api/1/metastore/schemas/dataset/items/' + datasetId).should((response) => { expect(response.status).to.eq(200) @@ -47,10 +50,6 @@ context('Draft datasets', () => { }) }) }) -}) - -context('Archived datasets', () => { - beforeEach(() => cy.drupalLogin('testeditor', 'testeditor')) it('Existing datasets which are archived cannot be visited, and are hidden from the catalog.', () => { // Create published dataset @@ -95,10 +94,6 @@ context('Archived datasets', () => { }) }) }) -}) - -context('Hidden datasets', () => { - beforeEach(() => cy.drupalLogin('testeditor', 'testeditor')) it('Newly created hidden datasets are visible when visited directly, but hidden from the catalog.', () => { // create hidden dataset diff --git a/cypress/integration/11_admin_dataset_file_upload.spec.js b/cypress/integration/11_admin_dataset_file_upload.spec.js index 036465b044..0f4c28b73a 100644 --- a/cypress/integration/11_admin_dataset_file_upload.spec.js +++ b/cypress/integration/11_admin_dataset_file_upload.spec.js @@ -5,8 +5,12 @@ context('Admin dataset file upload', () => { const fileUrl = 'https://dkan-default-content-files.s3.amazonaws.com/phpunit/district_centerpoints_small.csv' const title = dkan.generateRandomString() - before(() => { - cy.drupalLogin('testeditor', 'testeditor') + beforeEach(() => { + const user_credentials = Cypress.env('TEST_USER_CREDENTIALS') + cy.drupalLogin(user_credentials.user, user_credentials.pass) + }) + + it('create the dataset', () => { cy.visit('/node/add/data') cy.wait(2000) cy.get('#edit-field-json-metadata-0-value-title').type(title, { force:true } ) @@ -45,15 +49,12 @@ context('Admin dataset file upload', () => { .should('contain','has been created') }) - beforeEach(() => { - cy.drupalLogin('testeditor', 'testeditor') - }) - it('can fill up the form with distribution and submit', () => { // run cron to import new dataset cy.visit('/admin/config/system/cron') cy.get('#edit-run') .click({force: true}) + cy.contains('h1', 'Cron'); cy.get('.messages--status', {timeout: 120000}) .should('be.visible') @@ -66,6 +67,7 @@ context('Admin dataset file upload', () => { cy.get('#edit-title').type(title) cy.get('#edit-submit-dkan-dataset-content').click() cy.get('.views-field-nothing > a').click() + cy.contains('h1', 'Edit Data'); cy.get('#edit-field-json-metadata-0-value-distribution-distribution-0-distribution-downloadurl a') .invoke('attr', 'href') .should('eq', fileUrl) @@ -80,10 +82,13 @@ context('Admin dataset file upload', () => { // tests const uploadedFileName = dkan.generateCSVFileName() - before(() => { - const selectorDist = '#edit-field-json-metadata-0-value-distribution-distribution-0-distribution-downloadurl-upload' + beforeEach(() => { + const user_credentials = Cypress.env('TEST_USER_CREDENTIALS') + cy.drupalLogin(user_credentials.user, user_credentials.pass) + }) - cy.drupalLogin('testeditor', 'testeditor') + it('create the dataset', () => { + const selectorDist = '#edit-field-json-metadata-0-value-distribution-distribution-0-distribution-downloadurl-upload' cy.visit('/node/add/data') cy.wait(2000) cy.get('#edit-field-json-metadata-0-value-title').type(title, { force:true } ) @@ -125,9 +130,6 @@ context('Admin dataset file upload', () => { .should('contain','has been created') }) - beforeEach(() => { - cy.drupalLogin('testeditor', 'testeditor') - }) it('can create and import dataset with uploaded file', () => { // run cron to import new dataset @@ -146,7 +148,8 @@ context('Admin dataset file upload', () => { cy.visit('/admin/dkan/datasets') cy.get('#edit-title').type(title) cy.get('#edit-submit-dkan-dataset-content').click() - cy.get('.views-field-nothing > a').click() + cy.get('tbody > :nth-child(1) > .views-field-nothing > a').click({force: true}) + cy.get('h1').should('contain', 'Edit Data') cy.get('#edit-field-json-metadata-0-value-distribution-distribution-0-distribution-downloadurl a') .invoke('attr', 'href') .should('contain', `uploaded_resources/${uploadedFileName}`) diff --git a/docs_assets/pages/4.0_commands.md b/docs_assets/pages/4.0_commands.md index ce8d00c42c..2de016a647 100644 --- a/docs_assets/pages/4.0_commands.md +++ b/docs_assets/pages/4.0_commands.md @@ -39,3 +39,5 @@ @subpage dkansamplecontentcreate @subpage dkansamplecontentremove + +@subpage dkantestusers diff --git a/docs_assets/pages/dkan_testusers.md b/docs_assets/pages/dkan_testusers.md new file mode 100644 index 0000000000..23948dcdfa --- /dev/null +++ b/docs_assets/pages/dkan_testusers.md @@ -0,0 +1,17 @@ +@page dkantestusers dkan:qa-users-create + +DKAN ships with two test users: testapiuser and testadmin. + +You can define your own custom test users by adding a testuser.json file to the root of your project. These commands will generate and remove the users specified, if no file is found, the DKAN default user accounts will be used. + +#### Add users + +`dkan:qa-users-create` + +@alias `qauc` + +#### Remove users + +`dkan:qa-users-delete` + +@alias `qaud` diff --git a/modules/common/tests/src/Functional/Api1TestBase.php b/modules/common/tests/src/Functional/Api1TestBase.php index 4c5e2cdae0..1817bc997f 100644 --- a/modules/common/tests/src/Functional/Api1TestBase.php +++ b/modules/common/tests/src/Functional/Api1TestBase.php @@ -30,7 +30,7 @@ public function setUp(): void { $this->setDefaultModerationState($state = 'published'); $this->baseUrl = getenv('SIMPLETEST_BASE_URL'); $this->http = new Client(['base_uri' => $this->baseUrl]); - $this->auth = ['testuser', '2jqzOAnXS9mmcLasy']; + $this->auth = ['testapiuser', 'testapiuser']; $this->endpoint = $this->getEndpoint(); // Load the API spec for use by tests.