From 9cb24fcdae2aadb27dba6adb85b75a12c89e23bb Mon Sep 17 00:00:00 2001 From: Michelle Shull Date: Thu, 15 Nov 2018 14:41:12 -0500 Subject: [PATCH] fixes, clean-up, better selectors --- tests/acceptance/ExportSubscribersCest.php | 30 ++++++++-------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/tests/acceptance/ExportSubscribersCest.php b/tests/acceptance/ExportSubscribersCest.php index 79c5047310..03b3878dc5 100644 --- a/tests/acceptance/ExportSubscribersCest.php +++ b/tests/acceptance/ExportSubscribersCest.php @@ -3,43 +3,33 @@ namespace MailPoet\Test\Acceptance; use MailPoet\Test\DataFactories\Segment; +use MailPoet\Test\DataFactories\Subscriber; require_once __DIR__ . '/../DataFactories/Segment.php'; -require_once __DIR__ . '/../_data/MailPoetExportList.csv'; +require_once __DIR__ . '/../DataFactories/Subscriber.php'; class ExportSubscribersCest { function __construct() { $this->search_field_element = 'input.select2-search__field'; } function exportSubscribers(\AcceptanceTester $I) { + $segment_factory = new Segment(); $segment_name = 'Hobbyists'; - $segment = new Segment(); - $segment->withName($segment_name)->create(); + $segment = $segment_factory->withName($segment_name)->create(); + $subscriber_factory = new Subscriber(); + $subscriber_factory->withSegments([$segment])->withEmail('one@fake.fake')->create(); + $subscriber_factory->withSegments([$segment])->withEmail('two@fake.fake')->create(); + $subscriber_factory->withSegments([$segment])->withEmail('three@fake.fake')->create(); $I->wantTo('Export a list of subscribers'); $I->login(); $I->amOnMailPoetPage('Subscribers'); - //import unique user list to export, so we have exact data regardless of other tests - $I->click('[data-automation-id="import_subscribers_button"]'); - $I->waitForText('Back to Subscribers', 10); - //select upload file as import method, import CSV - $I->click('[data-automation-id="upload_subscriber_csv_file"]'); - $I->attachFile(['css'=>'#file_local'], 'MailPoetExportList.csv'); - $I->click(['xpath'=>'//*[@id="method_file"]/div/table/tbody/tr[2]/th/a']); - $I->waitForText('Jokūbas', 25); - //click is to trigger dropdown to display selections, least restrictive working method - $I->click($this->search_field_element); - $I->click(['xpath'=>'//*[@id="select2-mailpoet_segments_select-results"]/li[1]']); - //click next step - $I->click(['xpath'=>'//*[@id="step2_process"]']); - $I->waitForText('Import again', 10); //export those users - $I->amOnMailPoetPage('Subscribers'); $I->click(['xpath'=>'//*[@id="mailpoet_export_button"]']); //choose new list $I->selectOptionInSelect2($segment_name); //export - $I->click(['xpath'=>'//*[@id="mailpoet_subscribers_export"]/div[2]/table/tbody/tr[4]/th/a']); - $I->waitForText('9 subscribers were exported. Get the exported file here.'); + $I->click('.button-primary.mailpoet_export_process'); + $I->waitForText('3 subscribers were exported. Get the exported file here.', 20); $I->seeNoJSErrors(); } } \ No newline at end of file