forked from cypress-io/cypress-realworld-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api-testdata.spec.ts
47 lines (39 loc) · 1.08 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
// 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 = {};
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);
});
});
}
);
});
});