Skip to content

Commit

Permalink
Merge pull request #105 from cplkake/feature/lighthouse-ci
Browse files Browse the repository at this point in the history
Re-merge create partcipation page in generate-lighthouserc
  • Loading branch information
cplkake authored Dec 6, 2024
2 parents 1620a7d + 8e7d4b4 commit 2c91923
Showing 1 changed file with 77 additions and 11 deletions.
88 changes: 77 additions & 11 deletions generate-lighthouserc.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,80 @@
const fs = require('fs');

const config = {
ci: {
collect: {
url: ['http://localhost']
},
upload: {
target: 'temporary-public-storage'
const { writeFileSync } = require('fs');
const axios = require('axios');
const { CookieJar } = require('tough-cookie');
const { wrapper } = require('axios-cookiejar-support');

const jar = new CookieJar();
const client = wrapper(axios.create({ jar }));

async function createConversation() {
try {
// create a user
await client.post('http://localhost/api/v3/auth/new', {
hname: 'Test Participant 01',
email: '[email protected]',
password: 'Te$tP@ssw0rd*',
password2: 'Te$tP@ssw0rd*',
gatekeeperTosPrivacy: 'true',
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});

// create a conversation
const response = await client.post('http://localhost/api/v3/conversations', {
is_active: 'true',
is_draft: 'true',
topic: 'Conversation Topic',
description: 'Conversation Description',
}, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
});

const conversationId = await response.data.conversation_id
const dummyComments = [
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.',
'Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.',
]

// seed comments in the conversation
for (let i = 0; i < dummyComments.length; i++) {
await client.post('http://localhost/api/v3/comments', {
conversation_id: conversationId,
is_seed: true,
pid: 'mypid',
txt: dummyComments[i],
})
}

// logout
await client.post('http://localhost/api/v3/auth/deregister')

return conversationId;

} catch (error) {
console.error('Error:', error.message);
}
};
}

fs.writeFileSync('lighthouserc.js', 'module.exports = ' + JSON.stringify(config, null, 2) + ';');
createConversation()
.then(conversationId => {
const config = {
ci: {
collect: {
url: ['http://localhost', `http://localhost/${conversationId}`]
},
upload: {
target: 'temporary-public-storage'
}
}
};

writeFileSync('lighthouserc.js', 'module.exports = ' + JSON.stringify(config, null, 2) + ';');
})
.catch(error => {
console.error('Error creating a conversation:', error);
});

0 comments on commit 2c91923

Please sign in to comment.