Skip to content

Instantly share code, notes, and snippets.

View estruyf's full-sized avatar
:octocat:
Front Matter

Elio Struyf estruyf

:octocat:
Front Matter
View GitHub Profile
@estruyf
estruyf / playwright-jest-sample1.js
Last active February 27, 2020 17:45
Playwright with Jest for E2E testing - samples 1
const playwright = require('playwright');
const PAGE_URL = "https://www.eliostruyf.com";
describe(`UI Tests with Playwright`, () => {
let browser = null;
let page = null;
/**
* Create the browser and page context
@estruyf
estruyf / sharepoint.spec.js
Created January 19, 2020 13:21
Cypress test/spec file for SharePoint solutions
describe('SharePoint SPFx Testing', function() {
/**
* Before visiting SharePoint, we first need to authenticate
*/
before(function() {
cy.spAuth();
});
/**
@estruyf
estruyf / command.js
Created January 19, 2020 13:19
Cypress - SharePoint authentication plugin + command
Cypress.Commands.add('spAuth', function () {
const options = {
username: Cypress.env('username'),
password: Cypress.env('password'),
pageUrl: Cypress.env('appUrl')
}
cy.task('SharePointLogin', options).then(result => {
cy.clearCookies();
@estruyf
estruyf / focal-data.ts
Created December 19, 2019 12:50
Focal data of header image
const layoutContent = data.LayoutWebpartsContent;
const el = document.createElement('div');
el.innerHTML = layoutContent;
const divElm = el.querySelectorAll("[data-sp-canvascontrol]");
if (divElm && divElm.length > 0) {
const cntlData = divElm[0].getAttribute("data-sp-controldata");
if (cntlData) {
const pCtrlData = JSON.parse(cntlData);
if (pCtrlData && pCtrlData.properties) {
const focalData = {
@estruyf
estruyf / focal-data.ts
Created December 19, 2019 12:50
Focal data of header image
const layoutContent = data.LayoutWebpartsContent;
const el = document.createElement('div');
el.innerHTML = layoutContent;
const divElm = el.querySelectorAll("[data-sp-canvascontrol]");
if (divElm && divElm.length > 0) {
const cntlData = divElm[0].getAttribute("data-sp-controldata");
if (cntlData) {
const pCtrlData = JSON.parse(cntlData);
if (pCtrlData && pCtrlData.properties) {
const focalData = {
@estruyf
estruyf / header-image-data.json
Created December 19, 2019 12:46
Header image data
{
"id": "cbe7b0a9-3504-44dd-a3a3-0e5cacd07788",
"instanceId": "cbe7b0a9-3504-44dd-a3a3-0e5cacd07788",
"title": "\r\n Title area\r\n ",
"description": "\r\n Title area description\r\n ",
"serverProcessedContent": {
"htmlStrings": {},
"searchablePlainTexts": {},
"imageSources": {
"imageSource": "/sites/ECS2019/Shared Documents/brickheadz/boy1_b69dc338cfc310850f0459400b66b5d8.png"
@estruyf
estruyf / app-customizer-with-abort-controller.ts
Last active October 29, 2019 14:16
Application customizer with abort controller implementation to abort API calls during navigation events
import { override } from '@microsoft/decorators';
import { BaseApplicationCustomizer } from '@microsoft/sp-application-base';
import { SPEventArgs, Guid } from '@microsoft/sp-core-library';
import { SPHttpClient } from '@microsoft/sp-http';
import { cloneDeep } from '@microsoft/sp-lodash-subset';
interface NavigationEventDetails extends Window {
isNavigatedEventSubscribed: boolean;
currentPage: string;
currentHubSiteId: string;
@estruyf
estruyf / app-customizer-browser-history-binding.ts
Created September 11, 2019 11:00
Browser history binding
/**
* Bind the control to the browser history to do metadata check when page is in edit mode
*/
private bindToHistory(): void {
// Only need to bind the pushState once to the history
if (!this.pushState) {
// Binding to page mode changes
this.pushState = () => {
const defaultPushState = history.pushState;
// We need the current this context to update the component its state
@estruyf
estruyf / app-customizer-page-creation-checks.ts
Last active September 13, 2019 09:17
Application customizer with checks for page creation
import { override } from '@microsoft/decorators';
import { BaseApplicationCustomizer } from '@microsoft/sp-application-base';
import { SPEventArgs } from '@microsoft/sp-core-library';
interface NavigationEventDetails extends Window {
isNavigatedEventSubscribed: boolean;
currentPage: string;
currentHubSiteId: string;
currentUICultureName: string;
}
@estruyf
estruyf / library-component-localization.ts
Created September 5, 2019 18:23
Using the library component for localization
import * as strings from 'LibraryStrings';
import { LocaleKeys } from './loc/LocaleKeys';
export class LocalizationLibrary {
/**
* Retrieve the locale label for the specified key
*
* @param localeKey
*/