Skip to content

Commit

Permalink
chore: fix chai import
Browse files Browse the repository at this point in the history
  • Loading branch information
tripodsan committed Jan 10, 2024
1 parent 0548877 commit 42829cf
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions test/post-deploy.test.js → test/post-deploy.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
* governing permissions and limitations under the License.
*/
/* eslint-env mocha */
const { expect } = require('chai');
const chai = require('chai');
const chaiHttp = require('chai-http');
import { expect } from 'chai';
import * as chai from 'chai'
import chaiHttp from 'chai-http'
const {request} = chai.use(chaiHttp)

chai.use(chaiHttp);
const domain = !process.env.CI ? 'rum.hlx3.page' : 'helix-rum-collector-ci.edgecompute.app';

console.log(`Using ${domain}`);

describe('Helix RUM Collector Post-Deploy Tests', () => {
it('Missing body returns 400', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.post('/');
expect(response).to.have.status(400);
});

it('RUM collection with masked timestamp (t) returns 201', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.post('/')
.send({
t: 1234,
Expand All @@ -43,7 +43,7 @@ describe('Helix RUM Collector Post-Deploy Tests', () => {
});

it('RUM collection returns 201', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.post('/')
.send({
cwv: {
Expand All @@ -58,7 +58,7 @@ describe('Helix RUM Collector Post-Deploy Tests', () => {
});

it('RUM collection with empty string id returns 201', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.post('/')
.send({
cwv: {
Expand All @@ -73,37 +73,37 @@ describe('Helix RUM Collector Post-Deploy Tests', () => {
});

it('RUM collection via GET returns 201', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.get('/.rum/1?data=%7B%22checkpoint%22%3A%22noscript%22%2C%22weight%22%3A1%7D');
expect(response).to.have.status(201);
});

it('robots.txt denies everything', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.get('/robots.txt');
expect(response).to.have.status(200);
// eslint-disable-next-line no-unused-expressions
expect(response).to.be.text;
});

it('web vitals module is being served', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.get('/.rum/[email protected]/dist/web-vitals.base.js');
expect(response).to.have.status(200);
// eslint-disable-next-line no-unused-expressions
expect(response).to.have.header('content-type', /^application\/javascript/);
});

it('web vitals module is being served without redirect', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.get('/.rum/web-vitals/dist/web-vitals.base.js');
expect(response).to.have.status(200);
// eslint-disable-next-line no-unused-expressions
expect(response).to.have.header('content-type', /^application\/javascript/);
});

it('rum js module is being served without redirect', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.get('/.rum/@adobe/helix-rum-js@^1/src/index.js');
expect(response).to.have.status(200);
// eslint-disable-next-line no-unused-expressions
Expand All @@ -113,7 +113,7 @@ describe('Helix RUM Collector Post-Deploy Tests', () => {
}).timeout(5000);

it.skip('rum js module is being served with default replacements', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.get('/.rum/@adobe/[email protected]/src/index.js')
.buffer(true);
expect(response).to.have.status(200);
Expand All @@ -123,7 +123,7 @@ describe('Helix RUM Collector Post-Deploy Tests', () => {
}).timeout(5000);

it('Missing id returns 400', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.post('/')
.send({
cwv: {
Expand All @@ -137,7 +137,7 @@ describe('Helix RUM Collector Post-Deploy Tests', () => {
});

it('Non-numeric weight returns 400', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.post('/')
.send({
cwv: {
Expand All @@ -152,7 +152,7 @@ describe('Helix RUM Collector Post-Deploy Tests', () => {
});

it('Non-object root returns 400', async () => {
const response = await chai.request(`https://${domain}`)
const response = await request(`https://${domain}`)
.post('/')
.send([]);
expect(response).to.have.status(400);
Expand Down

0 comments on commit 42829cf

Please sign in to comment.