use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.
the class TestDataSteps method discardEditedDocument.
/**
* <p>
* Closes the current publication discarding current changes.
* </p><p>
* Only applicable to scenarios that leave the document in editable state; implemented as an {@linkplain After}
* hook rather than a step because this is really a test cleanup/tear-down activity that doesn't warrant expressing
* explicitly as a scenario step.
* </p><p>
* To ensure that this method gets called at the end of your scenario, tag the scenario with
* {@code @DiscardAfter}.
* </p>
*/
@After(value = "@DiscardAfter", order = 500)
public void discardEditedDocument() throws Throwable {
Publication currentPublication = testDataRepo.getCurrentPublication();
if (currentPublication != null) {
final String currentPublicationName = currentPublication.getName();
log.debug("Discarding and closing current publication: {}.", currentPublicationName);
contentPage.discardUnsavedChanges(currentPublicationName);
}
Dataset dataset = testDataRepo.getDataset();
if (dataset != null) {
String datasetName = dataset.getName();
log.debug("Discarding and closing current dataset: {}.", datasetName);
contentPage.discardUnsavedChanges(datasetName);
}
PublicationSeries series = testDataRepo.getPublicationSeries();
if (series != null) {
final String currentSeriesName = series.getName();
log.debug("Discarding and closing current series: {}.", currentSeriesName);
contentPage.discardUnsavedChanges(currentSeriesName);
}
PublicationArchive archive = testDataRepo.getPublicationArchive();
if (archive != null) {
final String currentArchiveName = archive.getName();
log.debug("Discarding and closing current archive: {}.", currentArchiveName);
contentPage.discardUnsavedChanges(currentArchiveName);
}
}
use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.
the class CmsSteps method givenIHaveAPublicationOpenForEditing.
@Given("^I have a publication opened for editing$")
public void givenIHaveAPublicationOpenForEditing() throws Throwable {
final Publication publication = TestDataFactory.createBareMinimumPublication().build();
testDataRepo.setPublication(publication);
createPublicationInEditableState(publication);
// Since previous step created a new document which was not saved, immediately after a login,
// the edit document screen is displayed (instead of dashboard)
assertTrue("Publication edit screen is displayed", contentPage.isDocumentEditScreenOpen());
}
use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.
the class CmsSteps method givenIHaveAPublishedPublicationWithNominalDateFallingAfterWeeksFromNow.
@Given("^I have a published publication with nominal date falling after (\\d+) weeks from now$")
public void givenIHaveAPublishedPublicationWithNominalDateFallingAfterWeeksFromNow(final int weeksFromNow) throws Throwable {
final Publication publicationWithNominalDateBeforeCutOff = TestDataFactory.createBareMinimumPublication().withNominalDate(Instant.now().plus(DAYS_IN_WEEK * weeksFromNow, ChronoUnit.DAYS).plus(1, ChronoUnit.DAYS)).build();
testDataRepo.setPublication(publicationWithNominalDateBeforeCutOff);
createPublishedPublication(publicationWithNominalDateBeforeCutOff);
}
use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.
the class CmsSteps method nominalPublicationDateIsDisplayedUsingFormat.
@Then("^Publication Date is displayed using format \"([^\"]*)\"$")
public void nominalPublicationDateIsDisplayedUsingFormat(final String dateFormat) throws Throwable {
final Publication.NominalPublicationDate nominalPublicationDate = testDataRepo.getCurrentPublication().getNominalPublicationDate();
final String expectedDate = nominalPublicationDate.inFormat(dateFormat);
assertThat("Publication Date is formatted in a way consistent with pattern '" + dateFormat + "'", publicationPage.getNominalPublicationDate(), is(expectedDate));
}
use of uk.nhs.digital.ps.test.acceptance.models.Publication in project hippo by NHS-digital-website.
the class CmsSteps method givenIHaveAPublishedPublicationWithNominalDateFallingThis.
@Given("^I have a published publication with nominal date falling this (week|month|year)$")
public void givenIHaveAPublishedPublicationWithNominalDateFallingThis(String unit) throws Throwable {
LocalDateTime date;
if (unit.equals("week")) {
// we want a day that is this week but not today or yesterday
date = getDateRelativeToToday(DAY_OF_WEEK, 1);
} else if (unit.equals("month")) {
// we want a date that is this month but not this week, so don't pick a date 7 days either side or today
date = getDateRelativeToToday(DAY_OF_MONTH, DAYS_IN_WEEK);
} else {
// we want a date that is this year but not this week or month, so don't pick a date one month either side
date = getDateRelativeToToday(MONTH_OF_YEAR, 1);
}
final Publication publication = TestDataFactory.createBareMinimumPublication().withNominalDate(date.toInstant(ZoneOffset.UTC)).build();
testDataRepo.setPublication(publication);
createPublishedPublication(publication);
}
Aggregations