Skip to content

Commit

Permalink
Update DKTL & Cypress test users (#3779)
Browse files Browse the repository at this point in the history
  • Loading branch information
janette committed May 10, 2022
1 parent 58ec835 commit 7168e58
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 33 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 >>
Expand Down Expand Up @@ -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 >>
Expand Down
7 changes: 4 additions & 3 deletions cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
3 changes: 2 additions & 1 deletion cypress/integration/07_admin_dataset_json_form.spec.js
Original file line number Diff line number Diff line change
@@ -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.', () => {
Expand Down
5 changes: 4 additions & 1 deletion cypress/integration/08_admin_views.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.', () => {
Expand Down Expand Up @@ -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')
})

Expand Down
3 changes: 2 additions & 1 deletion cypress/integration/09_admin_links.spec.js
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down
17 changes: 6 additions & 11 deletions cypress/integration/10_workflow_transitions.spec.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
29 changes: 16 additions & 13 deletions cypress/integration/11_admin_dataset_file_upload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 } )
Expand Down Expand Up @@ -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')

Expand All @@ -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)
Expand All @@ -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 } )
Expand Down Expand Up @@ -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
Expand All @@ -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}`)
Expand Down
2 changes: 2 additions & 0 deletions docs_assets/pages/4.0_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,5 @@
@subpage dkansamplecontentcreate

@subpage dkansamplecontentremove

@subpage dkantestusers
17 changes: 17 additions & 0 deletions docs_assets/pages/dkan_testusers.md
Original file line number Diff line number Diff line change
@@ -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`
2 changes: 1 addition & 1 deletion modules/common/tests/src/Functional/Api1TestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7168e58

Please sign in to comment.