Skip to content

Commit

Permalink
Update screenshots
Browse files Browse the repository at this point in the history
  • Loading branch information
xdan committed Apr 21, 2024
1 parent 99505c1 commit ab745b3
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 47 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ screenshots-test:
-e MIN=$(uglify) \
-e FAT=$(fat) \
jodit-screenshots \
npx playwright test
npx playwright test # --update-snapshots

.PHONY: screenshots-build-image
screenshots-build-image:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 42 additions & 46 deletions test/screenshots/mock.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,48 @@ const mockData: Record<string, Record<string, Array<MockResponse>>> = {
};

export const mockRequest = async (page: Page): Promise<void> => {
await page.route('https://xdsoft.net/**', route => {
if (route.request().resourceType() === 'image') {
return route.fulfill({
status: 200,
contentType: 'image/png',
body: buffer
});
}

for (const host in mockData) {
for (const pathname in mockData[host]) {
const process = mockData[host][pathname];
for (const item of process) {
const { filter, data } = item;

if (
filter({
url: route.request().url(),
method: route.request().method().toLowerCase(),
body: route.request().postDataJSON()
})
) {
return route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(data)
});
}
}
}
}

throw new Error(
'Not found mock data: ' +
JSON.stringify({
url: route.request().url(),
method: route.request().method().toLowerCase(),
body: route.request().postDataJSON()
})
);
});

await page.route('/**/*', route => {
const url = new URL(route.request().url());
let filePath = path.join(__dirname, '../../', url.pathname);
Expand Down Expand Up @@ -176,52 +218,6 @@ export const mockRequest = async (page: Page): Promise<void> => {
body: buffer
});
});

for (const host in mockData) {
for (const pathname in mockData[host]) {
const process = mockData[host][pathname];
await page.route(`https://${host}${pathname}`, async route => {
for (const item of process) {
const { filter, data } = item;

if (
filter({
url: route.request().url(),
method: route.request().method().toLowerCase(),
body: route.request().postDataJSON()
})
) {
return await route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(data)
});
}
}

throw new Error(
'Not found mock data: ' +
JSON.stringify({
url: route.request().url(),
method: route.request().method().toLowerCase(),
body: route.request().postDataJSON()
})
);
});
}
}

await page.route('https://xdsoft.net/**', route => {
if (route.request().resourceType() === 'image') {
return route.fulfill({
status: 200,
contentType: 'image/png',
body: buffer
});
}

return route.continue();
});
};

export async function makeCeptJodit(page: Page, config = {}): Promise<void> {
Expand Down

0 comments on commit ab745b3

Please sign in to comment.