2023-04-04 10:46:28 +02:00
|
|
|
///<reference path="../../global.d.ts" />
|
|
|
|
|
|
|
|
import UserCredentials = Cypress.UserCredentials;
|
2023-03-08 11:47:42 +01:00
|
|
|
|
|
|
|
const ENTERPRISE = Boolean(Cypress.env('ENTERPRISE'));
|
|
|
|
const randomId = String(Math.random()).split('.')[1];
|
|
|
|
const featureToggleName = `notifications_test-${randomId}`;
|
|
|
|
const baseUrl = Cypress.config().baseUrl;
|
|
|
|
let strategyId = '';
|
2023-04-04 10:46:28 +02:00
|
|
|
let userIds: number[] = [];
|
|
|
|
let userCredentials: UserCredentials[] = [];
|
2023-03-08 11:47:42 +01:00
|
|
|
const userName = `notifications_user-${randomId}`;
|
|
|
|
const projectName = `default`;
|
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
const EDITOR = 2;
|
2023-03-08 11:47:42 +01:00
|
|
|
|
|
|
|
describe('notifications', () => {
|
|
|
|
before(() => {
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.runBefore();
|
2023-03-08 11:47:42 +01:00
|
|
|
});
|
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
it('should create a notification when a feature is created in a project', () => {
|
|
|
|
cy.login_UI();
|
|
|
|
cy.createUser_API(userName, EDITOR).then(value => {
|
|
|
|
userIds = value.userIds;
|
|
|
|
userCredentials = value.userCredentials;
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.login_UI();
|
|
|
|
cy.visit(`/projects/${projectName}`);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.createFeature_UI(featureToggleName);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//Should not show own notifications
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_BUTTON']").click();
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//then
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_MODAL']").should('exist');
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
const credentials = userCredentials[0];
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//Sign in as a different user
|
|
|
|
cy.login_UI(credentials.email, credentials.password);
|
|
|
|
cy.visit(`/projects/${projectName}`);
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_BUTTON']").click();
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//then
|
|
|
|
cy.get("[data-testid='UNREAD_NOTIFICATIONS']").should('exist');
|
|
|
|
cy.get("[data-testid='NOTIFICATIONS_LIST']")
|
|
|
|
.eq(0)
|
|
|
|
.should('contain.text', `New feature ${featureToggleName}`);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
//clean
|
|
|
|
// We need to login as admin for cleanup
|
|
|
|
cy.login_UI();
|
|
|
|
userIds.forEach(id =>
|
|
|
|
cy.request('DELETE', `${baseUrl}/api/admin/user-admin/${id}`)
|
|
|
|
);
|
2023-03-08 11:47:42 +01:00
|
|
|
|
2023-04-04 10:46:28 +02:00
|
|
|
cy.deleteFeature_API(featureToggleName);
|
|
|
|
});
|
2023-03-08 11:47:42 +01:00
|
|
|
});
|
|
|
|
});
|