saleor-dashboard/testUtils/api.ts
Dawid Tarasiuk 4880093f63
Use Auth SDK (#1474)
* Use Auth SDK

* Update auth provider hook

* Update sdk module mapping

* Update setting password

* Fix no user details on first login

* Update auth tests

* Cleanups

* Update SDK

Update SDK

Update SDK

Update test recordings

Update SDK

* Implement SDK External Auth

Update new password view

Hnalde external logout

Update SDK

Fix logout external redirect

* Fix login page style

* Update SDK

* Auth Provider cleanups

Update and refactor auth

Auth types cleanups and refactor

* Update channel context provider

* Fix login error handling

* Logout immidiatelly non-staff user

* Update test snapshots

* Trigger CI

* Update to SDK v0.4, remove duplicated UserContext hook

* Handle server errors during login

* Fix wrong login page form submition handling

* Update login error messages

Co-authored-by: Jakub Majorek <majorek.jakub@gmail.com>
2021-12-17 12:10:54 +01:00

50 lines
1.2 KiB
TypeScript

import NodeHttpAdapter from "@pollyjs/adapter-node-http";
import { Polly } from "@pollyjs/core";
import FSPersister from "@pollyjs/persister-fs";
import { createFetch } from "@saleor/sdk";
import { InMemoryCache } from "apollo-cache-inmemory";
import ApolloClient from "apollo-client";
import { BatchHttpLink } from "apollo-link-batch-http";
import path from "path";
import { setupPolly } from "setup-polly-jest";
Polly.register(NodeHttpAdapter);
Polly.register(FSPersister);
function setupApi() {
setupPolly({
adapters: ["node-http"],
matchRequestsBy: {
headers: false,
url: {
hash: false,
hostname: false,
password: false,
pathname: false,
port: false,
protocol: false,
query: false,
username: false
}
},
persister: "fs",
persisterOptions: {
fs: {
recordingsDir: path.resolve(__dirname, "../recordings")
}
}
});
const cache = new InMemoryCache();
const link = new BatchHttpLink({
fetch: createFetch(),
uri: process.env.API_URI || "http://localhost:8000/graphql/"
});
const apolloClient = new ApolloClient({
cache,
link
});
return apolloClient;
}
export default setupApi;