Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add curatorial inspection workflow cypress test #446

Open
wants to merge 43 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
1cf8c79
chore: removes sample spec
andrea-kyurchiev Aug 12, 2024
c26d739
fix: retuns false on uncaught exepction
andrea-kyurchiev Aug 12, 2024
bf265a7
wip: feat: adds flag for enforcement workflow test
andrea-kyurchiev Aug 12, 2024
b8a6e3a
wip: feat: selects first option in dropdown
andrea-kyurchiev Aug 12, 2024
d33cbca
refactor: changes double quotes to single quotes
andrea-kyurchiev Aug 14, 2024
057485f
feat: adds a cypress command that allows editing rich textboxes
andrea-kyurchiev Aug 14, 2024
22eca49
test: adds to the ffe workflow
andrea-kyurchiev Aug 14, 2024
13299f9
chore: adds cypress gitignore
andrea-kyurchiev Aug 14, 2024
b17da75
test: check all populated fields and go through workflow with just id
andrea-kyurchiev Aug 15, 2024
2856162
test: adds test with only case reference
andrea-kyurchiev Aug 15, 2024
e87df40
test: adds tests for each field
andrea-kyurchiev Aug 15, 2024
4ebb362
test: fix flagged date selection
andrea-kyurchiev Aug 15, 2024
2f17e4b
test: removes unnecessary next redirect
andrea-kyurchiev Aug 15, 2024
00620aa
chore: removes sample spec
andrea-kyurchiev Aug 12, 2024
4a1a7f5
fix: retuns false on uncaught exepction
andrea-kyurchiev Aug 12, 2024
c168802
wip: feat: adds flag for enforcement workflow test
andrea-kyurchiev Aug 12, 2024
839def5
wip: feat: selects first option in dropdown
andrea-kyurchiev Aug 12, 2024
e4387c3
refactor: changes double quotes to single quotes
andrea-kyurchiev Aug 14, 2024
0b13911
feat: adds a cypress command that allows editing rich textboxes
andrea-kyurchiev Aug 14, 2024
7040fb6
test: adds to the ffe workflow
andrea-kyurchiev Aug 14, 2024
dfad8f7
chore: adds cypress gitignore
andrea-kyurchiev Aug 14, 2024
89be197
test: check all populated fields and go through workflow with just id
andrea-kyurchiev Aug 15, 2024
a057b03
test: adds test with only case reference
andrea-kyurchiev Aug 15, 2024
88afd82
test: adds tests for each field
andrea-kyurchiev Aug 15, 2024
9e969a1
test: fix flagged date selection
andrea-kyurchiev Aug 15, 2024
77f8667
test: removes unnecessary next redirect
andrea-kyurchiev Aug 15, 2024
fdbfcb7
chore: removes spaces
andrea-kyurchiev Aug 15, 2024
cc24d1b
test: creates person to be used in tests
andrea-kyurchiev Aug 19, 2024
75a2021
Merge branch 'feature/cypress-tests' of https://github.com/flaxandtea…
andrea-kyurchiev Aug 19, 2024
a15b657
test: delete test since its been renamed
andrea-kyurchiev Aug 19, 2024
5d594f2
test: adds create heritage asset test
andrea-kyurchiev Aug 19, 2024
0e9a9a5
test: adds commented search for the created person
andrea-kyurchiev Aug 19, 2024
39f0788
ops: uncomment the test step
andrea-kyurchiev Aug 19, 2024
191a39c
test: add temporary solution that selects Test Person
andrea-kyurchiev Aug 19, 2024
ad045a8
test: adds create organisation test
andrea-kyurchiev Aug 19, 2024
96e625d
test: search properly for test person
andrea-kyurchiev Aug 19, 2024
2852e16
test: lower waits
andrea-kyurchiev Aug 19, 2024
0d217dd
ops: comment out test step since it doesnt work
andrea-kyurchiev Aug 20, 2024
c23ba1d
test: select the created heritage asset
andrea-kyurchiev Aug 20, 2024
d1f5860
test: tests with multiple people as well as organisation
andrea-kyurchiev Aug 20, 2024
16c7042
test: adding cypress tests for curatorial inspection workflow.. added…
adamkelly03 Aug 29, 2024
9405ff3
test: adding indvidual tab tests
adamkelly03 Sep 4, 2024
af62b72
test: updating cypress config for baseUrl
adamkelly03 Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
projectId: 'arches',
video: true,
e2e: {
baseUrl:"http://localhost:8000",
setupNodeEvents(on, config) {},
specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}',
},
Expand Down
2 changes: 2 additions & 0 deletions cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/videos
/screenshots
49 changes: 49 additions & 0 deletions cypress/e2e/01_create_a_person.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
describe('Creating a person named Test Person and a person named John Doe if they dont exist', function () {
beforeEach(() => {
cy.login();
});

it('Create a person', function () {
cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=125&language=*&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Person%20-%20Name%22%2C%22id%22%3A%22termTest%20PersonPerson%20-%20Name%22%2C%22text%22%3A%22Test%20Person%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22Test%20Person%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D');
cy.wait(5000).then(() => {
cy.get('#search-results-list').then(($el) => {
if ($el.find('.search-listing').length > 0) {
// A caveat to this is that it will only look at the first page (which shouldn't be a problem with a fresh instance) since the search was failing locally to find Test Person (probably a permissions issue as all objects were created as Provisional)
if (!$el.text().includes('Test Person')) {
cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588')
cy.contains('Names').click();
cy.get('[aria-label="Full Name"]').should('be.visible').type('Test Person');
cy.get('button').contains('Add').click();
}
} else {
cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588')
cy.contains('Names').click();
cy.get('[aria-label="Full Name"]').should('be.visible').type('Test Person');
cy.get('button').contains('Add').click();
}
})
});
});

it('Create a second person', function () {
cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=329&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Person%20-%20Name%22%2C%22id%22%3A%22termJohn%20DoePerson%20-%20Name%22%2C%22text%22%3A%22John%20Doe%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22John%20Doe%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D&language=*');
cy.wait(5000).then(() => {
cy.get('#search-results-list').then(($el) => {
if ($el.find('.search-listing').length > 0) {
// A caveat to this is that it will only look at the first page (which shouldn't be a problem with a fresh instance) since the search was failing locally to find John Doe (probably a permissions issue as all objects were created as Provisional)
if (!$el.text().includes('John Doe')) {
cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588')
cy.contains('Names').click();
cy.get('[aria-label="Full Name"]').should('be.visible').type('John Doe');
cy.get('button').contains('Add').click();
}
} else {
cy.visit('http://localhost:8000/add-resource/22477f01-1a44-11e9-b0a9-000d3ab1e588')
cy.contains('Names').click();
cy.get('[aria-label="Full Name"]').should('be.visible').type('John Doe');
cy.get('button').contains('Add').click();
}
})
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
describe('Going through the Flag For Enforcement Workflow', function () {

beforeEach(() => {
cy.login();
cy.visit('http://localhost:8000/plugins/init-workflow');
});

it('Go through the workflow and populate all fields', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.wait(900);
cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref');
cy.type_ckeditor('editor2', 'test reason for enforcement');
cy.contains('Flagged by').siblings('.row').click();
cy.get('.select2-search__field').type('Test Person');
cy.wait(500);
cy.get('.select2-results__options li').first().click();
cy.contains('Flagged by').siblings('.row').click();
cy.get('.select2-search__field').type('John Doe');
cy.wait(600);
cy.get('.select2-results__options li').first().click();
cy.get('[aria-label="Flagged Date"]').scrollIntoView().should('be.visible').click();
cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click();
cy.contains('Select resources').siblings('.row').click();
cy.get('.select2-results__options li').contains('TestAsset').click();
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref');
cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement');
// Only checks if the date we selected is present as the year and month could change
cy.contains('Flagged Date Value:').siblings().should('contain', '17');
cy.contains('Actor:').siblings().should('have.text', 'John Doe, Test Person');
cy.contains('Associated Resources:').siblings().should('have.text', 'None TestAsset');
cy.wait(900);
cy.contains('Save and Complete Workflow').click();
});

it('Workflow with only Enforcement ID', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();


// Enforcement Details Tab
cy.wait(900);
cy.contains('Next Step').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().invoke('text').as('enforcementId')
cy.contains('Save and Complete Workflow').click();

console.log(this.enforcementId);
cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true');
});

it('Workflow with only Case Reference', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.wait(900);
cy.get('[aria-label="Case Reference"]').should('be.visible').type('Case Ref');
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
cy.contains('Case Reference Number:').siblings().should('have.text', 'Case Ref');
cy.contains('Save and Complete Workflow').click();
});

it('Workflow with only Reason For Enforcement', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.wait(900);
cy.type_ckeditor('editor2', 'test reason for enforcement');
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
cy.contains('Description:').siblings().should('have.text', 'test reason for enforcement');
cy.contains('Save and Complete Workflow').click();
});

it('Workflow with only Flagged By', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.wait(900);
cy.contains('Flagged by').siblings('.row').click();
cy.get('.select2-search__field').type('Test Person');
cy.wait(500);
cy.get('.select2-results__options li').first().click();
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
cy.contains('Actor:').siblings().should('have.text', 'Test Person');
cy.contains('Save and Complete Workflow').click();
});

it('Workflow with only Flagged By using Organisation', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.wait(900);
cy.contains('Flagged by').siblings('.row').click();
cy.get('.select2-search__field').type('Test Organisation');
cy.wait(500);
cy.get('.select2-results__options li').first().click();
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
cy.contains('Actor:').siblings().should('have.text', 'Test Organisation');
cy.contains('Save and Complete Workflow').click();
});

it('Workflow with only Flagged By using both an Organisation and a Person', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.wait(900);
cy.contains('Flagged by').siblings('.row').click();
cy.get('.select2-search__field').type('Test Organisation');
cy.wait(500);
cy.get('.select2-results__options li').first().click();
cy.wait(500);
cy.contains('Flagged by').siblings('.row').click();
cy.get('.select2-search__field').type('Test Person');
cy.wait(500);
cy.get('.select2-results__options li').first().click();
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
cy.contains('Actor:').siblings().should('have.text', 'Test Person, Test Organisation');
cy.contains('Save and Complete Workflow').click();
});


it('Workflow with only Flagged Date', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.wait(900);
cy.get('[aria-label="Flagged Date"]').click();
cy.get('[aria-label="Flagged Date"]').siblings('.bootstrap-datetimepicker-widget').contains('17').click();
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
// Only checks if the date we selected is present as the year and month could change
cy.contains('Flagged Date Value:').siblings().should('contain', '17');
cy.contains('Save and Complete Workflow').click();
});

it('Workflow with only Associated Resource', function () {
cy.contains('Workflows');
cy.contains('Flag for Enforcement').click();

// Initial step tab
// Makes sure the autogenerated id is not undefined
cy.wait(900);
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value');
cy.contains('Enforcement ID').siblings('.col-xs-12').children('input').should('not.have.value', '');
cy.contains('Save and Continue').click();

// Enforcement Details Tab
cy.contains('Select resources').scrollIntoView();
cy.wait(1000);
cy.contains('Select resources').siblings('.row').click();
cy.get('.select2-results__options li').contains('TestAsset').click();
// Selects the first value in the dropdown. Would be better if we have a pervious test that initates a Heritage Asset and uses that by name
cy.contains('Save and Continue').click();

// Enforcement Summary tab
cy.contains('ResourceID:').siblings().should('not.have.text');
cy.contains('ResourceID:').siblings().should('not.have.text', '');
cy.contains('Associated Resources:').siblings().should('have.text', 'None TestAsset');
cy.contains('Save and Complete Workflow').click();
});
});
20 changes: 20 additions & 0 deletions cypress/e2e/02_create_a_heritage_asset.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
describe('Creating a Heritage Asset named TestAsset if it doesnt exist', function () {
beforeEach(() => {
cy.login();
cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=336&term-filter=%5B%7B%22inverted%22%3Afalse%2C%22type%22%3A%22string%22%2C%22context%22%3A%22%22%2C%22context_label%22%3A%22%22%2C%22id%22%3A%22TestAsset%22%2C%22text%22%3A%22TestAsset%22%2C%22value%22%3A%22TestAsset%22%2C%22selected%22%3Atrue%7D%5D&language=*');
});

it('Create a heritage asset', function () {
cy.wait(5000).then(() => {
cy.get('#search-results-list').then(($el) => {
if (!$el.find('.search-listing').length > 0) {
// If no Heritage Assets exist create an empty heritage asset
cy.visit('http://localhost:8000/add-resource/076f9381-7b00-11e9-8d6b-80000b44d1d9')
cy.contains('Heritage Asset Names').click();
cy.get('[aria-label="Name"]').should('be.visible').type('TestAsset');
cy.get('button').contains('Add').click();
};
})
});
});
});
27 changes: 27 additions & 0 deletions cypress/e2e/03_create_an_organisation.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
describe('Creating a organisation named Test Organisation if one doesnt exist', function () {
beforeEach(() => {
cy.login();
cy.visit('http://localhost:8000/search?paging-filter=1&tiles=true&format=tilecsv&reportlink=false&precision=6&total=125&language=*&term-filter=%5B%7B%22context%22%3A%22%22%2C%22context_label%22%3A%22Organization%20-%20Names%22%2C%22id%22%3A%22termTest%20OrganisationOrganization%20-%20Names%22%2C%22text%22%3A%22Test%20Organisation%22%2C%22type%22%3A%22term%22%2C%22value%22%3A%22Test%20Organisation%22%2C%22inverted%22%3Afalse%2C%22selected%22%3Atrue%7D%5D');
});

it('Create an organisation', function () {
cy.wait(5000).then(() => {
cy.get('#search-results-list').then(($el) => {
if ($el.find('.search-listing').length > 0) {
// A caveat to this is that it will only look at the first page (which shouldn't be a problem with a fresh instance) since the search was failing locally to find Test Organisation (probably a permissions issue as all objects were created as Provisional)
if (!$el.text().includes('Test Organisation')) {
cy.visit('http://localhost:8000/add-resource/d4a88461-5463-11e9-90d9-000d3ab1e588')
cy.contains('Names').click();
cy.get('[aria-label="Organization Name"]').should('be.visible').type('Test Organisation');
cy.get('button').contains('Add').click();
}
} else {
cy.visit('http://localhost:8000/add-resource/d4a88461-5463-11e9-90d9-000d3ab1e588')
cy.contains('Names').click();
cy.get('[aria-label="Organization Name"]').should('be.visible').type('Test Organisation');
cy.get('button').contains('Add').click();
}
})
});
});
});
Loading
Loading