1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00
pigallery2/test/cypress/e2e/share.cy.ts

112 lines
3.4 KiB
TypeScript
Raw Normal View History

2023-12-01 20:02:40 +02:00
describe('Share', () => {
2023-12-02 10:13:05 +02:00
beforeEach(() => {
2023-12-01 20:02:40 +02:00
cy.viewport(1200, 600);
cy.visit('/');
cy.get('.card-body');
cy.get('.col-sm-12').contains('Login');
/* ==== Generated with Cypress Studio ==== */
cy.get('#username').type('admin');
cy.get('#password').clear();
cy.get('#password').type('admin');
cy.intercept({
method: 'Get',
2023-12-02 10:13:05 +02:00
url: '/pgapi/gallery/content/',
2023-12-01 20:02:40 +02:00
}).as('getContent');
cy.get('.col-sm-12 > .btn').click();
2023-12-02 10:13:05 +02:00
});
it('Open password protected sharing', () => {
2023-12-01 20:02:40 +02:00
cy.wait('@getContent');
cy.get('button#shareButton').click();
cy.get('input#share-password').type('secret', {force: true});
cy.get('button#getShareButton').click();
cy.get('input#shareLink').should('contain.value', 'http');
cy.get('input#shareLink')
.invoke('val')
.then((link: string) => {
cy.get('button.btn-close').click();
cy.get('button#button-frame-menu').click();
cy.get('#dropdown-frame-menu ng-icon[name="ionLogOutOutline"]').click({scrollBehavior: false});
2023-12-02 10:13:05 +02:00
cy.intercept({
method: 'Get',
url: '/pgapi/gallery/content/*',
}).as('getSharedContent');
2023-12-01 20:02:40 +02:00
cy.visit(link);
cy.get('input#password').type('secret');
cy.get('button#button-share-login').click();
cy.get('.mb-0 > :nth-child(1) > .nav-link').contains('Gallery');
2023-12-02 10:13:05 +02:00
cy.wait('@getSharedContent').then((interception) => {
2023-12-01 20:02:40 +02:00
assert.isNotNull(interception.response.body, '1st API call has data');
2023-12-02 10:13:05 +02:00
assert.isNull(interception.response.body?.error, '1st API call has data');
2023-12-01 20:02:40 +02:00
});
});
});
it('Open password protected sharing with logged in user', () => {
cy.wait('@getContent');
cy.get('button#shareButton').click();
cy.get('input#share-password').type('secret', {force: true});
cy.get('button#getShareButton').click();
cy.get('input#shareLink').should('contain.value', 'http');
cy.get('input#shareLink')
.invoke('val')
.then((link: string) => {
2023-12-02 10:13:05 +02:00
cy.intercept({
method: 'Get',
url: '/pgapi/gallery/content/*',
}).as('getSharedContent');
2023-12-01 20:02:40 +02:00
cy.visit(link);
cy.get('.mb-0 > :nth-child(1) > .nav-link').contains('Gallery');
2023-12-02 10:13:05 +02:00
cy.wait('@getSharedContent').then((interception) => {
2023-12-01 20:02:40 +02:00
assert.isNotNull(interception.response.body, '1st API call has data');
2023-12-02 10:13:05 +02:00
assert.isNull(interception.response.body?.error, '1st API call has data');
2023-12-01 20:02:40 +02:00
});
});
});
it('Open no password sharing', () => {
cy.wait('@getContent');
cy.get('button#shareButton').click();
cy.get('button#getShareButton').click();
cy.get('input#shareLink').should('contain.value', 'http');
cy.get('input#shareLink')
.invoke('val')
.then((link: string) => {
cy.get('button.btn-close').click();
cy.get('button#button-frame-menu').click();
cy.get('#dropdown-frame-menu ng-icon[name="ionLogOutOutline"]').click({scrollBehavior: false});
2023-12-02 10:13:05 +02:00
cy.intercept({
method: 'Get',
url: '/pgapi/gallery/content/*',
}).as('getSharedContent');
2023-12-01 20:02:40 +02:00
cy.visit(link);
cy.get('.mb-0 > :nth-child(1) > .nav-link').contains('Gallery');
2023-12-02 10:13:05 +02:00
cy.wait('@getSharedContent').then((interception) => {
2023-12-01 20:02:40 +02:00
assert.isNotNull(interception.response.body, '1st API call has data');
2023-12-02 10:13:05 +02:00
assert.isNull(interception.response.body?.error, '1st API call has data');
2023-12-01 20:02:40 +02:00
});
});
});
});