Shared:Mocks: add example
This commit is contained in:
parent
a0f108c4f1
commit
6183b59be3
@ -1,6 +0,0 @@
|
||||
import settings from "./settings";
|
||||
import capabilities from "./capabilities";
|
||||
|
||||
const handlers = [settings, capabilities];
|
||||
|
||||
export default handlers;
|
@ -1,49 +0,0 @@
|
||||
import { http, HttpResponse } from "msw";
|
||||
|
||||
export const settingsSuccessNoAuth = {
|
||||
response: {
|
||||
trustedDomainsType: 0,
|
||||
culture: "en-GB",
|
||||
utcOffset: "00:00:00",
|
||||
utcHoursOffset: 0,
|
||||
greetingSettings: "Web Office",
|
||||
ownerId: "00000000-0000-0000-0000-000000000000",
|
||||
enabledJoin: false,
|
||||
enableAdmMess: false,
|
||||
thirdpartyEnable: false,
|
||||
docSpace: true,
|
||||
standalone: true,
|
||||
baseDomain: "localhost",
|
||||
passwordHash: {
|
||||
size: 256,
|
||||
iterations: 100000,
|
||||
salt: "4d9abe238e2f7b14a30a4565d62214a795a15abb798ed61118a69820d6a6146c",
|
||||
},
|
||||
version: ".",
|
||||
recaptchaType: 0,
|
||||
recaptchaPublicKey: "",
|
||||
debugInfo: false,
|
||||
tenantStatus: 0,
|
||||
tenantAlias: "localhost",
|
||||
forumLink: "https://forum.onlyoffice.com",
|
||||
legalTerms:
|
||||
"https://help.onlyoffice.co/products/files/doceditor.aspx?fileid=5048502&doc=SXhWMEVzSEYxNlVVaXJJeUVtS0kyYk14YWdXTEFUQmRWL250NllHNUFGbz0_IjUwNDg1MDIi0",
|
||||
cookieSettingsEnabled: false,
|
||||
limitedAccessSpace: false,
|
||||
userNameRegex: "^[\\p{L}\\p{M}' \\-]+$",
|
||||
maxImageUploadSize: 0,
|
||||
},
|
||||
count: 1,
|
||||
links: [
|
||||
{
|
||||
href: "http://192.168.0.16/api/2.0/settings?withPassword=false",
|
||||
action: "GET",
|
||||
},
|
||||
],
|
||||
status: 0,
|
||||
statusCode: 200,
|
||||
};
|
||||
|
||||
export default http.get("/api/2.0/settings", async () => {
|
||||
return HttpResponse.json(settingsSuccessNoAuth);
|
||||
});
|
@ -1,16 +1,14 @@
|
||||
import { http } from "msw";
|
||||
import { test as base, expect } from "@playwright/test";
|
||||
import type { MockServiceWorker } from "playwright-msw";
|
||||
import { createWorkerFixture } from "playwright-msw";
|
||||
import getMockSettingsResponse, {
|
||||
settingsSuccessNoAuth,
|
||||
settingsError,
|
||||
settingsForbidden,
|
||||
settingsNotFound,
|
||||
} from "./settings";
|
||||
|
||||
import handlers from "./handlers";
|
||||
|
||||
const test = base.extend<{
|
||||
worker: MockServiceWorker;
|
||||
http: typeof http;
|
||||
}>({
|
||||
worker: createWorkerFixture(handlers),
|
||||
http,
|
||||
});
|
||||
|
||||
export { expect, test };
|
||||
export {
|
||||
getMockSettingsResponse,
|
||||
settingsSuccessNoAuth,
|
||||
settingsError,
|
||||
settingsForbidden,
|
||||
settingsNotFound,
|
||||
};
|
||||
|
60
packages/shared/__mocks__/e2e/settings.ts
Normal file
60
packages/shared/__mocks__/e2e/settings.ts
Normal file
@ -0,0 +1,60 @@
|
||||
export const settingsSuccessNoAuth = new Response(
|
||||
JSON.stringify({
|
||||
response: {
|
||||
trustedDomainsType: 0,
|
||||
culture: "en-GB",
|
||||
utcOffset: "00:00:00",
|
||||
utcHoursOffset: 0,
|
||||
greetingSettings: "Web Office",
|
||||
ownerId: "00000000-0000-0000-0000-000000000000",
|
||||
enabledJoin: false,
|
||||
enableAdmMess: false,
|
||||
thirdpartyEnable: false,
|
||||
docSpace: true,
|
||||
standalone: true,
|
||||
baseDomain: "localhost",
|
||||
passwordHash: {
|
||||
size: 256,
|
||||
iterations: 100000,
|
||||
salt: "4d9abe238e2f7b14a30a4565d62214a795a15abb798ed61118a69820d6a6146c",
|
||||
},
|
||||
version: ".",
|
||||
recaptchaType: 0,
|
||||
recaptchaPublicKey: "",
|
||||
debugInfo: false,
|
||||
tenantStatus: 0,
|
||||
tenantAlias: "localhost",
|
||||
forumLink: "https://forum.onlyoffice.com",
|
||||
legalTerms:
|
||||
"https://help.onlyoffice.co/products/files/doceditor.aspx?fileid=5048502&doc=SXhWMEVzSEYxNlVVaXJJeUVtS0kyYk14YWdXTEFUQmRWL250NllHNUFGbz0_IjUwNDg1MDIi0",
|
||||
cookieSettingsEnabled: false,
|
||||
limitedAccessSpace: false,
|
||||
userNameRegex: "^[\\p{L}\\p{M}' \\-]+$",
|
||||
maxImageUploadSize: 0,
|
||||
},
|
||||
count: 1,
|
||||
links: [
|
||||
{
|
||||
href: "http://192.168.0.16/api/2.0/settings?withPassword=false",
|
||||
action: "GET",
|
||||
},
|
||||
],
|
||||
status: 0,
|
||||
statusCode: 200,
|
||||
}),
|
||||
{ status: 200 },
|
||||
);
|
||||
|
||||
export const settingsForbidden = new Response(null, { status: 403 });
|
||||
|
||||
export const settingsNotFound = new Response(null, { status: 404 });
|
||||
|
||||
export const settingsError = new Response(null, { status: 500 });
|
||||
|
||||
const getMockSettingsResponse = (withPassword: boolean): Response => {
|
||||
if (!withPassword) return settingsSuccessNoAuth;
|
||||
|
||||
return settingsSuccessNoAuth;
|
||||
};
|
||||
|
||||
export default getMockSettingsResponse;
|
Loading…
Reference in New Issue
Block a user