Skip to content

Commit

Permalink
test: View an existing resource e2e tests (DEV-2380) (#1845)
Browse files Browse the repository at this point in the history
Co-authored-by: Julien Schneider <[email protected]>
Co-authored-by: Raitis Veinbahs <[email protected]>
  • Loading branch information
3 people authored Nov 6, 2024
1 parent a2afd80 commit a232efc
Show file tree
Hide file tree
Showing 70 changed files with 1,921 additions and 677 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,31 +55,41 @@ jobs:
with:
node-version: 18
- run: npm install
- name: Install Cypress dependencies
run: |
cd ../dsp-das/apps/dsp-app/cypress
npm install
- name: Checkout DSP-API repo
uses: actions/checkout@v3
with:
repository: dasch-swiss/dsp-api
ref: main
path: dsp-api
- name: start API
- name: Start API
run: |
cd dsp-api
make init-db-test
docker compose -f docker-compose.yml up -d sipi ingest api
./webapi/scripts/wait-for-api.sh
- name: run e2e tests in ci
- name: Run e2e tests in CI
if: github.event_name == 'push'
run: |
cd ../dsp-das
npm run e2e-ci
- name: run e2e tests on cypress cloud on push
if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release-please') && github.event.pull_request.merged == true
- name: Run e2e tests on Cypress Cloud on push
if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.head.ref, 'release-please') && github.event.pull_request.merged == true
run: |
cd ../dsp-das
export CYPRESS_RECORD_KEY=$CYPRESS_RECORD_KEY_SECRET
npm run e2e-cloud
env:
CYPRESS_RECORD_KEY_SECRET: ${{ secrets.CYPRESS_RECORD_KEY }}
- name: Upload artifact
uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-snapshots
path: apps/dsp-app/cypress/fixtures/screenshots

jdnconvertiblecalendar-tests:
name: JDNConvertibleCalendar
Expand Down
33 changes: 33 additions & 0 deletions apps/dsp-app/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,39 @@ export default defineConfig({
apiUrl: 'http://0.0.0.0:3333',
authToken:
'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiIwLjAuMC4wOjMzMzMiLCJzdWIiOiJodHRwOi8vcmRmaC5jaC91c2Vycy9yb290IiwiYXVkIjpbIktub3JhIiwiU2lwaSIsImh0dHA6Ly9sb2NhbGhvc3Q6MzM0MCJdLCJleHAiOjE3MzE1NzAwNzcsImlhdCI6MTcyODk3ODA3NywianRpIjoiX09hYm15ZWFSSTZ0NlpzczNRQ0djUSIsInNjb3BlIjoiYWRtaW4ifQ.xZKAXIKfVk2F35CO1luzi1fZnZgyWUM65m0FZ7h67RA',
dspIngestUrl: 'http://0.0.0.0:3340',
sipiIIIfUrl: 'http://0.0.0.0:1024',
},
trashAssetsBeforeRuns: true,
screenshotsFolder: 'cypress/fixtures/screenshots',

setupNodeEvents(on, config) {
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome' && browser.isHeadless) {
// fullPage screenshot size is 1600x1400 on non-retina screens
// and 2800x2400 on retina screens
launchOptions.args.push('--window-size=1600,1400');
// force screen to be non-retina (1600x1400 size)
launchOptions.args.push('--force-device-scale-factor=1');
// force screen to be retina (2800x2400 size)
// launchOptions.args.push('--force-device-scale-factor=2')
}

if (browser.name === 'electron' && browser.isHeadless) {
// fullPage screenshot size is 1400x1200
launchOptions.preferences.width = 1400;
launchOptions.preferences.height = 1200;
}

if (browser.name === 'firefox' && browser.isHeadless) {
// menubars take up height on the screen
// so fullPage screenshot size is 1400x1126
launchOptions.args.push('--width=1400');
launchOptions.args.push('--height=1200');
}

return launchOptions;
});
},
},
});
1 change: 1 addition & 0 deletions apps/dsp-app/cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
62 changes: 62 additions & 0 deletions apps/dsp-app/cypress/e2e/logged-out-user/resource-archive.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import { faker } from '@faker-js/faker';
import { UploadedFileResponse } from '../../../../../libs/vre/shared/app-representations/src';
import { ResponseUtil } from '../../fixtures/requests';
import { ArchiveClass } from '../../models/existing-data-models';
import { Project0803Page } from '../../support/pages/existing-ontology-class-page';

describe.skip('Create archive model, add new data and view it', () => {
let projectAssertionPage: Project0803Page;
let finalLastModificationDate: string;

const archiveData: ArchiveClass = {
className: faker.lorem.word(),
label: faker.lorem.word(),
file: '',
};

const archiveFile = 'dummy.txt.zip';

beforeEach(() => {
projectAssertionPage = new Project0803Page();
cy.postAuthenticated({
url: `${Cypress.env('apiUrl')}/v2/ontologies/classes`,
body: projectAssertionPage.payloads.createClassPayload(
archiveData.className,
'http://api.knora.org/ontology/knora-api/v2#ArchiveRepresentation'
),
}).then(response => {
finalLastModificationDate = ResponseUtil.lastModificationDate(response);
cy.uploadFile({
filePath: `../uploads/${archiveFile}`,
projectShortCode: projectAssertionPage.projectShortCode,
}).then(response => {
archiveData.file = (response as UploadedFileResponse).internalFilename;
const data = projectAssertionPage.payloads.archive(archiveData);
cy.createResource(data);
cy.request(
`${Cypress.env('sipiIIIfUrl')}/${projectAssertionPage.projectShortCode}/${archiveData.file}/file`
).then(response => {
expect(response.status).to.eq(200);
});
cy.screenshot('upload-resource-archive-screenshot', {
scale: false,
overwrite: true,
capture: 'runner',
});
});
});
});

it('archive representation should be present', () => {
projectAssertionPage.visitClass(archiveData.className);
cy.get('[data-cy=accept-cookies]').click();
cy.get('[data-cy=resource-list-item] h3.res-class-value').contains(archiveData.label).click();
cy.get('[data-cy=resource-header-label]').contains(archiveData.label);
cy.get('.representation-container').should('exist');
cy.get('app-archive').should('be.visible');
cy.get('[data-cy=original-file-name]').contains(archiveFile);
cy.get('[data-cy=more-button]').click();
// cy.get('[data-cy=download-file-button]').click(); //merge #4227 bugfix
// cy.readFile(path.join(Cypress.config('downloadsFolder'), 'file.zip')).should('exist');
});
});
Loading

0 comments on commit a232efc

Please sign in to comment.