2022-02-17 20:46:45 +03:00
|
|
|
import handler from 'serve-handler';
|
|
|
|
import http from 'http';
|
|
|
|
import path from 'path';
|
|
|
|
|
|
|
|
const port = 3000;
|
|
|
|
const uri = `http://localhost:${port}/`
|
|
|
|
const publicPath = path.join(__dirname, '../../build/');
|
|
|
|
|
|
|
|
console.log(publicPath);
|
|
|
|
|
|
|
|
const server = http.createServer((request, response) => {
|
|
|
|
return handler(request, response, {
|
|
|
|
public: publicPath
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
const startServer = async () => {
|
|
|
|
return new Promise((resolve: any) => {
|
2022-02-17 22:39:08 +03:00
|
|
|
server.listen(port, resolve);
|
2022-02-17 20:46:45 +03:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const stopServer = async () => {
|
|
|
|
return new Promise((resolve: any) => {
|
|
|
|
server.close(resolve);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-02-15 23:15:09 +03:00
|
|
|
describe('smoke test', () => {
|
2022-02-17 20:46:45 +03:00
|
|
|
beforeAll(startServer);
|
|
|
|
|
|
|
|
afterAll(stopServer);
|
|
|
|
|
2022-02-15 23:15:09 +03:00
|
|
|
it('should work', async () => {
|
|
|
|
console.log('going to the page in browser...');
|
2022-02-17 20:46:45 +03:00
|
|
|
await page.goto(uri);
|
2022-02-15 23:15:09 +03:00
|
|
|
|
|
|
|
console.log('waiting for fluence to connect...');
|
|
|
|
await page.waitForTimeout(1000);
|
|
|
|
|
|
|
|
console.log('clicking button...');
|
|
|
|
await page.click('#btn');
|
|
|
|
|
|
|
|
console.log('waiting for relay time to appear...');
|
|
|
|
const elem = await page.waitForSelector('#relayTime');
|
|
|
|
|
|
|
|
console.log('getting the content of relay time div...');
|
|
|
|
const content = await elem?.evaluate((x) => x.textContent);
|
|
|
|
|
|
|
|
expect(content?.length).toBeGreaterThan(10);
|
|
|
|
}, 10000);
|
|
|
|
});
|