-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
api-testdata.spec.ts
52 lines (43 loc) · 1.23 KB
/
api-testdata.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// check this file using TypeScript if available
// @ts-check
import { User } from "../../../src/models";
const apiTestData = `${Cypress.env("apiUrl")}/testData`;
type TestDataCtx = {
authenticatedUser?: User;
};
describe("Test Data API", function () {
let ctx: TestDataCtx = {};
before(() => {
// Hacky workaround to have the e2e tests pass when cy.visit('http://localhost:3000') is called
cy.request("GET", "/");
});
beforeEach(function () {
cy.task("db:seed");
cy.database("filter", "users").then((users: User[]) => {
ctx.authenticatedUser = users[0];
return cy.loginByApi(ctx.authenticatedUser.username);
});
});
context("GET /testData/:entity", function () {
Cypress._.each(
[
"users",
"contacts",
"bankaccounts",
"notifications",
"transactions",
"likes",
"comments",
"banktransfers",
],
(entity) => {
it(`gets remote mock data for ${entity}`, function () {
cy.request("GET", `${apiTestData}/${entity}`).then((response) => {
expect(response.status).to.eq(200);
expect(response.body.results.length).to.be.greaterThan(1);
});
});
}
);
});
});