-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from swisstopo/feature/asset-148-elastic-crea…
…te-alastic-search-index Feature 148: Create elastic search index
- Loading branch information
Showing
8 changed files
with
137 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; | ||
|
||
Then(/^The user should see the sync progress$/, () => { | ||
cy.get('.progress').should('exist').and('be.visible'); | ||
}); | ||
When(/^The user clicks start sync button$/, () => { | ||
cy.get('button:contains("Synchronisation starten")').click(); | ||
}); | ||
When(/^A user clicks administration menu button$/, () => { | ||
cy.get('span:contains("Verwaltung")').not(':contains("Benutzer Verwaltung")').click(); | ||
cy.wait(1000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { assert } from 'chai'; | ||
import { Given } from '@badeball/cypress-cucumber-preprocessor'; | ||
import { bearerAuth } from '../../support/commands/helper.commands'; | ||
|
||
const body = | ||
'{"titlePublic":"CypressTestAsset","titleOriginal":"CypressTestAsset","createDate":20240610,"receiptDate":20240610,"publicUse":{"isAvailable":false,"statusAssetUseItemCode":"tobechecked","startAvailabilityDate":null},"internalUse":{"isAvailable":true,"statusAssetUseItemCode":"tobechecked","startAvailabilityDate":null},"assetKindItemCode":"basemap","assetFormatItemCode":"pdf","isNatRel":true,"manCatLabelRefs":["other"],"typeNatRels":[],"assetLanguages":[{"languageItemCode":"DE"}],"assetContacts":[],"ids":[{"idId":null,"id":"123","description":"Beschreibung"}],"studies":[],"assetMainId":null,"siblingAssetIds":[],"newStudies":[],"newStatusWorkItemCode":"initiateAsset"}'; | ||
|
||
Given('Test asset is created', () => { | ||
cy.window() | ||
.then(win => win.localStorage.getItem('access_token')) | ||
.as('access_token'); | ||
cy.get('@access_token').then(token => | ||
cy.request({ | ||
method: 'GET', | ||
url: 'http://localhost:4200/api/search-asset?searchText=CypressTestAsset', | ||
auth: bearerAuth(token), | ||
}).then((response) => { | ||
if (response.body._tag === 'SearchAssetResultEmpty') { | ||
cy.request({ | ||
method: 'PUT', | ||
url: 'http://localhost:4200/api/asset-edit', | ||
auth: bearerAuth(token), | ||
body: body, | ||
headers: { | ||
'Content-Type': 'application/json', | ||
}, | ||
}).then(response => { | ||
assert.equal(response.status, 200, 'Response status should be 200'); | ||
}); | ||
} | ||
})); | ||
}); | ||
|
||
Given('Elastic index is created', () => { | ||
cy.window() | ||
.then(win => win.localStorage.getItem('access_token')) | ||
.as('access_token'); | ||
cy.get('@access_token').then(token => | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/assets/sync', | ||
auth: bearerAuth(token), | ||
}), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Feature: Elastic index | ||
|
||
Background: | ||
Given The user is logged in | ||
And Test asset is created | ||
|
||
Scenario: User creates elastic index | ||
When A user clicks administration menu button | ||
And The user clicks start sync button | ||
Then The user should see the sync progress |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import {Then, When} from '@badeball/cypress-cucumber-preprocessor'; | ||
import { Then, When } from '@badeball/cypress-cucumber-preprocessor'; | ||
|
||
Then(/^The user should see a test information in results$/, () => { | ||
Then(/^The user should see the asset in results$/, () => { | ||
cy.get('asset-sg-animate-number:contains("0")', {timeout: 3000}).should('not.exist'); | ||
cy.get('.asset-body').should('exist'); | ||
cy.get('.search-results div:contains("test")').should('exist'); | ||
cy.get('.search-results div:contains("CypressTestAsset")').should('exist'); | ||
}); | ||
When(/^The user clicks enter$/, () => { | ||
cy.get('.search-input').type('{enter}'); | ||
}); | ||
When(/^A user types information into the search field$/, () => { | ||
cy.get('.search-input').type('test'); | ||
When(/^A user types (.*) into the search field$/, (searchText: string) => { | ||
cy.get('.search-input').type(searchText); | ||
cy.wait(1000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */ | ||
/* eslint-disable @typescript-eslint/no-unsafe-return */ | ||
import { assetsBaseUrl } from '../config/config'; | ||
|
||
//login Eam | ||
/*Cypress.Commands.add('login', (username: string, password: string) => { | ||
cy.visit(assetsBaseUrl); | ||
cy.get('[name="loginWithIdentityProvider"] div input[aria-label="idp-metadata-Swisstopo-BDMS-REF"]').last().click(); | ||
cy.get('[type="email"]').type(username); | ||
cy.get('eiam-button[name="continueBtn"]').click(); | ||
cy.get('[type="password"]').type(password); | ||
cy.get('eiam-buttonp[name="continueBtn"]').click(); | ||
}); | ||
*/ | ||
export const bearerAuth = token => ({ bearer: token }); | ||
|
||
Cypress.Commands.add('login', (username: string, password: string) => { | ||
cy.visit(assetsBaseUrl); | ||
cy.get('input[name="username"]').type(username); | ||
cy.get('input[name="password"]').type(password); | ||
cy.get('input[name="signInSubmitButton"]').click(); | ||
}); | ||
|
||
Cypress.Commands.add('login', (username: string, password: string) => { | ||
cy.session(['login', username, password], () => { | ||
cy.visit(assetsBaseUrl); | ||
cy.intercept('http://localhost:4011/connect/token').as('token'); | ||
cy.origin('http://localhost:4011', { args: { username, password } }, ({ username, password }) => { | ||
cy.get('#Input_Username').type(username); | ||
cy.get('#Input_Password').type(password); | ||
cy.contains('button', 'Login').click({ force: true }); | ||
}); | ||
cy.wait('@token') | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
.then((interception) => interception.response.body.access_token) | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument | ||
.then((token) => window.localStorage.setItem('access_token', token)); | ||
}, | ||
{ | ||
validate() { | ||
cy.window() | ||
.then(win => win.localStorage.getItem('access_token')) | ||
.as('access_token'); | ||
cy.get('@access_token').then(token => | ||
cy.request({ | ||
method: 'GET', | ||
url: '/api/user', | ||
auth: bearerAuth(token), | ||
}), | ||
); | ||
}, | ||
cacheAcrossSpecs: true, | ||
}, | ||
); | ||
}); | ||
|
||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type | ||
//export const bearerAuth = (token) => ({bearer: token}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import './commands/login.commands'; | ||
import './commands/helper.commands'; | ||
|
||
declare global { | ||
namespace Cypress { | ||
|