Skip to content
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
32 changes: 23 additions & 9 deletions tests/UI/Slack_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@
expect(await page.screenshotSelector(selector)).to.matchImage(screenshotName);
}

async function openReportTypeSelect() {
await page.evaluate(() => {
const reportTypeField = $('#addEditReport select[name="report_type"]').closest('.matomo-form-field');
reportTypeField.find('input.select-dropdown')[0].click();
});
}

async function selectSlackReportType() {
await page.evaluate(() => {
const reportTypeField = $('#addEditReport select[name="report_type"]').closest('.matomo-form-field');
reportTypeField.find('ul li:last').click();
});
}

it('should load the schedule report as empty', async function () {
const selector = '.page';
await captureScreen('empty_report', async () => {
Expand All @@ -43,14 +57,14 @@
it('should show send report via Slack as an option', async function () {
const selector = '.page';
await captureScreen('send_via_slack_new', async () => {
await page.evaluate(() => $('#addEditReport .matomo-form-field:eq(6) input')[0].click());
await openReportTypeSelect();
}, selector);
});

it('should show slack channel ID input as disabled as Oauth token not configured', async function () {
const selector = '.page';
await captureScreen('slack_report_disabled', async () => {
await page.evaluate(() => $('#addEditReport .matomo-form-field:eq(6) ul li:last').click());
await selectSlackReportType();
}, selector);
});

Expand All @@ -70,8 +84,8 @@
await captureScreen('slack_report_enabled', async () => {
await page.evaluate(() => $('#add-report').click());
await page.waitForNetworkIdle();
await page.evaluate(() => $('#addEditReport .matomo-form-field:eq(6) input')[0].click());
await page.evaluate(() => $('#addEditReport .matomo-form-field:eq(6) ul li:last').click());
await openReportTypeSelect();
await selectSlackReportType();
await page.evaluate(() => $('#addEditReport .matomo-form-field.slack:eq(0) input')[0].click());
await page.evaluate(() => $('#addEditReport .matomo-form-field.slack:eq(0) li:eq(1)').click());
}, selector);
Expand All @@ -82,7 +96,7 @@
testEnvironment.configOverride.Slack = {slackOauthToken: 'token'};
testEnvironment.save();
await captureScreen('slack_report_error', async () => {
await page.type('textarea#report_description', 'Slack Report');
await page.type('input#report_description', 'Slack Report');
await page.evaluate(() => $('#slackVisitsSummary_get').click());
await page.click('.matomo-save-button input.btn');
await page.waitForNetworkIdle();
Expand All @@ -104,9 +118,9 @@
await captureScreen('slack_report_pdf_view', async () => {
await page.evaluate(() => $('#add-report').click());
await page.waitForNetworkIdle();
await page.type('textarea#report_description', 'Slack Report PDF');
await page.evaluate(() => $('#addEditReport .matomo-form-field:eq(6) input')[0].click());
await page.evaluate(() => $('#addEditReport .matomo-form-field:eq(6) ul li:last').click());
await page.type('input#report_description', 'Slack Report PDF');
await openReportTypeSelect();
await selectSlackReportType();
}, selector);
});

Expand All @@ -122,4 +136,4 @@

// TODO: Add tests for display options once core changes are merged

});
});
Binary file modified tests/UI/expected-ui-screenshots/Slack_empty_report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_new_scheduled_reports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_send_via_slack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_send_via_slack_new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_slack_report_disabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_slack_report_enabled.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_slack_report_error.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_slack_report_pdf_save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_slack_report_pdf_view.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified tests/UI/expected-ui-screenshots/Slack_slack_report_save_report.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading