Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve deploy in iframe tests #1622

Merged
merged 4 commits into from
Feb 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions test/integration/deploy.spec.ts

This file was deleted.

66 changes: 66 additions & 0 deletions test/integration/deploy/dom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"root": "o46cdgh",
"nodes": {
"o46cdgh": {
"id": "o46cdgh",
"name": "Application",
"type": "app",
"parentId": null,
"attributes": {},
"parentProp": null,
"parentIndex": null
},
"o57cdlq": {
"id": "o57cdlq",
"name": "page1",
"type": "page",
"parentId": "o46cdgh",
"attributes": {
"title": {
"type": "const",
"value": "Page 1"
}
},
"parentProp": "pages",
"parentIndex": "a0"
},
"s123uru": {
"name": "pageRow",
"props": {},
"attributes": {
"component": {
"type": "const",
"value": "PageRow"
}
},
"layout": {},
"id": "s123uru",
"type": "element",
"parentId": "o57cdlq",
"parentProp": "children",
"parentIndex": "a0"
},
"n903u7c": {
"name": "text",
"props": {
"value": {
"type": "const",
"value": "Hello World!"
}
},
"attributes": {
"component": {
"type": "const",
"value": "Text"
}
},
"layout": {},
"id": "n903u7c",
"type": "element",
"parentId": "s123uru",
"parentProp": "children",
"parentIndex": "a0"
}
},
"version": 5
}
50 changes: 50 additions & 0 deletions test/integration/deploy/index.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import * as path from 'path';
import { test, expect } from '../../playwright/test';
import { readJsonFile } from '../../utils/fs';
import generateId from '../../utils/generateId';

test.use({
ignoreConsoleErrors: [
/Failed to load resource: the server responded with a status of 404 \(Not Found\)/,
],
});

test('can render in an iframe', async ({ api, page, baseURL }) => {
const dom = await readJsonFile(path.resolve(__dirname, './dom.json'));

const app = await api.mutation.createApp(`App ${generateId()}`, {
from: { kind: 'dom', dom },
});

await api.mutation.deploy(app.id, { description: '' });

await page.evaluate(
([src]) => {
const iframe = document.createElement('iframe');
iframe.src = src;
iframe.id = 'my-frame';
document.body.append(iframe);
},
[`${baseURL}/deploy/${app.id}/pages/o57cdlq`],
);

const frame = await page.frameLocator('#my-frame');

await expect(frame.getByText('Hello World!')).toBeVisible();
});

test('can render non-existing app in an iframe', async ({ page, baseURL }) => {
await page.evaluate(
([src]) => {
const iframe = document.createElement('iframe');
iframe.src = src;
iframe.id = 'my-frame';
document.body.append(iframe);
},
[`${baseURL}/deploy/non-existing/pages/o57cdlq`],
);

const frame = await page.frameLocator('#my-frame');

await expect(frame.getByText('This page could not be found.')).toBeVisible();
});