74 lines
2.7 KiB
TypeScript
74 lines
2.7 KiB
TypeScript
// Marks this file as an ES module (rather than a global script) so its
|
|
// top-level consts don't collide, under the TS type-checker, with the same
|
|
// names declared in other spec files — see e.g. stage.cy.ts, which gets
|
|
// this for free via a real import.
|
|
export {}
|
|
|
|
const hostUrl = Cypress.env('hosturl')
|
|
const appLocation = Cypress.env('appLocation')
|
|
const longerCommandTimeout = Cypress.env('longerCommandTimeout')
|
|
|
|
context('submitted-details tests: ', function () {
|
|
this.beforeAll(() => {
|
|
cy.loginAndUpdateValidKey(true)
|
|
})
|
|
|
|
it('1 | clicking an open submit loads its diffs with a single postdata request', () => {
|
|
// Count every STP request the app makes during the test.
|
|
// The STP URL is `stp/execute/?_program=...` - glob segments don't match
|
|
// past `execute/` with a single `*`, so keep the glob within the path.
|
|
cy.intercept('POST', '**/SASjsApi/stp/**').as('stpExecute')
|
|
|
|
cy.visit(`${hostUrl}${appLocation}/#/review/submitted`)
|
|
cy.get('.app-loading', { timeout: longerCommandTimeout }).should(
|
|
'not.exist'
|
|
)
|
|
|
|
// the SUBMIT queue list must be rendered with at least one row
|
|
cy.get('app-submitter clr-datagrid clr-dg-row', {
|
|
timeout: longerCommandTimeout
|
|
})
|
|
.should('exist')
|
|
.and('have.length.greaterThan', 0)
|
|
|
|
// route-based flow: clicking a row navigates to /review/submitted/:tableId
|
|
// and triggers exactly one SHOW_DIFFS (auditors/postdata) request
|
|
cy.get('app-submitter clr-datagrid clr-dg-row')
|
|
.first()
|
|
.click()
|
|
.then(() => {
|
|
cy.url().should('include', '/review/submitted/')
|
|
})
|
|
|
|
// wait for the diff table to render (the response was applied)
|
|
cy.get('app-approve-details .card', { timeout: longerCommandTimeout })
|
|
.should('exist')
|
|
.should('be.visible')
|
|
|
|
// give any (incorrect) duplicate request time to surface
|
|
cy.wait(3000)
|
|
|
|
cy.get('@stpExecute.all').then((allRequests: any) => {
|
|
// the adapter posts multipart form data, so match on the _program
|
|
// query param rather than the request body
|
|
const postdataRequests = allRequests.filter((req: any) =>
|
|
JSON.stringify(req.request.query || {}).includes('auditors/postdata')
|
|
)
|
|
expect(
|
|
postdataRequests.length,
|
|
'exactly one auditors/postdata SHOW_DIFFS request'
|
|
).to.equal(1)
|
|
|
|
// the submit queue was already fetched to render the list - opening a
|
|
// row must not fetch it again
|
|
const getsubmitsRequests = allRequests.filter((req: any) =>
|
|
JSON.stringify(req.request.query || {}).includes('editors/getsubmits')
|
|
)
|
|
expect(
|
|
getsubmitsRequests.length,
|
|
'no editors/getsubmits request after opening a submit'
|
|
).to.equal(1)
|
|
})
|
|
})
|
|
})
|