2022-04-08 12:34:59 +02:00
|
|
|
/// <reference types="cypress" />
|
|
|
|
|
|
|
|
export {};
|
|
|
|
const randomId = String(Math.random()).split('.')[1];
|
|
|
|
const segmentName = `unleash-e2e-${randomId}`;
|
|
|
|
|
|
|
|
// Disable all active splash pages by visiting them.
|
|
|
|
const disableActiveSplashScreens = () => {
|
|
|
|
cy.visit(`/splash/operators`);
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('segments', () => {
|
|
|
|
before(() => {
|
|
|
|
disableActiveSplashScreens();
|
|
|
|
});
|
|
|
|
|
|
|
|
beforeEach(() => {
|
2022-05-25 10:14:22 +02:00
|
|
|
cy.login();
|
2022-04-08 12:34:59 +02:00
|
|
|
cy.visit('/segments');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can create a segment', () => {
|
2022-04-08 13:13:45 +02:00
|
|
|
if (document.querySelector("[data-testid='CLOSE_SPLASH']")) {
|
|
|
|
cy.get("[data-testid='CLOSE_SPLASH']").click();
|
2022-04-08 12:34:59 +02:00
|
|
|
}
|
|
|
|
|
2022-04-08 13:13:45 +02:00
|
|
|
cy.get("[data-testid='NAVIGATE_TO_CREATE_SEGMENT']").click();
|
2022-04-08 12:34:59 +02:00
|
|
|
|
|
|
|
cy.intercept('POST', '/api/admin/segments').as('createSegment');
|
|
|
|
|
2022-04-08 13:13:45 +02:00
|
|
|
cy.get("[data-testid='SEGMENT_NAME_ID']").type(segmentName);
|
|
|
|
cy.get("[data-testid='SEGMENT_DESC_ID']").type('hello-world');
|
|
|
|
cy.get("[data-testid='SEGMENT_NEXT_BTN_ID']").click();
|
|
|
|
cy.get("[data-testid='SEGMENT_CREATE_BTN_ID']").click();
|
2022-04-08 12:34:59 +02:00
|
|
|
cy.wait('@createSegment');
|
|
|
|
cy.contains(segmentName);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('gives an error if a segment exists with the same name', () => {
|
2022-04-08 13:13:45 +02:00
|
|
|
cy.get("[data-testid='NAVIGATE_TO_CREATE_SEGMENT']").click();
|
2022-04-08 12:34:59 +02:00
|
|
|
|
2022-04-08 13:13:45 +02:00
|
|
|
cy.get("[data-testid='SEGMENT_NAME_ID']").type(segmentName);
|
|
|
|
cy.get("[data-testid='SEGMENT_NEXT_BTN_ID']").should('be.disabled');
|
|
|
|
cy.get("[data-testid='INPUT_ERROR_TEXT']").contains(
|
2022-04-08 12:34:59 +02:00
|
|
|
'Segment name already exists'
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('can delete a segment', () => {
|
2022-04-08 13:13:45 +02:00
|
|
|
cy.get(`[data-testid='SEGMENT_DELETE_BTN_ID_${segmentName}']`).click();
|
2022-04-08 12:34:59 +02:00
|
|
|
|
2022-04-08 13:13:45 +02:00
|
|
|
cy.get("[data-testid='SEGMENT_DIALOG_NAME_ID']").type(segmentName);
|
|
|
|
cy.get("[data-testid='DIALOGUE_CONFIRM_ID'").click();
|
2022-04-08 12:34:59 +02:00
|
|
|
|
|
|
|
cy.contains(segmentName).should('not.exist');
|
|
|
|
});
|
|
|
|
});
|