-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(examples): add e2e test to supabase and strapi-v4 examples (#4413)
* test(examples): add e2e test to supabase and strapi-v4 examples * chore(examples): remove show button * chore(examples): remove show component * test(examples): add show component and test to data-provider-strapi-v4
- Loading branch information
1 parent
5cec6de
commit 57968c0
Showing
23 changed files
with
1,273 additions
and
155 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"email": "demo@refine.dev", | ||
"password": "demodemo" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"email": "info@refine.dev", | ||
"password": "refine-supabase" | ||
} |
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 |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/// <reference types="cypress" /> | ||
/// <reference types="../../index.d.ts" /> | ||
|
||
import { getIdFromURL } from "../../../utils"; | ||
|
||
const hostname = "api.fake-rest.refine.dev"; | ||
|
||
Cypress.Commands.add("interceptGETPosts", () => { | ||
return cy | ||
.intercept( | ||
{ | ||
method: "GET", | ||
hostname: hostname, | ||
pathname: "/posts", | ||
}, | ||
{ | ||
fixture: "posts.json", | ||
}, | ||
) | ||
.as("getPosts"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptGETPost", () => { | ||
return cy | ||
.fixture("posts") | ||
.then((posts) => { | ||
return cy.intercept( | ||
{ | ||
method: "GET", | ||
hostname: hostname, | ||
pathname: "/posts/*", | ||
}, | ||
|
||
(req) => { | ||
const id = getIdFromURL(req.url); | ||
const post = posts.find((post) => post.id === id); | ||
|
||
if (!post) { | ||
req.reply(404, {}); | ||
return; | ||
} | ||
|
||
req.reply(post); | ||
}, | ||
); | ||
}) | ||
.as("getPost"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptPOSTPost", () => { | ||
return cy.fixture("posts").then((posts) => | ||
cy | ||
.intercept( | ||
{ | ||
method: "POST", | ||
hostname: hostname, | ||
pathname: "/posts", | ||
}, | ||
(req) => { | ||
const merged = Object.assign({}, req.body, { | ||
id: posts.length + 1, | ||
}); | ||
|
||
return req.reply(merged); | ||
}, | ||
) | ||
.as("postPost"), | ||
); | ||
}); | ||
|
||
Cypress.Commands.add("interceptPATCHPost", () => { | ||
return cy | ||
.fixture("posts") | ||
.then((posts) => { | ||
return cy.intercept( | ||
{ | ||
method: "PATCH", | ||
hostname: hostname, | ||
pathname: "/posts/*", | ||
}, | ||
|
||
(req) => { | ||
const id = getIdFromURL(req.url); | ||
const post = posts.find((post) => post.id === id); | ||
|
||
if (!post) { | ||
return req.reply(404, {}); | ||
} | ||
const merged = Object.assign({}, post, req.body); | ||
return req.reply(merged); | ||
}, | ||
); | ||
}) | ||
.as("patchPost"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptDELETEPost", () => { | ||
return cy | ||
.intercept( | ||
{ | ||
method: "DELETE", | ||
hostname: hostname, | ||
pathname: "/posts/*", | ||
}, | ||
{}, | ||
) | ||
.as("deletePost"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptGETCategories", () => { | ||
return cy | ||
.intercept( | ||
{ | ||
method: "GET", | ||
hostname: hostname, | ||
pathname: "/categories", | ||
}, | ||
{ fixture: "categories.json" }, | ||
) | ||
.as("getCategories"); | ||
}); |
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 |
---|---|---|
@@ -1,119 +1,4 @@ | ||
/// <reference types="cypress" /> | ||
/// <reference types="../../index.d.ts" /> | ||
|
||
import { getIdFromURL } from "../../../utils"; | ||
|
||
Cypress.Commands.add("interceptGETPosts", () => { | ||
return cy | ||
.intercept( | ||
{ | ||
method: "GET", | ||
hostname: "api.fake-rest.refine.dev", | ||
pathname: "/posts", | ||
}, | ||
{ | ||
fixture: "posts.json", | ||
}, | ||
) | ||
.as("getPosts"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptGETPost", () => { | ||
return cy | ||
.fixture("posts") | ||
.then((posts) => { | ||
return cy.intercept( | ||
{ | ||
method: "GET", | ||
hostname: "api.fake-rest.refine.dev", | ||
pathname: "/posts/*", | ||
}, | ||
|
||
(req) => { | ||
const id = getIdFromURL(req.url); | ||
const post = posts.find((post) => post.id === id); | ||
|
||
if (!post) { | ||
req.reply(404, {}); | ||
return; | ||
} | ||
|
||
req.reply(post); | ||
}, | ||
); | ||
}) | ||
.as("getPost"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptPOSTPost", () => { | ||
return cy.fixture("posts").then((posts) => | ||
cy | ||
.intercept( | ||
{ | ||
method: "POST", | ||
hostname: "api.fake-rest.refine.dev", | ||
pathname: "/posts", | ||
}, | ||
(req) => { | ||
const merged = Object.assign({}, req.body, { | ||
id: posts.length + 1, | ||
}); | ||
|
||
return req.reply(merged); | ||
}, | ||
) | ||
.as("postPost"), | ||
); | ||
}); | ||
|
||
Cypress.Commands.add("interceptPATCHPost", () => { | ||
return cy | ||
.fixture("posts") | ||
.then((posts) => { | ||
return cy.intercept( | ||
{ | ||
method: "PATCH", | ||
hostname: "api.fake-rest.refine.dev", | ||
pathname: "/posts/*", | ||
}, | ||
|
||
(req) => { | ||
const id = getIdFromURL(req.url); | ||
const post = posts.find((post) => post.id === id); | ||
|
||
if (!post) { | ||
return req.reply(404, {}); | ||
} | ||
const merged = Object.assign({}, post, req.body); | ||
return req.reply(merged); | ||
}, | ||
); | ||
}) | ||
.as("patchPost"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptDELETEPost", () => { | ||
return cy | ||
.intercept( | ||
{ | ||
method: "DELETE", | ||
hostname: "api.fake-rest.refine.dev", | ||
pathname: "/posts/*", | ||
}, | ||
{}, | ||
) | ||
.as("deletePost"); | ||
}); | ||
|
||
Cypress.Commands.add("interceptGETCategories", () => { | ||
return cy | ||
.intercept( | ||
{ | ||
method: "GET", | ||
hostname: "api.fake-rest.refine.dev", | ||
pathname: "/categories", | ||
}, | ||
{ fixture: "categories.json" }, | ||
) | ||
.as("getCategories"); | ||
}); | ||
// add commands to the Cypress chain | ||
import "./api-fake-rest"; | ||
import "./supabase"; | ||
import "./strapi-v4"; |
Oops, something went wrong.