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

Create partcipation page in generate-lighthouserc #92

Merged
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
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);
});
Loading