Changeset View
Changeset View
Standalone View
Standalone View
cypress/integration/origin-save.spec.js
Show First 20 Lines • Show All 394 Lines • ▼ Show 20 Lines | cy.wait('@saveRequest').then(() => { | ||||
.should('have.value', goodVisitType); | .should('have.value', goodVisitType); | ||||
cy.get('#swh-input-origin-url') | cy.get('#swh-input-origin-url') | ||||
.should('have.value', $(cells[2]).text().slice(0, -1)); | .should('have.value', $(cells[2]).text().slice(0, -1)); | ||||
}); | }); | ||||
}); | }); | ||||
}); | }); | ||||
it('should create save request for authenticated user', function() { | it('should create save request for authenticated user', function() { | ||||
cy.adminLogin(); | cy.userLogin(); | ||||
cy.visit(url); | cy.visit(url); | ||||
const originUrl = 'https://git.example.org/account/repo'; | const originUrl = 'https://git.example.org/account/repo'; | ||||
stubSaveRequest({requestUrl: this.Urls.api_1_save_origin('git', originUrl), | stubSaveRequest({requestUrl: this.Urls.api_1_save_origin('git', originUrl), | ||||
saveRequestStatus: 'accepted', | saveRequestStatus: 'accepted', | ||||
originUrl: origin.url, | originUrl: origin.url, | ||||
saveTaskStatus: 'not yet scheduled'}); | saveTaskStatus: 'not yet scheduled'}); | ||||
makeOriginSaveRequest('git', originUrl); | makeOriginSaveRequest('git', originUrl); | ||||
cy.wait('@saveRequest').then(() => { | cy.wait('@saveRequest').then(() => { | ||||
checkAlertVisible('success', saveCodeMsg['success']); | checkAlertVisible('success', saveCodeMsg['success']); | ||||
}); | }); | ||||
}); | }); | ||||
it('should not show user requests filter checkbox for anonymous users', function() { | |||||
cy.get('#swh-origin-save-requests-list-tab').click(); | |||||
cy.get('#swh-save-requests-user-filter').should('not.exist'); | |||||
}); | |||||
it('should show user requests filter checkbox for authenticated users', function() { | |||||
cy.userLogin(); | |||||
cy.visit(url); | |||||
cy.get('#swh-origin-save-requests-list-tab').click(); | |||||
cy.get('#swh-save-requests-user-filter').should('exist'); | |||||
}); | |||||
it('should show only user requests when filter is activated', function() { | |||||
cy.intercept('POST', '/api/1/origin/save/**') | |||||
.as('saveRequest'); | |||||
const originAnonymousUser = 'https://some.git.server/project/'; | |||||
const originAuthUser = 'https://other.git.server/project/'; | |||||
// anonymous user creates a save request | |||||
makeOriginSaveRequest('git', originAnonymousUser); | |||||
cy.wait('@saveRequest'); | |||||
// authenticated user creates another save request | |||||
cy.userLogin(); | |||||
cy.visit(url); | |||||
makeOriginSaveRequest('git', originAuthUser); | |||||
cy.wait('@saveRequest'); | |||||
// user requests filter checkbox should be in the DOM | |||||
cy.get('#swh-origin-save-requests-list-tab').click(); | |||||
cy.get('#swh-save-requests-user-filter').should('exist'); | |||||
// check unfiltered user requests | |||||
cy.get('tbody tr').then(rows => { | |||||
expect(rows.length).to.eq(2); | |||||
expect($(rows[0].cells[2]).text()).to.contain(originAuthUser); | |||||
expect($(rows[1].cells[2]).text()).to.contain(originAnonymousUser); | |||||
}); | |||||
// activate filter and check filtered user requests | |||||
cy.get('#swh-save-requests-user-filter') | |||||
.click({force: true}); | |||||
cy.get('tbody tr').then(rows => { | |||||
expect(rows.length).to.eq(1); | |||||
expect($(rows[0].cells[2]).text()).to.contain(originAuthUser); | |||||
}); | |||||
// deactivate filter and check unfiltered user requests | |||||
cy.get('#swh-save-requests-user-filter') | |||||
.click({force: true}); | |||||
cy.get('tbody tr').then(rows => { | |||||
vlorentz: could you add some comments inside this test to explain the steps? | |||||
Done Inline Actionsack, @ardumont also found some were missing. anlambert: ack, @ardumont also found some were missing. | |||||
expect(rows.length).to.eq(2); | |||||
}); | |||||
}); | |||||
}); | }); |
could you add some comments inside this test to explain the steps?