-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to export select subscriber ids.
- Add `id=[]` query param to `/api/subscribers/export` API. - Add UI export prompt. - Add Cypress tests. Closes #739
- Loading branch information
Showing
4 changed files
with
77 additions
and
19 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
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 |
---|---|---|
|
@@ -28,6 +28,27 @@ describe('Subscribers', () => { | |
}); | ||
}); | ||
|
||
it('Exports subscribers', () => { | ||
const cases = [ | ||
{ | ||
listIDs: [], ids: [], query: '', length: 3, | ||
}, | ||
{ | ||
listIDs: [], ids: [], query: "name ILIKE '%anon%'", length: 2, | ||
}, | ||
{ | ||
listIDs: [], ids: [], query: "name like 'nope'", length: 1, | ||
}, | ||
]; | ||
|
||
// listIDs[] and ids[] are unused for now as Cypress doesn't support encoding of arrays in `qs`. | ||
cases.forEach((c) => { | ||
cy.request({ url: `${apiUrl}/api/subscribers/export`, qs: { query: c.query, list_id: c.listIDs, id: c.ids } }).then((resp) => { | ||
cy.expect(resp.body.trim().split('\n')).to.have.lengthOf(c.length); | ||
}); | ||
}); | ||
}); | ||
|
||
|
||
it('Advanced searches subscribers', () => { | ||
cy.get('[data-cy=btn-advanced-search]').click(); | ||
|
@@ -253,24 +274,36 @@ describe('Domain blocklist', () => { | |
|
||
// Add non-banned domain. | ||
cy.request({ | ||
method: 'POST', url: `${apiUrl}/api/subscribers`, failOnStatusCode: true, | ||
body: { email: '[email protected]', 'name': 'test', 'lists': [1], 'status': 'enabled' } | ||
method: 'POST', | ||
url: `${apiUrl}/api/subscribers`, | ||
failOnStatusCode: true, | ||
body: { | ||
email: '[email protected]', name: 'test', lists: [1], status: 'enabled', | ||
}, | ||
}).should((response) => { | ||
expect(response.status).to.equal(200); | ||
}); | ||
|
||
// Add banned domain. | ||
cy.request({ | ||
method: 'POST', url: `${apiUrl}/api/subscribers`, failOnStatusCode: false, | ||
body: { email: '[email protected]', 'name': 'test', 'lists': [1], 'status': 'enabled' } | ||
method: 'POST', | ||
url: `${apiUrl}/api/subscribers`, | ||
failOnStatusCode: false, | ||
body: { | ||
email: '[email protected]', name: 'test', lists: [1], status: 'enabled', | ||
}, | ||
}).should((response) => { | ||
expect(response.status).to.equal(400); | ||
}); | ||
|
||
// Modify an existinb subscriber to a banned domain. | ||
cy.request({ | ||
method: 'PUT', url: `${apiUrl}/api/subscribers/1`, failOnStatusCode: false, | ||
body: { email: '[email protected]', 'name': 'test', 'lists': [1], 'status': 'enabled' } | ||
method: 'PUT', | ||
url: `${apiUrl}/api/subscribers/1`, | ||
failOnStatusCode: false, | ||
body: { | ||
email: '[email protected]', name: 'test', lists: [1], status: 'enabled', | ||
}, | ||
}).should((response) => { | ||
expect(response.status).to.equal(400); | ||
}); | ||
|
@@ -305,16 +338,24 @@ describe('Domain blocklist', () => { | |
|
||
// Add banned domain. | ||
cy.request({ | ||
method: 'POST', url: `${apiUrl}/api/subscribers`, failOnStatusCode: true, | ||
body: { email: '[email protected]', 'name': 'test', 'lists': [1], 'status': 'enabled' } | ||
method: 'POST', | ||
url: `${apiUrl}/api/subscribers`, | ||
failOnStatusCode: true, | ||
body: { | ||
email: '[email protected]', name: 'test', lists: [1], status: 'enabled', | ||
}, | ||
}).should((response) => { | ||
expect(response.status).to.equal(200); | ||
}); | ||
|
||
// Modify an existinb subscriber to a banned domain. | ||
cy.request({ | ||
method: 'PUT', url: `${apiUrl}/api/subscribers/1`, failOnStatusCode: true, | ||
body: { email: '[email protected]', 'name': 'test', 'lists': [1], 'status': 'enabled' } | ||
method: 'PUT', | ||
url: `${apiUrl}/api/subscribers/1`, | ||
failOnStatusCode: true, | ||
body: { | ||
email: '[email protected]', name: 'test', lists: [1], status: 'enabled', | ||
}, | ||
}).should((response) => { | ||
expect(response.status).to.equal(200); | ||
}); | ||
|
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